Skip to content

Instantly share code, notes, and snippets.

View vanbo's full-sized avatar

Ivan Andreev vanbo

View GitHub Profile
@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 / 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-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 / gist:26ef8a2464b72e4b0b966ffb4067d9eb
Last active June 9, 2025 16:30
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-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 / wc-paysafe-add-transaction-amout-to-order-notes
Last active September 9, 2021 12:47
WC Paysafe: Add transaction amount to the order notes
add_action( 'wc_paysafe_payment_response_processed', 'vanbodevelops_paysafe_add_order_details_after_payment', 10, 2 );
/**
* IMPORTANT: Add the code to your 'child-theme/functions.php' file
*
* @param \WC_Order $order
* @param \WcPaysafe\Api\Response_Abstract $response
*/
function vanbodevelops_paysafe_add_order_details_after_payment($order, $response) {
// If the transaction is successful
if ( 'completed' == strtolower( $response->get_status() ) ) {
@vanbo
vanbo / wc-trustcommerce-limit-transactions
Created September 13, 2021 17:52
wc-trustcommerce-limit-transactions
/**
* IMPORTANT: Add to your 'wp-content/themes/theme-name/functions.php' file
*
* Description: Will limit the trustcommerce requests per interval of time.
*/
add_filter( 'wc_trustcommerce_process_single_payment_request', 'vanbodevelops_limit_transaction_requests', 9999, 3 );
/**
* @param $request
* @param $order
@vanbo
vanbo / paysafe-json-api-modify-merchantrefnum
Created September 22, 2021 12:09
Paysafe JSON API: modify MerchantRefNumber
/**
* IMPORTANT: Add to your 'wp-content/themes/theme-name/functions.php' file
*/
add_filter( 'wc_paysafe_token_transaction_parameters', 'vanbodevelops_paysafe_modify_merchant_ref_number', 10, 4 );
/**
* @param array $params The request parameters
* @param \WC_Order $order The WC order object
* @param string $token The payment token
* @param string $trans_type The transaction type: 'cards', 'directdebit'
*
@vanbo
vanbo / wc-paytrace-strip-desc-tags
Created December 14, 2021 19:00
WC Paytrace-strip description tags
/**
* Please add to your "wp-content/themes/theme-name/functions.php" file or anywhere that you know the code will be executed
*/
add_filter( 'wc_paytrace_transaction_request', 'vanbodevelops_paytrace_request_strip_tags', 10, 5 );
/**
* @param array $request_parameters
* @param WC_Order $order The order to be charged
* @param float $amount Amount to be charged
* @param bool $is_subscription Is this a subscription
* @param bool $is_paid_with_profile Is this a profile payment(true) or new card is used(false)
@vanbo
vanbo / paytrace-load-public-key
Last active February 11, 2022 10:25
paytrace-load-public-key
/**
* IMPORTANT: The code should be added to the "child-theme/functions.php" file or anywhere that you know it will be loaded
*/
function vd_paytrace_load_js() {
if ( ! class_exists( '\WcPaytrace\Helpers\Factories' ) ) {
return;
}
$pt_gateway = \WcPaytrace\Helpers\Factories::get_gateway( 'paytrace' );