Description
The wpforms_authorize_net_process_transaction
filter is used to set arguments on the Authorize.net payment sent from WPForms while processing the form entry for payments.
Parameters
- $transaction
- (object) WPForms Authorize.Net Process object.
- $args
- (array) Single transaction arguments.
Source
wpforms-authorize-net/src/Api/Api.php
More Information
The wpforms_authorize_net_process_transaction
filter is used to set specific arguments on Authorize.net transaction payments.
Using the wpforms_authorize_net_process_payment_single_args
filter, you can pull this information from WPForms and use the wpforms_authorize_net_process_transaction
filter to set those fields on the payment. Address fields, invoice numbers, etc are just a few of the examples.
Examples
/** * Filter used to get the address field information. * * @link https://wpforms.com/developers/wpforms_authorize_net_process_payment_single_args/ * * @param array $args Single payment arguments. * @param object $process WPForms Authorize.Net Process object. * * @return array */ function wpf_dev_authorize_net_process_payment_single_add_fields_to_args( $args, $process ) { // Replace 3 in $process->fields[3] to the form id of your address field. $args[ 'address' ] = $process->fields[3]; return $args; } add_filter( 'wpforms_authorize_net_process_payment_single_args', 'wpf_dev_authorize_net_process_payment_single_add_fields_to_args', 10, 2 ); /** * Set the customer's Bill To address. * * @link https://wpforms.com/developers/wpforms_authorize_net_process_transaction/ * * @param netauthorizeapicontractv1TransactionRequestType $transaction Single transaction object. * @param array $args Single transaction arguments. * * @return netauthorizeapicontractv1TransactionRequestType */ function wpf_dev_authorize_net_process_transaction_add_address_to_transaction( $transaction, $args ) { $bill_to = $transaction->getBillTo(); if ( is_null( $bill_to ) ) { $bill_to = new netauthorizeapicontractv1CustomerAddressType(); } $address = $args[ 'address' ][ 'address1' ]; if ( ! empty( $args[ 'address' ][ 'address2' ] ) ) { $address .= ' ' . $args[ 'address' ][ 'address2' ]; } $bill_to->setAddress( $address ); $bill_to->setCity( $args[ 'address' ][ 'city' ] ); $bill_to->setState( $args[ 'address' ][ 'state' ] ); $bill_to->setZip( $args[ 'address' ][ 'postal' ] ); $bill_to->setCountry( $args[ 'address' ][ 'country' ] ); $transaction->setBillTo( $bill_to ); return $transaction; } add_filter( 'wpforms_authorize_net_process_transaction', 'wpf_dev_authorize_net_process_transaction_add_address_to_transaction', 10, 2 );
For any assistance in locating your particular field ID, please check out this tutorial.
Related
Filter Reference: wpforms_authorize_net_process_payment_single_args
Tutorial Reference: