如何在 auth Only Continue Transaction 类型中设置订单发票编号和描述?

How to set order invoice number and description in auth Only Continue Transaction type?

如何使用 AuthorizeNet 中的 Paypal 快速结帐更新发票编号和说明,交易类型为 "authOnlyContinueTransaction" 或 "authCaptureContinueTransaction"。需要在 PHP.

中完成

我尝试了下面的代码:

$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
    $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
    $merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);

    // Set the transaction's refId
    $refId = 'ref' . time();

    // Set PayPal compatible merchant credentials
    $paypal_type = new AnetAPI\PayPalType();
    $paypal_type->setPayerID($payerId);

    $paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
    $paypal_type->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");

    $payment_type = new AnetAPI\PaymentType();
    $payment_type->setPayPal($paypal_type);

    // Order info
    $order = new AnetAPI\OrderType();
    $order->setInvoiceNumber("101");
    $order->setDescription("Shirts");

    //create a transaction
    $transactionRequestType = new AnetAPI\TransactionRequestType();
    $transactionRequestType->setTransactionType("authOnlyContinueTransaction");
    $transactionRequestType->setRefTransId($transactionId);
    $transactionRequestType->setAmount(4.34);
    $transactionRequestType->setPayment($payment_type);
    $transactionRequestType->setOrder($order);

    $request = new AnetAPI\CreateTransactionRequest();
    $request->setMerchantAuthentication($merchantAuthentication);
    $request->setRefId($refId);
    $request->setTransactionRequest($transactionRequestType);

    $controller = new AnetController\CreateTransactionController($request);

    $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);

    if ($response != null) {
        if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) {
            $tresponse = $response->getTransactionResponse();

            if ($tresponse != null && $tresponse->getMessages() != null) {
                echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n";
                echo "TRANS ID  : " . $tresponse->getTransId() . "\n";
                echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID();
                echo "Description : " . $tresponse->getMessages()[0]->getDescription() . "\n";
            } else {
                echo "Transaction Failed \n";
                if ($tresponse->getErrors() != null) {
                    echo " Error code  : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
                    echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
                }
            }
        } else {
            echo "Transaction Failed \n";
            $tresponse = $response->getTransactionResponse();
            if ($tresponse != null && $tresponse->getErrors() != null) {
                echo " Error code  : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
                echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
            } else {
                echo " Error code  : " . $response->getMessages()->getMessage()[0]->getCode() . "\n";
                echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n";
            }
        }
    } else {
        echo  "No response returned \n";
    }

无法更改发票编号和订单描述。 早些时候,交易类型 "authOnlyTransaction" 或 "authCaptureTransaction" 能够更新发票编号和描述。

如何更新交易类型为"authOnlyContinueTransaction"或"authCaptureContinueTransaction"?

我从 https://developer.authorize.net/api/reference/index.html#PayPal-express-checkout

你好像对流程有误解。您不能在 authOnlyContinueTransactionauthCaptureContinueTransaction 中传递 order 对象。流程是这样的

  1. 创建交易并获取参考 ID
  2. 通过上述方法中引用的id进行确认

或者,最好使用 createTransactionRequest 来设置顺序。