Skip to content

Instantly share code, notes, and snippets.

View vanbo's full-sized avatar

Ivan Andreev vanbo

View GitHub Profile
@vanbo
vanbo / wc-epaybg-change-request-description.php
Created September 18, 2023 19:53
wc-epaybg-change-request-description
add_filter( 'wc_epaybg_request_parameters', 'vanbodevelops_epaybg_add_order_number_to_description', 10, 4 );
/**
* @param $epaybg_args
* @param $payment_type
* @param $order
* @param \WC_Gateway_Epaybg $gateway
*
* @return array
*/
function vanbodevelops_epaybg_add_order_number_to_description( $epaybg_args, $payment_type, $order, $gateway ) {
@vanbo
vanbo / pay360-register-all-users
Created August 16, 2023 12:36
pay360-register-all-users
/**
* NOTE: Add to 'wp-content/themes/your-theme/functions.php' file
*/
add_filter( 'pay360_hosted_cashier_get_parameters', 'vanbodevelops_pay360_always_register_account', 10, 3 );
function vanbodevelops_pay360_always_register_account( $args, $order, $gateway ) {
if ( 0 < $order->get_customer_id() ) {
return $args;
}
$customer_id = $order->get_meta( 'wc_pay360_guest_customer_id', true );
@vanbo
vanbo / paytrace-protect-js-theme.php
Created March 10, 2023 15:23
paytrace-protect-js-theme
add_filter( 'wc_paytrace_protect_form_theme', 'vanbo_paytrace_protect_js_theme', 10, 3 );
function vanbo_paytrace_protect_js_theme( $theme_styles, $map, $id ) {
return array(
'iframe' => array(
'background' => '',
'padding' => '',
'margin' => '',
),
'code' => array(
'font_color' => '#6d6d6d',
@vanbo
vanbo / paysafe-filter-request-params.php
Last active January 20, 2023 12:20
paysafe-filter-request-params
add_filter( 'wc_paysafe_token_transaction_parameters', 'vanbo_paysafe_token_request_params', 10, 4 );
/**
* @param array $params
* @param \WC_Order $order
* @param $token
* @param string $type Possible values: interac, cards, directdebit
*
* @return array
*/
function vanbo_paysafe_token_request_params( $params, $order, $token, $type ) {
@vanbo
vanbo / paytrace-add-card-details-to-order.php
Created June 8, 2022 14:59
paytrace-add-card-details-to-order.php
/**
* NOTE: Add to 'wp-content/themes/your-theme/functions.php' file
*/
add_action( 'wc_paytrace_transaction_approved_response_processed', 'vanbodevelops_add_order_details', 10, 2 );
/**
* @param \WcPaytrace\Abstracts\Response $response
* @param \WC_Order $order
*/
function vanbodevelops_add_order_details( $response, $order ) {
try {
@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' );
@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 / 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-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 / 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() ) ) {