代码之家  ›  专栏  ›  技术社区  ›  R P

如何在仅授权继续交易类型中设置订单发票编号和说明?

  •  2
  • R P  · 技术社区  · 8 年前

    如何使用AuthorizeNet中交易类型为“authOnlyContinueTransaction”或“authCaptureContinueTransaction”的Paypal express签出更新发票编号和说明。需要在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”或“AuthCaptureTransation”,可以更新发票编号和描述。

    如何使用事务类型“authOnlyContinueTransaction”或“authCaptureContinueTransaction”更新相同的内容?

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

    1 回复  |  直到 8 年前
        1
  •  1
  •   Rajesh    8 年前

    你似乎误解了流程。你不能通过 顺序 中的对象 authOnlyContinueTransaction authCaptureContinueTransaction 。流程是这样的。

    1. 创建事务并获取引用id
    2. 按上述方式传递引用id进行确认

    或者,更好地使用 createTransactionRequest 这将允许您设置顺序。