簡體   English   中英

預期要設置的信用卡ID Braintree錯誤

[英]Expected credit card id to be set braintree error

我正在為通過Braintree更新信用卡的表單做后端代碼。 我確定所有值在JSON中都是正確的。 但是,當我使用ajax轉到后端頁面時,響應中出現以下錯誤:

致命錯誤:/var/www/html/braiden/braintree/lib/Braintree/CreditCardGateway.php:431中未捕獲的異常“ InvalidArgumentException”,消息為“將設置預期的信用卡ID”
堆棧跟蹤:
#0 /var/www/html/braiden/braintree/lib/Braintree/CreditCardGateway.php(152):Braintree \\ CreditCardGateway-> _ validateId(NULL)
#1 /var/www/html/braiden/braintree/updateCreditCardBackend.php(18):Braintree \\ CreditCardGateway-> find(NULL)
#2 {main}在第431行的/var/www/html/braiden/braintree/lib/Braintree/CreditCardGateway.php中拋出

這是代碼的副本,這里的任何幫助都會很棒。 首先給我提供后端頁面的json: {名稱:“雞”,卡號:“ 4111111111111111”,Cvv:“ 747”,月:“ 12”,年:“ 22”}

繼承人代碼

<?php  require_once 'lib/Braintree.php';
$requestBody = file_get_contents('php://input');
$requestJSON = json_decode($requestBody);
$name = $requestJSON->Name;
$cvv = $requestJSON->Cvv;
$cardNumber = $requestJSON->cardNumber;
$year =  $requestJSON->Year;
$month = $requestJSON->Month;
$token = $requestJSON->Token;

  $gateway = new Braintree_Gateway([
    'environment' => 'sandbox',
    'merchantId' => '********',
    'publicKey' => '********',
    'privateKey' => '********'
  ]);
$creditCard = $gateway->creditCard()->find($token);
$result = $gateway->creditCard()->update($creditCard->token, [
    'cardholderName' => $name,
    'cvv' => $cvv,
    'number' => $cardNumber,
    'expirationMonth' => $month,
    'expirationYear' => $year
]);
?>

我不得不將json中的名稱從Token更改為tok,它的工作顯然是保留的。 像這樣{[“ tok”:“ this.token”]}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM