I am working on Square payment gateway and I created three steps creating a customer, creating a card, and then making a payment.
$create_customer_request = new SquareModelsCreateCustomerRequest();
$address = new SquareModelsAddress();
$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();
creating a card request
$body_card = new SquareModelsCreateCustomerCardRequest($_POST['nonce']);
$card_api_response = $client->getCustomersApi()->createCustomerCard($_SESSION['temp_customer_id'], $body_card);
making a payment
$payments_api = $client->getPaymentsApi();
$money->setAmount(10);
$money->setCurrency('USD');
$pay_body = new SquareModelsCreatePaymentRequest($_POST['nonce'],uniqid(),$money);
$pay_body->setCustomerId($_SESSION['temp_customer_id']);
$response = $client->getPaymentsApi()->createPayment($pay_body);
The issue I am having right now, I need to make two requests with the Nonce token but the system doesn't allow me to do it for the Square payment gateway. Don't know what to do now, Any kind of help will be appreciated. Pardon me for any mistakes here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…