Last active
April 6, 2021 15:09
-
-
Save vanbo/aef8b9c079f6a1e4e07eacc35e9f2e55 to your computer and use it in GitHub Desktop.
Modify the Pay360 Hosted Cashier transaction request to include the customer prefix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | |
$new_transaction_number = $ref_number_parts[0] . ':' . $customer_prefix . ':' . $ref_number_parts[2] . ':' . $ref_number_parts[1] . ':' . $ref_number_parts[3]; | |
$args['transaction']['merchantReference'] = $new_transaction_number; | |
$return_url = remove_query_arg( 'merchantRef', $args['session']['returnUrl']['url'] ); | |
$args['session']['returnUrl']['url'] = add_query_arg( 'merchantRef', $new_transaction_number, $return_url ); | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment