Skip to content

Instantly share code, notes, and snippets.

@vanbo
Created September 22, 2021 12: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/26554817bfdb6eb48df25f5c56ada71a to your computer and use it in GitHub Desktop.
Save vanbo/26554817bfdb6eb48df25f5c56ada71a to your computer and use it in GitHub Desktop.
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'
*
* @return array
*/
function vanbodevelops_paysafe_modify_merchant_ref_number( $params, $order, $token, $trans_type ) {
// Add any value you want to the reference number
$params['merchantRefNum'] = 'add-the-value-as-prefix-' . $params['merchantRefNum'] . '-or-add-the-value-as-suffix';
return $params;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment