Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Apple Pay-authorize.net仅在实时、沙盒工作时返回错误153_Php_Authorize.net_Applepay_Applepayjs - Fatal编程技术网

Php Apple Pay-authorize.net仅在实时、沙盒工作时返回错误153

Php Apple Pay-authorize.net仅在实时、沙盒工作时返回错误153,php,authorize.net,applepay,applepayjs,Php,Authorize.net,Applepay,Applepayjs,在搜索了很多文章后,我找不到解决问题的方法 我在我的网站上集成了ApplePay按钮,并成功地在沙箱模式下进行了交易。我正在使用authorize.NETPHPSDK生成请求。问题是从我开始生活的时候开始的。 来自authorize.net的消息是“处理支付数据时出错。解密数据中缺少必填字段。” 以下是我所做的: 已将付款处理证书更改为live authorize.net帐户中的证书 已将我用于处理授权.net付款的凭据更改为我获得付款处理证书的同一个live帐户 使用带有真实信用卡的实时app

在搜索了很多文章后,我找不到解决问题的方法

我在我的网站上集成了ApplePay按钮,并成功地在沙箱模式下进行了交易。我正在使用authorize.NETPHPSDK生成请求。问题是从我开始生活的时候开始的。 来自authorize.net的消息是“处理支付数据时出错。解密数据中缺少必填字段。”

