Last active
January 15, 2021 15:58
-
-
Save vanbo/dc3d9bc8660a7de33aafb44dde3033fa to your computer and use it in GitHub Desktop.
Paytrace Add custom data to payment request
This file contains hidden or 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( '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 | |
| */ | |
| function prefix_filter_paytrace_transaction_request( $request_parameters, $order, $amount, $is_subscription, $is_paid_with_profile ) { | |
| /** | |
| * Let's say that the custom data is in the order meta | |
| */ | |
| $field = $order->get_meta( 'custom_data_meta_name', true ); | |
| // Add the field to the request | |
| $request_parameters['NameOfPaytraceField'] = $field; | |
| // Log the parameters after we modify them. Can help to see what values we added | |
| // The logs are in WooCommerce > Status > Logs > "paytrace-[date]-[hash].log" | |
| \WC_Paytrace::add_debug_log( 'Parameters after we modified them: ' . print_r($request_parameters, true) ); | |
| return $request_parameters; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment