Achtung!

Dieser Artikel enthält PHP-Code und richtet sich an Entwickler. Wir stellen diesen Code als Service zur Verfügung, bieten jedoch keine Unterstützung für Codeanpassungen oder die Entwicklung durch Dritte.

Für zusätzliche Hilfe siehe das Tutorial von WPBeginner zum Hinzufügen von benutzerdefiniertem Code.

Schließen

Beschreibung

Der wpforms_authorize_net_process_transaction Filter wird verwendet, um Argumente für die von WPForms gesendete Authorize.Net-Zahlung festzulegen, während der Formulareintrag für Zahlungen verarbeitet wird.

Parameter

$transaktion
(object) WPForms Authorize.Net Prozessobjekt.
$args
(array) Einzelne Transaktionsargumente.

Quelle

wpforms-authorize-net/src/Api/Api.php

Weitere Informationen

Der wpforms_authorize_net_process_transaction Filter wird verwendet, um spezifische Argumente für Authorize.Net-Transaktionszahlungen festzulegen.

Mithilfe des wpforms_authorize_net_process_payment_single_args Filters können Sie diese Informationen aus WPForms abrufen und den wpforms_authorize_net_process_transaction Filter verwenden, um diese Felder für die Zahlung festzulegen. Adressfelder, Rechnungsnummern usw. sind nur einige Beispiele.

Beispiele

/**
 * 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 );

Für Hilfe bei der Suche nach Ihrer spezifischen Feld-ID lesen Sie bitte dieses Tutorial.

Filterreferenz: wpforms_authorize_net_process_payment_single_args

Tutorialreferenz: