douyi1899 2019-06-04 11:49
浏览 99

重定向页面仅显示订单摘要(authorize.net接受的主机)

I am using the php sdk provided by authorize.net. The particular method is the accepted host method using a redirected page. 1) The token is returned with I00001 Successful message 2) The page does not display anything but order summary at the top. 3) I also get the error below in the Chrome console.

I have been fighting this for over 2 weeks to no avail, any help you all can give me would be greatly appreciated. Jim

ERROR MESSAGE IN CHROME CONSOLE:

payment:24 Uncaught SyntaxError: Invalid or unexpected token

CODE USED:

function sdk_test()
 {
     //-----------------------------------------------------------
     //Create a merchantAuthenticationType object with authentication details
     //retrieved from the constants file
     //-----------------------------------------------------------
    $merchantAuthentication = new 
 AnetAPI\MerchantAuthenticationType();
    //$merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
    $merchantAuthentication->setName($this->anobj->get_field('login'));
    //$merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
    $merchantAuthentication->setTransactionKey($this->anobj->get_field('x_trans_key'));

    //-----------------------------------------------------------
    // Set the transaction's refId
    //-----------------------------------------------------------
    $refId = 'ref' . time();
    //-----------------------------------------------------------
    // Create the payment data for a credit card
    //-----------------------------------------------------------
    $creditCard = new AnetAPI\CreditCardType();
    $creditCard->setCardNumber("4111111111111111");
    $creditCard->setExpirationDate("2038-12");
    $creditCard->setCardCode("123");
    //-----------------------------------------------------------
    // Add the payment data to a paymentType object
    //-----------------------------------------------------------
    $paymentOne = new AnetAPI\PaymentType();
    $paymentOne->setCreditCard($creditCard);
    //-----------------------------------------------------------
    // Create order information
    //-----------------------------------------------------------
    $order = new AnetAPI\OrderType();
    $order->setInvoiceNumber("10101");
    $order->setDescription("Golf Shirts");
  //-----------------------------------------------------------
    // Set the customer's Bill To address
    //-----------------------------------------------------------
    $customerAddress = new AnetAPI\CustomerAddressType();
    $customerAddress->setFirstName("Ellen");
    $customerAddress->setLastName("Johnson");
    $customerAddress->setCompany("Souveniropolis");
    $customerAddress->setAddress("14 Main Street");
    $customerAddress->setCity("Pecan Springs");
    $customerAddress->setState("TX");
    $customerAddress->setZip("44628");
    $customerAddress->setCountry("USA");
    //-----------------------------------------------------------
    // Set the customer's identifying information
    //-----------------------------------------------------------
    $customerData = new AnetAPI\CustomerDataType();
    $customerData->setType("individual");
    $customerData->setId("99999456654");
    $customerData->setEmail("EllenJohnson@example.com");
    //-----------------------------------------------------------
    // Add values for transaction settings
    //-----------------------------------------------------------
    $duplicateWindowSetting = new AnetAPI\SettingType();
    $duplicateWindowSetting->setSettingName("duplicateWindow");
    $duplicateWindowSetting->setSettingValue("60");
    //-----------------------------------------------------------
    // Add some merchant defined fields. These fields won't be
    // stored with the transaction,but will be echoed back in the response.
    //-----------------------------------------------------------
    $merchantDefinedField1 = new AnetAPI\UserFieldType();
    $merchantDefinedField1->setName("customerLoyaltyNum");
    $merchantDefinedField1->setValue("1128836273");
    $merchantDefinedField2 = new AnetAPI\UserFieldType();
    $merchantDefinedField2->setName("favoriteColor");
    $merchantDefinedField2->setValue("blue");
    //-----------------------------------------------------------
    // Create a TransactionRequestType object and add the previous objects to it
    //-----------------------------------------------------------
    $transactionRequestType = new AnetAPI\TransactionRequestType();
    $transactionRequestType->setTransactionType("authOnlyTransaction");
    $transactionRequestType->setAmount($amount);
    $transactionRequestType->setOrder($order);
    $transactionRequestType->setPayment($paymentOne);
    $transactionRequestType->setBillTo($customerAddress);
    $transactionRequestType->setCustomer($customerData);
    $transactionRequestType->addToTransactionSettings($duplicateWindowSetting);
  $transactionRequestType->addToUserFields($merchantDefinedField1);
    $transactionRequestType->addToUserFields($merchantDefinedField2);
    //-----------------------------------------------------------
    // Assemble the complete transaction request
    //-----------------------------------------------------------
    $request = new AnetAPI\CreateTransactionRequest();
    $request->setMerchantAuthentication($merchantAuthentication);
    $request->setRefId($refId);
    $request->setTransactionRequest($transactionRequestType);
    //-----------------------------------------------------------
    // Create the controller and get the response
    //-----------------------------------------------------------
    $controller = new AnetController\CreateTransactionController($request);
    $response = $controller->executeWithApiResponse(
et\authorize\api\constants\ANetEnvironment::SANDBOX);
    if ($response != null)
    {
        // Check to see if the API request was successfully received and acted upon
        if ($response->getMessages()->getResultCode() == "Ok")
        {
            // Since the API request was successful, look for a transaction response
            // and parse it to display the results of authorizing the card
            $tresponse = $response->getTransactionResponse();

            if ($tresponse != null && $tresponse->getMessages() != null)
            {
                echo " Successfully created transaction with Transaction ID: " .
                    $tresponse->getTransId() . "
";
                echo " Transaction Response Code: " . $tresponse->getResponseCode() . "
";
                echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "
";
                echo " Auth Code: " . $tresponse->getAuthCode() . "
";
                echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "
";
            }
            else
            {
                echo "Transaction Failed 
";
                if ($tresponse->getErrors() != null)
                {
                    echo " Error Code  : " .
                        $tresponse->getErrors()[0]->getErrorCode() . "
";
                    echo " Error Message : " .
                        $tresponse->getErrors()[0]->getErrorText() . "
";
                }
            }
   }
        else
        {
            echo "Transaction Failed 
";
            $tresponse = $response->getTransactionResponse();

            if ($tresponse != null && $tresponse->getErrors() != null)
            {
                echo " Error Code  : " .
                    $tresponse->getErrors()[0]->getErrorCode() . "
";
                echo " Error Message : " .
                    $tresponse->getErrors()[0]->getErrorText() . "
";
            }
            else
            {
                echo " Error Code  : " .
                    $response->getMessages()->getMessage()[0]->getCode() . "
";
                echo " Error Message : " .
                    $response->getMessages()->getMessage()[0]->getText() . "
";
            }
        }
    }
    else
    {
        echo  "No response returned 
";
    }
    return $response;
 }

