Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View vanbo's full-sized avatar

Ivan Andreev vanbo

View GitHub Profile
@vanbo
vanbo / wc-paytrace-set-order-to-processing-after-capture
Created June 25, 2021 16:33
WC Paytrace: set order to processing after capture
add_action( 'wc_paytrace_capture_approved_response_processed', 'vanbodevelops_set_order_processing_after_capture', 10, 3 );
/**
* @param $response
* @param \WC_Order $order
* @param $amount
*/
function vanbodevelops_set_order_processing_after_capture( $response, $order, $amount ) {
// It's our gateway
if ( 'paytrace' != $order->get_payment_method() ) {
@vanbo
vanbo / gist:26ef8a2464b72e4b0b966ffb4067d9eb
Created June 23, 2021 16:19
WC Paytrace - Set order to on hold when authorized only
/**
* IMPORTANT: Add the code to your "themes/theme-name/functions.php" file.
*/
add_filter( 'woocommerce_payment_complete_order_status', 'vanbodevelops_set_order_to_onhold_after_processing', 10, 3 );
function vanbodevelops_set_order_to_onhold_after_processing( $status, $order_id, $order_now ) {
$order = wc_get_order( $order_id );
if ( ! class_exists( 'WC_Paytrace_Order' ) ) {
return $status;
}
@vanbo
vanbo / wc-paysafe-send-process-order-emails-to-admin
Last active May 10, 2021 17:18
wc paysafe send payment complete emails to the admin as well
add_action( 'init', 'vanbodevelops_add_email_actions' );
function vanbodevelops_add_email_actions() {
// Triggers for this email.
add_action( 'woocommerce_order_status_cancelled_to_processing_notification', 'send_order_emails', 11, 2 );
add_action( 'woocommerce_order_status_failed_to_processing_notification', 'send_order_emails', 11, 2 );
add_action( 'woocommerce_order_status_on-hold_to_processing_notification', 'send_order_emails', 11, 2 );
add_action( 'woocommerce_order_status_pending_to_processing_notification', 'send_order_emails', 11, 2 );
}
/**
@vanbo
vanbo / wc-paysafe-hosted-end-server-to-server-notification
Last active March 8, 2021 10:04
WooCommerce Paysafe: End server to server notification on Hosted
// Actions
add_action( 'woocommerce_api_wc_gateway_paysafe_response', 'vanbodevelops_intercept_hosted_response', 9 );
function vanbodevelops_intercept_hosted_response() {
/**
* @var \WcPaysafe\Gateways\Redirect\Gateway $gateway
*/
$gateway = vanbodevelops_get_gateway( 'netbanx' );
if ( 'hosted' != $gateway->get_option( 'integration', 'hosted' ) ) {
return;
@vanbo
vanbo / wc-pay360-modify-transaction-reference-number
Last active April 6, 2021 15:09
Modify the Pay360 Hosted Cashier transaction request to include the customer prefix
add_filter( 'pay360_hosted_cashier_get_parameters', 'vanbodevelops_filter_hc_parameters', 10, 3 );
function vanbodevelops_filter_hc_parameters( $args, $order, $gateway ) {
// This is the customer ID prefix, from the settings
$customer_prefix = $gateway->get_option( 'cashier_customer_prefix' );
$ref_number_parts = explode( ':', $args['transaction']['merchantReference'] );
$customer_prefix = str_replace( array( ' ', ':', ), array( '-', '-' ), $customer_prefix );
@vanbo
vanbo / woocommerce psigate limit transaction attempts
Last active March 22, 2021 08:37
WooCommerce Psigate limit transaction attempts
/**
* Add to "wp-content\themes\child-theme\functions.php" file
*/
add_filter( 'wc_psigate_process_acc_manager_payment_parameters', 'vanbodevelops_filter_acc_parameters', 10, 2 );
add_filter( 'wc_psigate_process_credit_card_payment_parameters', 'vanbodevelops_filter_acc_parameters', 10, 2 );
function vanbodevelops_filter_acc_parameters( $parameters, $order ) {
$transaction_count = get_incremented_transaction_attempt( $order );
// Check if the order is paid and which attempt of transaction it is
@vanbo
vanbo / woocommerce-pay360-replace-checkout-icons
Last active February 23, 2021 13:07
WooCommerce Pay360 replace checkout icons
/**
* IMPORTANT: Place the snippet inside your "wp-content\themes\child-theme\functions.php" file
*/
/**
* Replace the Pay360 image in the checkout icon
*/
add_filter( 'woocommerce_pay360_icon', 'vanbodevelops_pay360_icon', 10 );
function vanbodevelops_pay360_icon( $image ) {
return WC_Pay360::plugin_url() . '/pay360-logo.png';
@vanbo
vanbo / wc-pay360-modify-request-register
Created February 17, 2021 09:10
WC Pay360 Modify Request 'register'
/**
* NOTЕ: Add the code to your "themes\child-theme\functions.php" file
*/
add_filter( 'pay360_hosted_cashier_get_parameters', 'vanbodevelops_do_not_register_profile', 10, 3 );
function vanbodevelops_do_not_register_profile( $args, $order, $get_gateway ) {
// Send the 'registered' parameter as false,
// so Pay360 will not create a profile for the customer in their system.
if ( ! empty( $args['customer'] ) ) {
$args['customer']['registered'] = false;
}
@vanbo
vanbo / wc-psigate-include-shipping-for-free-orders
Last active January 13, 2021 17:08
WooCommerce Psigate include the shipping in the order total for free orders
/**
* Add to your "themes/child-theme-folder/functions.php" file
*/
add_filter( 'wc_psigate_process_credit_card_payment_parameters', 'vanbo_combine_shipping_in_total', 10, 2 );
function vanbo_combine_shipping_in_total( $parameters, $order ) {
$total = number_format( ( $order->get_total() - WC_Compat_PsiGate::get_total_shipping( $order ) - $order->get_total_tax() ), 2, '.', '' );
// If the total is 0
if ( 0 >= $total ) {
// Subtotal will equal the order total
@vanbo
vanbo / wc-paytrace-block-card-types-js
Last active October 19, 2020 17:48
WC Paytrace block card types on checkout
/**
* NOTE: Add this snippet to your "child-theme\functions.php" file
*/
add_action( 'wp_footer', 'vanbo_add_block_script_to_footer', 9999 );
function vanbo_add_block_script_to_footer() {
?>
<script>
(function ($) {
/**