Skip to content

Instantly share code, notes, and snippets.

@vanbo
Last active April 6, 2021 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanbo/aef8b9c079f6a1e4e07eacc35e9f2e55 to your computer and use it in GitHub Desktop.
Save vanbo/aef8b9c079f6a1e4e07eacc35e9f2e55 to your computer and use it in GitHub Desktop.
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 );
$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