RETURNED PAGE SOURCE:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">

<head id="Head1"><title>
    Secure Information
</title>
          <!-- Google Tag Manager -->
            <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
            new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
            j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
            'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
            })(window,document,'script','dataLayer','GTM-KFWQGNC');</script>
          <!-- End Google Tag Manager -->
    <script src="https://sandbox-assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js" type="text/javascript" > </script>
    <script type="text/javascript">
          var g_token = "null";
          var g_merchantData = null;
          var g_pageOptions = null;
          var g_paymentProfiles = null;
          var g_maxPaymentProfiles = false;
          var g_errorPanelMessage = "The page has timed out. Please go back to the beginning and try again.";
            var g_siteKey = "6Lc8tgYAAAAAAFfalsuPuIZ6bv_2dGT_Y9ZxURiK";
            var g_visaCheckoutUrl = "https://sandbox.secure.checkout.visa.com/wallet-services-web/xo/button.png";
        </script>

<script type="text/javascript">
  var g_EcheckEnabled = false;
var g_CreditEnabled = false;
  </script>
  <base href="./Scripts/v1/">
</head>
<body>
  <div class="PageOuter" id="divPageOuter">
    <div id="divPopupScreen" class="PopupScreen" style="display:none;"></div>
      <div class="Page" id="divPage">
      <div class="PageMain container" id="divPageMain container">

          <!-- Google Tag Manager (noscript) -->
            <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KFWQGNC"
            height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
          <!-- End Google Tag Manager (noscript) -->
          <app-accept-payment></app-accept-payment>

          <link href="styles.bundle.css" rel="stylesheet"/>
          <script type="text/javascript" src="inline.bundle.js"></script>
          <script type="text/javascript" src="polyfills.bundle.js"></script>
          <script type="text/javascript" src="scripts.bundle.js"></script>
          <script type="text/javascript" src="main.bundle.js"></script>        

      </div>
      <div class="PageMainAfter"></div>
    </div>
  </div>
</body>
</html>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 树莓派与pix飞控通信
    • ¥15 自动转发微信群信息到另外一个微信群
    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题