首页 > 解决方案 > Square up php create card using php sdk api-card nonce error

问题描述

我试图解决这个问题,但无法这样做。尽管最近创建了字段“card_nonce”,但在服务器上找不到它。我使用 npm 和 node 来生成 card_nonce。

使用的代码:

$billing_address = new Address();
$billing_address->setAddressLine1('500 Electric Ave');
$billing_address->setAddressLine2('Suite 600');
$billing_address->setLocality('New York');
$billing_address->setAdministrativeDistrictLevel1('NY');
$billing_address->setPostalCode('10003');
$billing_address->setCountry('AU');

// $body = new CreateCustomerCardRequest($_POST['nonce']);
$body = new CreateCustomerCardRequest('CBASECw9ri-7s1THlCWDoSVsVY8');
$body->setBillingAddress($billing_address);
$body->setCardholderName('Gaurav Gulati');

$api_response = $customersApi->createCustomerCard($customer_id, $body);

if ($api_response->isSuccess()) {
$result = $api_response->getResult();
$customer_card = $api_response->getCard();
$customer_card_id = $customer_card->getId();
    
} else {
    $errors = $api_response->getErrors();
}

回复:

[0] => Square\Models\Error Object
(
 [category:Square\Models\Error:private] => INVALID_REQUEST_ERROR
 [code:Square\Models\Error:private] => NOT_FOUND
 [detail:Square\Models\Error:private] => Resource not found.
 [field:Square\Models\Error:private] => card_nonce
)

任何人都知道如何解决此错误。

标签: phpsquare

解决方案


您已从参数中删除了“cnon:”。“CBASECw9ri-7s1THlCWDoSVsVY8”应该是cnon:CBASECw9ri-7s1THlCWDoSVsVY8.


推荐阅读