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

标签 php paypal paypal-sandbox authorize.net

如何在 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

关于php - 如何在 auth Only Continue Transaction 类型中设置订单发票编号和描述?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49128448/

相关文章:

php - include_once函数是否创建了http请求

java - Paypal 沙盒 API : javax.net.ssl.SSLHandshakeException:收到致命警报:handshake_failure

javascript - Chartjs - 未捕获的引用错误图表未定义 Laravel 5.8

paypal - 如何使用 PayPal 的 merchant-sdk-java 减少计费周期的耗用时间?

Paypal DoDirectPayment 请求返回 NULL

Paypal 沙盒订阅 PAYER_CANNOT_PAY

php - PayPal SANDBOX 是否为您返回生产网址?

php - paypal IPN突然失效(无HTTP响应)

php - 如何对同一搜索模型同时使用 condition() 和 addcondition()

php - 针对 PHP 中给定 DTD 的 XML 验证