Skip to content

Instantly share code, notes, and snippets.

View vanbo's full-sized avatar

Ivan Andreev vanbo

View GitHub Profile
@vanbo
vanbo / wc-paysafe-add-account-based-on-order-currency
Last active September 9, 2019 08:54
WC Paysafe: Add account number based on order currency
// Normal order
add_filter( 'wc_paysafe_request_params', 'prefix_add_account_number', 10, 2 );
// Subscriptions/Pre-Orders order
add_filter( 'wc_paysafe_addons_request_params', 'prefix_add_account_number', 10, 2 );
/**
* @param $params
* @param WC_Order $order
*
* @return mixed
*/
@vanbo
vanbo / wc-trustcommerce-request-remove-or-format-ip
Last active January 15, 2019 19:18
WC TrustCommerce: Remove or format IP in requests
// Removes the 'ip' from TrustCommerce single payment request
add_filter( 'wc_trustcommerce_process_single_payment_request', 'prefix_remove_ip_from_request', 10, 3 );
function prefix_remove_ip_from_request( $request, $order, $gateway ) {
if ( isset( $request['ip'] ) ) {
unset( $request['ip'] );
}
return $request;
}
@vanbo
vanbo / psigate-show-html-api-only
Created May 18, 2018 08:06
Psigate Show Only HTML API Option
add_action( 'wp_footer', 'prefix_hide_the_card_form' );
function prefix_hide_the_card_form() {
// Checkout or the Pay page
if ( is_checkout() || is_checkout_pay_page() ) {
?>
<style>
.payment_method_psigate div#credit_card_info {
display: none !important;
}
@vanbo
vanbo / wc-paytrace-custom-data-payment-request
Last active January 15, 2021 15:58
Paytrace Add custom data to payment request
add_filter( 'wc_paytrace_transaction_request', 'prefix_filter_paytrace_transaction_request', 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)
*
* @return array
*/
@vanbo
vanbo / borica-p12-set-password
Last active August 6, 2018 09:00
borica-p12-set-password
add_filter( 'wc_borica_certificates_password', 'pref_set_p12_password', 10, 2 );
function pref_set_p12_password( $default, $password_type ) {
$pass = $default;
if ( 'p12_certificate' == $password_type ) {
// In 'set_your_pass' write any password you want.
// You will use this same password to add the certificate to the browser
$pass = 'set_your_pass';
}
return $pass;
@vanbo
vanbo / paysafe-add-accordd-params
Last active August 9, 2018 08:10
Paysafe: Add accordD financing parameter
// Normal order
add_filter( 'wc_paysafe_request_params', 'prefix_add_accordd', 10, 2 );
// Subscriptions/Pre-Orders order
add_filter( 'wc_paysafe_addons_request_params', 'prefix_add_accordd', 10, 2 );
function prefix_add_accordd( $params, $order ) {
$params['accordD'] = array(
// This is the type of financing offered. Possible values are:
// DEFERRED_PAYMENT – Deferred payment financing
// EQUAL_PAYMENT – Equal payment financing
add_filter( 'wc_borica_certificates_password', 'prefix_set_private_key_password', 10, 2 );
function prefix_set_private_key_password( $default, $password_type ) {
$pass = $default;
if ( 'private_key' == $password_type ) {
// Replace 'set_your_pass' with your actual private key password.
$pass = 'set_your_pass';
}
return $pass;
}
@vanbo
vanbo / filter-pay360-hosted-request
Created September 10, 2018 15:52
pay360-hosted-request-filter
add_filter( 'pay360_hosted_get_parameters', 'prefix_add_request_parameters' );
function prefix_add_request_parameters($args, $order, $gateway) {
// Add, remove or update a parameter
// Add template parameter
$args['template'] = 'template_name';
// Always return the arguments back
return $args;
}
@vanbo
vanbo / pay360-limit-description-to-255-chars
Last active October 2, 2018 10:59
Pay360 Limit Description to 255 chars
add_filter( 'pay360_hosted_cashier_get_parameters', 'prefix_limit_description', 10, 3 );
function prefix_limit_description($args, $order, $gateway) {
// Add, remove or update a parameter
// Limit the description to 252 chars and add ... at the end
$args['transaction']['description'] = substr( $args['transaction']['description'], 0, ( 252 ) ) . '...';
// Always return the arguments back
return $args;
}
@vanbo
vanbo / linnworks-transfer-tracking-code
Created October 17, 2018 11:46
Linnworks - Transfer Tracking code to plugin
/**
* Adds hooks on the rest init
*/
function prefix_filter_order_fields() {
// Rest API update of the order
add_filter( "woocommerce_rest_pre_insert_shop_order_object", 'prefix_transfer_tracking_info_to_format', 5, 2 );
}
add_action( 'rest_api_init', 'prefix_filter_order_fields', 0 );
/**