using the SDK as written (all in sandbox - still) obtaining all details i need from the customer i then call on the square/index.php to create the card input along with the total$$. It calls the process_payment.php and the charge for the correct amount is successful. HOWEVER, from there I can’t continue program flow. It dies after it reports ‘successful’.
I hope this is easy for you guys (anyone) but I’ve tried adding code to the end of the process_payment.php and even to the end of square/index.php …nothing. Not even displaying of vars in either works…just weird
Please tell me how or where you guys add code for the process to continue after ‘Payment Successful!’
thx
After the payment are you looking have the customer navigate to a new page on your site? If so you can modify the response of a successful payment to do whatever the next step is in your flow.
no, after the payment is successful I need to then continue by creating emails, receipts and orders. There is no place that works for continuing code. it remains dead. I have your older version working great. It’s the transition to this version that is killing me
What you’re saying is logical and it works on the older version. I have no idea why nothing works here. Not even an echo “hello”; works
here’s the response code. Please demonstrate where I add code to continue. I’ve tried already and nothing so far works
try {
// Every payment you process with the SDK must have a unique idempotency key.
// If you’re unsure whether a particular payment succeeded, you can reattempt
// it with the same idempotency key without worrying about double charging
// the buyer.
$create_payment_request = new CreatePaymentRequest($token, Uuid::uuid4(), $money);
$response = $payments_api->createPayment($create_payment_request);
if ($response->isSuccess()) {
echo json_encode($response->getResult());
} else {
echo json_encode(array(‘errors’ => $response->getErrors()));
}
} catch (ApiException $e) {
echo json_encode(array(‘errors’ => $e));
}
I’ve added code after and in between - nothing works
So I’ll guess you haven’t been able to make it work either? The answer you gave is how the old version worked but not the new version. The square code actually prohibits anything from working after the response is provided. It’s written that way. So how do we proceed after the response is provided?
Let me be more specific so the answer isn’t so nebulous
Show me the code to advance the process after the ‘payment successful’ response to open ‘thank_you.php’
please provide all the code and files necessary to edit and make this work. Your answer above does not work
In the example it’s designed to wait for the response and prints out the results. If you’d like to change the behavior you’ll need to change the JS in the POST to the payment request.
hey Bryan
your first answer was to change it in the PHP file was logical and I was trying it but it didn’t work. However, this response to change it in the js file does work - thank you
I’ll no doubt have another question as I’m not good with js. My stuff is mostly php so here goes…
As my php acquires details of the order, items etc I load a $_Session(array) var with all the details to hopefully survive the square CC process (works in the old version just fine). I’ll need to add to the $_Session(array) details I think will be only available in the ‘sq-payment-flow.js’ file (not sure yet). I’ll need details like the CC make, last-4, Transaction #, and amount (I know what we put in but I like to confirm that what’s been charged). Can js add to the $_Session or is there a way I can include these values when I regain control with the ‘thank-you.php’ ? Again I’m not good with js (I don’t like revealing code to the user)
Appreciate your help. I look forward to your response - thx
Yes, that’s correct. That was my mistake.
In the payment response you’ll see card_details
which has a card that contains the data you’ll need. The payment response is a JSON response that is the data in the POST to the payment request.