[英]Create two nonce in one transaction for Square payment gateway
我正在研究 Square 支付网关,我创建了三个步骤,创建客户、创建卡,然后进行支付。
$create_customer_request = new \Square\Models\CreateCustomerRequest();
$address = new \Square\Models\Address();
$address->setAddressLine1($ship_address);
$address->setPostalCode($_POST['ship_postcode']);
$address->setCountry('US');
$create_customer_request->setGivenName($_POST['f_name']);
$create_customer_request->setFamilyName($_POST['f_name']);
$create_customer_request->setEmailAddress($_POST['email']);
$create_customer_request->setAddress($address);
$create_customer_request->setPhoneNumber($_POST['phone']);
$create_customer_request->setReferenceId($_POST['f_name']."-customer-".rand(10,15));
$create_customer_request->setNote('A customer');
$custcreateapiResponse = $client->getCustomersApi() >createCustomer($create_customer_request);
$custcreateapiResponse->isSuccess();
$_SESSION['temp_customer_id'] = $cust_res->getCustomer()->getId();
创建卡请求
$body_card = new \Square\Models\CreateCustomerCardRequest($_POST['nonce']);
$card_api_response = $client->getCustomersApi()->createCustomerCard($_SESSION['temp_customer_id'], $body_card);
付款
$payments_api = $client->getPaymentsApi();
$money->setAmount(10);
$money->setCurrency('USD');
$pay_body = new \Square\Models\CreatePaymentRequest($_POST['nonce'],uniqid(),$money);
$pay_body->setCustomerId($_SESSION['temp_customer_id']);
$response = $client->getPaymentsApi()->createPayment($pay_body);
我现在遇到的问题是,我需要使用 Nonce 令牌发出两个请求,但系统不允许我为 Square 支付网关执行此操作。 不知道现在该怎么办,任何形式的帮助将不胜感激。 请原谅我在这里的任何错误。
我尝试了互联网上的许多解决方案,但没有一个对我有用,所以我自己尝试逻辑。 我知道这不是一个好方法,但是,它对我有用
在付款表单中,我创建了另一个隐藏字段
<input type="hidden" id="card-nonce-1" name="nonce1">
在 sq-payment-form.js 中创建一个新的 function
function onGetCardNoncesecond(event) {
event.preventDefault();
paymentForm.requestCardNonce();
}
并将值放在隐藏字段中并提交并使用它。 任何建议将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.