Solved

Create new payment 404 error response

aruninnoppl
Tourist
12 0 2

Hello All,

 

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___________:532215___________9@shopname.myshopify.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);

curl_setopt($curl, CURLOPT_POSTFIELDS,$postData_payment);

$response2 = curl_exec($curl);
$error_number2 = curl_errno($curl);
$error_message2 = curl_error($curl);
// Close cURL to be nice
curl_close($curl);

print_r($response2);

 

====

 

Here is the response I received:

 

HTTP/2 404
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
x-sorting-hat-podid: 63
x-sorting-hat-shopid: 21444296768
vary: Accept-Encoding
referrer-policy: origin-when-cross-origin
x-frame-options: DENY
x-shopid: 21444296768
x-shardid: 63
x-stats-userid:
x-stats-apiclientid: 3161903
x-stats-apipermissionid: 193724481600
x-shopify-api-terms: By accessing or using the Shopify API you agree to the Shopify API License and Terms of Use at https://www.shopify.com/legal/api-terms
strict-transport-security: max-age=7889238
x-request-id: b980db70-4d9f-4b2f-884e-eddecee5293e
x-shopify-stage: production
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-content-type-options: nosniff
x-download-options: noopen
x-permitted-cross-domain-policies: none
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
x-dc: gcp-us-east1,gcp-us-east1
cf-cache-status: DYNAMIC
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 52313747cbacaae0-MAA

{"errors":"Not Found"}

 

Thanks in advance.

Accepted Solutions (2)

Visely-Team
Shopify Partner
1843 210 488

This is an accepted 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.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog

View solution in original post

Busfox
Shopify Staff (Retired)
628 49 110

This is an accepted solution.

 

Hi @aruninnoppl,

 

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.

 

Cheers,

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 5 (5)

Visely-Team
Shopify Partner
1843 210 488

This is an accepted 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.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
aruninnoppl
Tourist
12 0 2

Thanks, Sergiu. Yes, the token was wrong and now I corrected it. I appreciate your help.

Busfox
Shopify Staff (Retired)
628 49 110

This is an accepted solution.

 

Hi @aruninnoppl,

 

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.

 

Cheers,

To learn more visit the Shopify Help Center or the Community Blog.

aruninnoppl
Tourist
12 0 2

Thanks Busfox. Yes the requested was not accepted so it was showing the 404. Thanks for your help.

aruninnoppl
Tourist
12 0 2

Hello Busfox,

 

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.