I'm trying to create a new payment using sales channel api using this tutorial: https://help.shopify.com/en/api/reference/sales-channels/payment
but I'm getting 404 error.
First of all I created a checkout using this: https://help.shopify.com/en/api/reference/sales-channels/checkout?api[version]=2019-10#create-2019-1... and got the checkout ID.
Then I stored the credit card in the vault and got the session ID using this: https://help.shopify.com/en/api/reference/sales-channels/payment#create_payment_session-2019-10
Then using the checkout ID and session ID i'm trying to create the payment but I'm getting the 404 response. I'm trying from the localhost. Please let me know if the payment work if I try from my localhost.
This is the code I tried:
$url2 = "https://57a5e13___________:email@example.com/admin/api/2019-07/checkouts/14201b794685cdf16857dd996ac026ef/payments.json";
// I have removed the api & secret key
$method2 = "POST";
$local_ip = getHostByName(php_uname('n'));
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$postData_payment_1 = array ('payment' => array ('request_details' => array ('ip_address' => $local_ip, 'accept_language' => $accept_language, 'user_agent' => $user_agent, ), 'amount' => '10', 'session_id' => $credit_card_vault_session_id, 'unique_token' => 'token I received when I installed the app from the partner a/c to shop', ) );
$postData_payment = json_encode($postData_payment_1);
$curl = curl_init($url2);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_MAXREDIRS, 3);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
// curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 3);
// curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_USERAGENT, 'My New Shopify App v.1');
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method2);
$response2 = curl_exec($curl);
$error_number2 = curl_errno($curl);
$error_message2 = curl_error($curl);
// Close cURL to be nice
Here is the response I received:
date: Wed, 09 Oct 2019 14:59:00 GMT
content-type: application/json; charset=utf-8
set-cookie: __cfduid=d6358657c89b5afe584709a818bc1a3e61570633140; expires=Thu, 08-Oct-20 14:59:00 GMT; path=/; domain=.myshopify.com; HttpOnly
content-security-policy: default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src https://cdn.shopify.com https://cdn.shopify.cn https://checkout.shopifycs.com https://js-agent.newrelic.com https://bam.nr-data.net https://dme0ih8comzn4.cloudfront.net https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://js.braintreegateway.com https://c.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com https://widget.intercom.io https://js.intercomcdn.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fcheckouts%2Fpayments&source%5Bsection%5D=admin_api&source%5Buuid%5D=b980db70-4d9f-4b2f-884e-eddecee5293e
x-xss-protection: 1; mode=block; report=/xss-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fcheckouts%2Fpayments&source%5Bsection%5D=admin_api&source%5Buuid%5D=b980db70-4d9f-4b2f-884e-eddecee5293e
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Thanks in advance.
Solved! Go to the solution
That is odd. One note, though I am not sure that is related, the value for unique_token should be unique across all payments created. Definitely, you must not use the token you've got while installing the app. It should be a random, unique value.
Your app does not have access to payment processing, but I can see you requested it. You'll need to wait until your request is complete before you can start payment processing through your app.
My payment processing request was rejected/failed since it was a single store. They said like it will be enabled only for the merchant sites. So I wasn't able to continue the payment process.
1. Is there any way I can process the payment?
2. I see a weburl is generated when creating a checkout and if I access that url, it takes me to the store checkout page. But the problem is after the payment is made, it doesn't bring me back to my website, it stays on the shopify store checkout only with the thank you message. Is there a way I can redirect them to my website where I created the this checkout process?
3. Any other idea I can solve this?
Thanks in advance.