Skip to content

Instantly share code, notes, and snippets.

View vanbo's full-sized avatar

Ivan Andreev vanbo

View GitHub Profile
@vanbo
vanbo / wc-trustcommerce-modify-token-payment-request
Created August 20, 2019 15:14
WooCommerce TrustCommerce Modify Token Payment Request
add_filter( 'wc_trustcommerce_process_profile_payment_request_request', 'prefix_modify_token_payment_request', 10, 3 );
/**
* @param array $request
* @param WC_Order $order
* @param $gateway
*
* @return mixed
*/
function prefix_modify_token_payment_request( $request, $order, $gateway ) {
@vanbo
vanbo / psigate-modify-api-urls
Created September 9, 2019 14:58
WC Psigate Modify API URLs
// Modify XML-API test URL
add_filter( 'wc_psigate_xml_test_url', 'prefix_modify_xml_api_test_url' );
function prefix_modify_xml_api_test_url($url) {
// Put any url in the place of the example one
return 'https://staging.psigate.com:27989/Messenger/XMLMessenger';
}
// Modify Account Manager API test URL
add_filter( 'wc_psigate_manager_test_url', 'prefix_modify_account_manager_test_url' );
function prefix_modify_account_manager_test_url($url) {
@vanbo
vanbo / wc-paysafe-checkoutjs-automatically-open-form
Last active March 19, 2020 19:14
wc-paysafe-checkoutjs-automatically-open-form
add_action( 'wp_footer', 'prefix_add_script_to_footer' );
/**
* Adds a script to automatically load the Paysafe Layover on the WooCommerce pay page
*/
function prefix_add_script_to_footer() {
if ( ! is_checkout_pay_page() ) {
return;
}
?>
@vanbo
vanbo / wc-paysafe-modify-overlay-settings
Last active January 14, 2021 15:29
WC Paysafe Modify Overlay settings
/**
* Add the gist to your "theme/functions.php" file or any file loading with after the "theme/functions.php" file
*/
add_filter( 'wc_paysafe_checkoutjs_order_iframe_props', 'prefix_modify_overlay_parameters', 10, 3 );
/**
* @param array $parameters
* @param \WC_Order $order
* @param \WcPaysafe\Api\Checkoutjs\Service $service
*
@vanbo
vanbo / wc-psigate-free-trial-subscription
Created December 12, 2019 07:32
WooCommerce PsiGate - Allow processing of Free Trial Subscription
add_filter( 'wc_psigate_process_credit_card_payment_parameters', 'prefix_allow_free_trial_subscription', 10, 2 );
/**
* @param array $parameters
* @param \WC_Order $order
*
* @return mixed
*/
function prefix_allow_free_trial_subscription( $parameters, $order ) {
if ( ! function_exists('wcs_order_contains_subscription') ) {
return $parameters;
@vanbo
vanbo / wc-epaytouch-payment-setup-request
Created January 23, 2020 16:18
WC Epay.bg OneTouch - Filter Setup Payment Request
/**
* Place the code in your theme/functions.php file
*/
add_filter( 'wc_epay_one_touch_payment_setup_params', 'prefix_epaytouch_setup_params', 10, 4 );
function prefix_epaytouch_setup_params( $params, $device_id, $token, $account_payment_class ) {
if ( isset( $params['EXP'] ) ) {
// remove the expiration time
unset( $params['EXP'] );
}
@vanbo
vanbo / wc-paytrace-force-api-to-user-tls-1-2
Created February 17, 2020 09:47
WC Paytrace - Force API to use TLS 1.2
add_action( 'http_api_curl', 'paytrace_http_api_curl', 10, 3 );
/**
* Force posts to Paytrace to use TLS v1.2.
*
* @param string $handle
* @param mixed $r
* @param string $url
*/
function paytrace_http_api_curl( $handle, $r, $url ) {
if ( strstr( $url, 'https://' ) && ( strstr( $url, 'api.paytrace.com' ) || strstr( $url, 'paytrace.com/api' ) ) ) {
@vanbo
vanbo / woocommerce-paytrace-change-request-timeout
Created May 4, 2020 17:43
WooCommerce Paytrace change request timeout
/**
* NOTE: Add the code to the 'theme/functions.php" file
*/
add_filter( 'wc_paytrace_request_timeout', 'vanbo_paytrace_edit_timeout', 10 );
/**
* @param int $timeout The current seconds
*
* @return int Return the seconds you want the timeout to be
*/
function vanbo_paytrace_edit_timeout($timeout){
@vanbo
vanbo / woocommerce-complete-order-from-link-to-edit-order-screen
Last active June 2, 2020 15:57
Complete the order from a link to the Edit order screen
@vanbo
vanbo / woocommerce-paysafe-json-pay-page-payment
Created June 9, 2020 20:30
WooCommece Paysafe JSON Pay Page Payment
add_filter( 'wc_paysafe_layover_on_checkout', 'vanbo_wc_paysafe_layover_on_checkout' );
function vanbo_wc_paysafe_layover_on_checkout( $on_checkout ) {
return true;
}