以下是我所做的:

  • 已将付款处理证书更改为live authorize.net帐户中的证书
  • 已将我用于处理授权.net付款的凭据更改为我获得付款处理证书的同一个live帐户
  • 使用带有真实信用卡的实时apple设备
  • 我使用第一个数据纳什维尔处理器作为CC处理器,支持ApplePay
  • 请注意,如果我切换回沙箱模式,事务将顺利通过。

    请求和失败的响应如下所示:

    请求:

    { 
        "createTransactionRequest":{ 
            "merchantAuthentication":{ 
                "name":"xxxxxxxxx",
                "transactionKey":"xxxxxxxxxxx"
            },
            "clientId":"sdk-php-2.0.0",
            "refId":"ref1575669789",
            "transactionRequest":{ 
                "transactionType":"authOnlyTransaction",
                "amount":"14.08",
                "payment":{ 
                    "opaqueData":{ 
                        "dataDescriptor":"COMMON.APPLE.INAPP.PAYMENT",
                        "dataValue":"eyJ2ZXJzaW9u...Q1OSJ9fQ=="
                    }
                },
                "order":{ 
                    "invoiceNumber":"63059-191206",
                    "description":"xxxxxxxxx, xxxxxxxxxxxx v9.0.12 (Order# 63059-191206)"
                },
                "customer":{ 
                    "type":"individual",
                    "email":""
                },
                "billTo":{ 
                    "firstName":"xxxxxxx",
                    "lastName":"xxxxxxx",
                    "address":"xxxx San Remo Cir ",
                    "city":"Vista",
                    "state":"CA",
                    "zip":"92084",
                    "country":"US"
                },
                "retail":{ 
                    "marketType":0,
                    "deviceType":8
                },
                "transactionSettings":{ 
                    "setting":[ 
                        { 
                            "settingName":"duplicateWindow",
                            "settingValue":"60"
                        }
                    ]
                }
            }
        }
    }
    
    {
        "transactionResponse":{
            "responseCode":"3",
            "authCode":"",
            "avsResultCode":"P",
            "cvvResultCode":"",
            "cavvResultCode":"",
            "transId":"0",
            "refTransID":"",
            "transHash":"",
            "testRequest":"0",
            "accountNumber":"",
            "accountType":"",
            "errors":[
                {
                    "errorCode":"153",
                    "errorText":"There was an error processing the payment data. Required fields are missing from decrypted data."
                }
            ],
            "transHashSha2":"",
            "SupplementalDataQualificationIndicator":0
        },
        "refId":"ref1575669789",
        "messages":{
            "resultCode":"Error",
            "message":[
                {
                    "code":"E00027",
                    "text":"The transaction was unsuccessful."
                }
            ]
        }
    }
    
    响应:

    { 
        "createTransactionRequest":{ 
            "merchantAuthentication":{ 
                "name":"xxxxxxxxx",
                "transactionKey":"xxxxxxxxxxx"
            },
            "clientId":"sdk-php-2.0.0",
            "refId":"ref1575669789",
            "transactionRequest":{ 
                "transactionType":"authOnlyTransaction",
                "amount":"14.08",
                "payment":{ 
                    "opaqueData":{ 
                        "dataDescriptor":"COMMON.APPLE.INAPP.PAYMENT",
                        "dataValue":"eyJ2ZXJzaW9u...Q1OSJ9fQ=="
                    }
                },
                "order":{ 
                    "invoiceNumber":"63059-191206",
                    "description":"xxxxxxxxx, xxxxxxxxxxxx v9.0.12 (Order# 63059-191206)"
                },
                "customer":{ 
                    "type":"individual",
                    "email":""
                },
                "billTo":{ 
                    "firstName":"xxxxxxx",
                    "lastName":"xxxxxxx",
                    "address":"xxxx San Remo Cir ",
                    "city":"Vista",
                    "state":"CA",
                    "zip":"92084",
                    "country":"US"
                },
                "retail":{ 
                    "marketType":0,
                    "deviceType":8
                },
                "transactionSettings":{ 
                    "setting":[ 
                        { 
                            "settingName":"duplicateWindow",
                            "settingValue":"60"
                        }
                    ]
                }
            }
        }
    }
    
    {
        "transactionResponse":{
            "responseCode":"3",
            "authCode":"",
            "avsResultCode":"P",
            "cvvResultCode":"",
            "cavvResultCode":"",
            "transId":"0",
            "refTransID":"",
            "transHash":"",
            "testRequest":"0",
            "accountNumber":"",
            "accountType":"",
            "errors":[
                {
                    "errorCode":"153",
                    "errorText":"There was an error processing the payment data. Required fields are missing from decrypted data."
                }
            ],
            "transHashSha2":"",
            "SupplementalDataQualificationIndicator":0
        },
        "refId":"ref1575669789",
        "messages":{
            "resultCode":"Error",
            "message":[
                {
                    "code":"E00027",
                    "text":"The transaction was unsuccessful."
                }
            ]
        }
    }
    
    我错过了什么

    编辑:

    { 
        "createTransactionRequest":{ 
            "merchantAuthentication":{ 
                "name":"xxxxxxxxx",
                "transactionKey":"xxxxxxxxxxx"
            },
            "clientId":"sdk-php-2.0.0",
            "refId":"ref1575669789",
            "transactionRequest":{ 
                "transactionType":"authOnlyTransaction",
                "amount":"14.08",
                "payment":{ 
                    "opaqueData":{ 
                        "dataDescriptor":"COMMON.APPLE.INAPP.PAYMENT",
                        "dataValue":"eyJ2ZXJzaW9u...Q1OSJ9fQ=="
                    }
                },
                "order":{ 
                    "invoiceNumber":"63059-191206",
                    "description":"xxxxxxxxx, xxxxxxxxxxxx v9.0.12 (Order# 63059-191206)"
                },
                "customer":{ 
                    "type":"individual",
                    "email":""
                },
                "billTo":{ 
                    "firstName":"xxxxxxx",
                    "lastName":"xxxxxxx",
                    "address":"xxxx San Remo Cir ",
                    "city":"Vista",
                    "state":"CA",
                    "zip":"92084",
                    "country":"US"
                },
                "retail":{ 
                    "marketType":0,
                    "deviceType":8
                },
                "transactionSettings":{ 
                    "setting":[ 
                        { 
                            "settingName":"duplicateWindow",
                            "settingValue":"60"
                        }
                    ]
                }
            }
        }
    }
    
    {
        "transactionResponse":{
            "responseCode":"3",
            "authCode":"",
            "avsResultCode":"P",
            "cvvResultCode":"",
            "cavvResultCode":"",
            "transId":"0",
            "refTransID":"",
            "transHash":"",
            "testRequest":"0",
            "accountNumber":"",
            "accountType":"",
            "errors":[
                {
                    "errorCode":"153",
                    "errorText":"There was an error processing the payment data. Required fields are missing from decrypted data."
                }
            ],
            "transHashSha2":"",
            "SupplementalDataQualificationIndicator":0
        },
        "refId":"ref1575669789",
        "messages":{
            "resultCode":"Error",
            "message":[
                {
                    "code":"E00027",
                    "text":"The transaction was unsuccessful."
                }
            ]
        }
    }
    
    以下是有关从ApplePay发送不透明数据的代码

    $transactionMode = $cc_authorize_mode == $this->MODE_TEST ? \net\authorize\api\constants\ANetEnvironment::SANDBOX : \net\authorize\api\constants\ANetEnvironment::PRODUCTION;
    $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
    $merchantAuthentication->setName($cc_authorize_loginid);
    $merchantAuthentication->setTransactionKey($cc_authorize_txnkey);
    
    // Set the transaction's refId
    $refId = 'ref' . time();
    $phoneNumber = ! empty($co_b_phone) ? $co_b_phone : $co_phone;
    $customerEmail = ! empty($co_b_email) ? $co_b_email : $co_email;
    $ip = lloader()->getUtilByName('ip')->getClientIp();
    
    // Create order information
    $order = new AnetAPI\OrderType();
    $order->setInvoiceNumber($order_number);
    $order->setDescription($this->getOrderPostedByMessage($id_order, $order_number));
    
    // Set the customer's Bill To address
    $customerAddress = new AnetAPI\CustomerAddressType();
    $customerAddress->setFirstName($co_ccholder_firstname);
    $customerAddress->setLastName($co_ccholder_lastname);
    if (! empty($co_b_company)) { $customerAddress->setCompany($co_b_company); }
    $customerAddress->setAddress($co_b_address." ".$co_b_address2);
    $customerAddress->setCity($co_b_city);
    $bState = f_isUSState($co_b_state) ? $STATES_XX[$co_b_state] : $STATES[$co_b_state];
    $customerAddress->setState($bState);
    $customerAddress->setZip($co_b_zip);
    $customerAddress->setCountry($countriesISO2[$co_country]);
    $customerAddress->setPhoneNumber($phoneNumber);
    $customerAddress->setEmail($customerEmail);
    
    // Set the customer's identifying information
    $customerData = new AnetAPI\CustomerDataType();
    $customerData->setType("individual");
    if ( ! empty($member_row['id'])) { $customerData->setId($member_row['id']); }
    $customerData->setEmail($customerEmail);
    
    
    // Add values for transaction settings
    $duplicateWindowSetting = new AnetAPI\SettingType();
    $duplicateWindowSetting->setSettingName("duplicateWindow");
    $duplicateWindowSetting->setSettingValue("60");
    
    // Create a TransactionRequestType object and add the previous objects to it
    $transactionRequestType = new AnetAPI\TransactionRequestType();
    $transactionRequestType->setCustomerIP($ip);
    $transactionRequestType->setTransactionType($this->api_trtype_map[$transactionType]);
    if (empty($this->applePayPaymentData)) {
                // Normal CC request
                // Create the payment data for a credit card
                ...
    } else {
        $retail = new AnetAPI\TransRetailInfoType();
        $retail->setMarketType('0');
        $retail->setDeviceType('8');
        $transactionRequestType->setRetail($retail);
    
        // Apple Pay Token Request
        $op = new AnetAPI\OpaqueDataType();
        $op->setDataDescriptor("COMMON.APPLE.INAPP.PAYMENT");
        $paymentToken = base64_encode($this->applePayPaymentData);
        $op->setDataValue($paymentToken);
        $payment = new AnetAPI\PaymentType();
        $payment->setOpaqueData($op);
    }
    
    $transactionRequestType->setAmount($grandTotal);
    $transactionRequestType->setOrder($order);
    $transactionRequestType->setPayment($payment);
    $transactionRequestType->setBillTo($customerAddress);
    $transactionRequestType->setCustomer($customerData);
    $transactionRequestType->addToTransactionSettings($duplicateWindowSetting);
    
    // 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($transactionMode);
    if ($response != null) {
        if ($response->getMessages()->getResultCode() == "Ok") {
           ...
           if ($tresponse != null && $tresponse->getMessages() != null) {
              ...
              return true;
           } else {
              if ($tresponse->getErrors() != null) {
                 ...
              }
           }
            ...
        }
        ...
    }
    
    EDIT2:

    { 
        "createTransactionRequest":{ 
            "merchantAuthentication":{ 
                "name":"xxxxxxxxx",
                "transactionKey":"xxxxxxxxxxx"
            },
            "clientId":"sdk-php-2.0.0",
            "refId":"ref1575669789",
            "transactionRequest":{ 
                "transactionType":"authOnlyTransaction",
                "amount":"14.08",
                "payment":{ 
                    "opaqueData":{ 
                        "dataDescriptor":"COMMON.APPLE.INAPP.PAYMENT",
                        "dataValue":"eyJ2ZXJzaW9u...Q1OSJ9fQ=="
                    }
                },
                "order":{ 
                    "invoiceNumber":"63059-191206",
                    "description":"xxxxxxxxx, xxxxxxxxxxxx v9.0.12 (Order# 63059-191206)"
                },
                "customer":{ 
                    "type":"individual",
                    "email":""
                },
                "billTo":{ 
                    "firstName":"xxxxxxx",
                    "lastName":"xxxxxxx",
                    "address":"xxxx San Remo Cir ",
                    "city":"Vista",
                    "state":"CA",
                    "zip":"92084",
                    "country":"US"
                },
                "retail":{ 
                    "marketType":0,
                    "deviceType":8
                },
                "transactionSettings":{ 
                    "setting":[ 
                        { 
                            "settingName":"duplicateWindow",
                            "settingValue":"60"
                        }
                    ]
                }
            }
        }
    }
    
    {
        "transactionResponse":{
            "responseCode":"3",
            "authCode":"",
            "avsResultCode":"P",
            "cvvResultCode":"",
            "cavvResultCode":"",
            "transId":"0",
            "refTransID":"",
            "transHash":"",
            "testRequest":"0",
            "accountNumber":"",
            "accountType":"",
            "errors":[
                {
                    "errorCode":"153",
                    "errorText":"There was an error processing the payment data. Required fields are missing from decrypted data."
                }
            ],
            "transHashSha2":"",
            "SupplementalDataQualificationIndicator":0
        },
        "refId":"ref1575669789",
        "messages":{
            "resultCode":"Error",
            "message":[
                {
                    "code":"E00027",
                    "text":"The transaction was unsuccessful."
                }
            ]
        }
    }
    
    我在请求中添加了电子邮件、电话和ip地址,结果相同。修改后的请求如下:

    { 
    "createTransactionRequest":{ 
        "merchantAuthentication":{ 
            "name":"**********",
            "transactionKey":"***************"
        },
        "clientId":"sdk-php-2.0.0",
        "refId":"ref1576180306",
        "transactionRequest":{ 
            "transactionType":"authOnlyTransaction",
            "amount":"14.08",
            "payment":{ 
                "opaqueData":{ 
                    "dataDescriptor":"COMMON.APPLE.INAPP.PAYMENT",
                    "dataValue":"eyJ2ZXJzaW9uIj...DFiZiJ9fQ=="
                }
            },
            "order":{ 
                "invoiceNumber":"63117-191212",
                "description":"******************* v9.0.12 (Order# 63117-191212)"
            },
            "customer":{ 
                "type":"individual",
                "email":"*********@gmail.com"
            },
            "billTo":{ 
                "firstName":"Gabe",
                "lastName":"Garcia",
                "address":"********* Cir ",
                "city":"Vista",
                "state":"CA",
                "zip":"92084",
                "country":"US",
                "phoneNumber":"**************",
                "email":"**********@gmail.com"
            },
            "customerIP":"************",
            "retail":{ 
                "marketType":"0",
                "deviceType":"8"
            },
            "transactionSettings":{ 
                "setting":[ 
                    { 
                        "settingName":"duplicateWindow",
                        "settingValue":"60"
                    }
                ]
            }
        }
    }
    
    }

    如前所述

    有几件事需要注意:

    • 您在我们网站上输入的苹果商户ID必须与您在苹果网站上创建的相同。如果是 不同的是,我们将无法解密支付数据
    • 必须是电子商务交易。确认您的网关帐户已设置为无卡帐户
    • 提交的数据必须是base64编码的。据我所知,你做得对,但要仔细检查。我不知道这个斑点是否 你回来的时候已经用base64编码了,但可能要再检查一遍 以确保您没有对其进行双重编码
    • opaqueData字段不应仅为
      token.paymentData.data
      。相反,它应该是一个
      Base64编码的
      JSON字符串,表示整个
      token.paymentData对象
    处理付款数据时出错

    • 必须同时指定两个不透明参数
    • 您不能包括卡号或到期日期
    • 不能包含轨迹数据
    • 必须是电子商务交易。确认您的网关帐户是 设置为卡不存在帐户
    • 交易必须是授权或授权和捕获类型 交易记录
    • 不能包含3DS数据
    • 您必须提交可以成功解密的数据
    • 解密数据必须属于提交请求的商户
    • 提交的数据必须是base64编码的

      • 这很可能是由于来自ApplePay端的OpaqueData字段中的数据问题造成的。因此,我的建议是在日志文件中打印该令牌,然后使用以下库之一对其进行解密,以手动检查是否存在所有数据。 您可以对沙盒环境和活动环境执行相同的操作。因此,您将看到令牌数据中的任何差异


        这就是它使用库的方式。

        您需要一份“支付处理证书”和一份来自苹果的私钥(以下称为merch.cer和priv.p12)。你可以在苹果的开发中心生成这些。您还需要在最终用户设备上生成一个示例支付令牌,以及生成该令牌的时间戳。RSA加密令牌应如下所示:

        {
        “数据”:“,
        “标题”:{
        “应用程序数据”:”
        “wrappedKey”:“,
        “publicKeyHash”:“,
        “transactionId”:”
        },
        “签字”:“,
        “版本”:“RSA_v1”
        }
        
        演示

        $ # Copy in your payment processing cert and test token
        $ cd examples
        $ cp /secret/place/merch.cer .
        $ cp /secret/place/token.json .
        $
        $ # Extract private key from cert
        $ openssl pkcs12 -export -nocerts -inkey merch.key -out priv.p12 -password 'pass:'
        $
        $ # Get intermediate and root certs from Apple
        $ wget -O int.cer 'https://www.apple.com/certificateauthority/AppleAAICAG3.cer'
        $ wget -O root.cer 'https://www.apple.com/certificateauthority/AppleRootCA-G3.cer'
        $
        $ # Verify chain of trust
        $ openssl x509 -inform DER -in merch.cer -pubkey > pub.pem
        $ openssl x509 -inform DER -in root.cer > root.pem
        $ openssl x509 -inform DER -in int.cer > int_merch.pem
        $ openssl x509 -inform DER -in merch.cer >> int_merch.pem
        $ openssl verify -verbose -CAfile root.pem int_merch.pem # should output OK
        $
        $ # Run demo
        $ cd ..
        $ php -denable_dl=on -dextension=`pwd`/modules/applepay.so examples/decrypt.php -p <privkey_pass> -c examples/token.json -t <time_of_transaction>
        
        $#复制您的支付处理证书和测试令牌
        $cd示例
        $cp/secret/place/merch.cer。
        $cp/secret/place/token.json。
        $
        $#从证书中提取私钥
        $openssl pkcs12-导出-nocerts-inkey merch.key-out priv.p12-密码“pass:”
        $
        $#从Apple获得中间和根证书
        $wget-O int.cer'https://www.apple.com/certificateauthority/AppleAAICAG3.cer'
        $wget-O root.cer'https://www.apple.com/certificateauthority/AppleRootCA-G3.cer'
        $
        $#验证信任链
        $openssl x509-通知DER-在merch.cer-pubkey>pub.pem中
        $openssl x509-通知DER-在root.cer>root.pem中
        $openssl x509-通知DER-in int.cer>int_merch.pem
        $openssl x509-通知DER-在merch.cer>>int_merch.pem中
        $openssl verify-verbose-CAfile root.pem int_merch.pem#应输出正常
        $
        $#运行演示
        $cd。。
        $php-denable_dl=on-dextension=`pwd`/modules/applepay.so examples/decrypt.php-p-c examples/token.json-t
        
        尝试重新生成证书?是的,我多次重新生成支付处理证书,甚至在apple帐户中重新创建了商户身份。transactionRequest->customer->email为空,可能需要设置,是否可以在请求时设置?能否发布与设置“opaqueData”字段相关的代码?它应该是从ApplePay钱包收到的base64编码令牌。@Roadowl发生了什么事。我编辑了这篇文章。注意,相同的代码在沙箱模式下工作。此外,还会生成请求,并且可以看到。我认为这与它的生成方式没有多大关系。谢谢你的建议。所有这些都适用。我不确定您是否注意到所有事务在沙盒模式下都会通过。我制作了全新的商户id,并将其用于相同结果的交易。然后我在沙盒上尝试了相同的id,事务正在通过。@bksi我已经更新了答案。请确保您已经完成了所有检查表,并且仍然面临问题,然后尝试从c重新执行整个过程