How to Send an Address Through to Payments


Would you like to include the address from your WPForms to any payment? will accept certain metadata they already have mapped to their payment API. In this tutorial, we’ll show you how to send through the payment’s Address form field inside the payments.


In order to set up your form to accept payments, please review this documentation.

Once your form is set up to accept these payments, you can now copy and paste this code snippet to your site.

 * Include an address into the set of Authorize.Net args.
 * @link
 * @param array                        $args    Single payment arguments.
 * @param \WPFormsAuthorizeNet\Process $process WPForms Authorize.Net Process object.
 * @return array

function wpf__authorize_net_process_payment_single_add_fields_to_args( $args, $process ) {
   // Replace 3 in $process->fields[3] to an id of your address field.
   $args['address'] = $process->fields[3];
   return $args;
add_filter( 'wpforms_authorize_net_process_payment_single_args', 'wpf__authorize_net_process_payment_single_add_fields_to_args', 10, 2 );

 * Set the customer's Bill To address.
 * @link
 * @param \net\authorize\api\contract\v1\TransactionRequestType $transaction Single transaction object.
 * @param array                                                 $args        Single transaction arguments.
 * @return \net\authorize\api\contract\v1\TransactionRequestType

function wpf__authorize_net_process_transaction_add_address_to_transaction( $transaction, $args ) {
   $bill_to = $transaction->getBillTo();
   if ( is_null( $bill_to ) ) {
      $bill_to = new \net\authorize\api\contract\v1\CustomerAddressType();
   $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__authorize_net_process_transaction_add_address_to_transaction', 10, 2 );

In the first code snippet, we’re using the code to grab our Address form field ID fields[3] so the API will know where to pull the address information from. Please remember to update this field ID to match the field ID of your form.

And that’s it, when you payments are sent through WPForms, they will now update the customer’s address.

sending address through to

Would you like to also learn how to send metadata through to Stripe? Take a look at this tutorial on How To Send Metadata to Stripe Payments.

Filter References: