php - 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
)
任何人都知道如何解决此错误。
解决方案
您已从参数中删除了“cnon:”。“CBASECw9ri-7s1THlCWDoSVsVY8”应该是cnon:CBASECw9ri-7s1THlCWDoSVsVY8
.
推荐阅读
- java - Android ReCaptcha:在我的 Activity 中实例化(同步!)Executor 对象是否会导致其线程(和 UI)崩溃?
- r - 将 na.rm 添加到具有多个参数的函数
- rest - 在运行时放心的 API 编排
- vb.net - 发送带有超链接的项目列表 ASP.net VB
- python - 使用 apache-tika 和 python 从 PDF 中提取内联图像
- spring-boot - 使用 kafka 作为生产者和消费者端之间的中间件的消费者端应用程序中未收到标头
- sql - 基于列值重复显示列的 SQL 查询
- sql - 使用 sqldeveloper 转至 csv 时没有输出
- html - 我的列只有在我给出行类时才有效
- python - sklearn.impute SimpleImputer:为什么 transform() 首先需要 fit_transform()?