shababhsiddique
shababhsiddique

Reputation: 911

Shopify Payment App, Payment Session recieved POST request without any data

I am currently working on a shopify offsite payment provider app. As per the docs the payment app is approved and is marked ready to use from admin.

During checkout HTTP POST request recieved from Shopify to the provider's payment session URL provided during the payments app extension configuration. But that request has no data in it.

POST:Array
(
)
GET:Array
(
)
SERVER:Array
(
    [DOCUMENT_ROOT] => /home/shababhsiddique/Work/Docker/cardinity-shopify/cardinity_external_payment/public
    [REMOTE_ADDR] => 127.0.0.1
    [REMOTE_PORT] => 33874
    [SERVER_SOFTWARE] => PHP 7.4.16 Development Server
    [SERVER_PROTOCOL] => HTTP/1.1
    [SERVER_NAME] => 127.0.0.1
    [SERVER_PORT] => 8081
    [REQUEST_URI] => /payment.php
    [REQUEST_METHOD] => POST
    [SCRIPT_NAME] => /payment.php
    [SCRIPT_FILENAME] => /home/shababhsiddique/Work/Docker/cardinity-shopify/cardinity_external_payment/public/payment.php
    [PHP_SELF] => /payment.php
    [HTTP_HOST] => 0d07-178-236-207-149.ngrok.io
    [HTTP_USER_AGENT] => Faraday v1.10.0
    [CONTENT_LENGTH] => 874
    [HTTP_CONTENT_LENGTH] => 874
    [HTTP_ACCEPT] => application/json
    [HTTP_ACCEPT_ENCODING] => gzip;q=1.0,deflate;q=0.6,identity;q=0.3
    [CONTENT_TYPE] => application/json
    [HTTP_CONTENT_TYPE] => application/json
    [HTTP_SHOPIFY_API_VERSION] => 2022-04
    [HTTP_SHOPIFY_REQUEST_ID] => efca42b2-8861-4e6c-aafc-297ecc4cba54
    [HTTP_SHOPIFY_REQUEST_TIME] => 2022-06-06T05:31:18Z
    [HTTP_SHOPIFY_SHOP_DOMAIN] => cardinity.myshopify.com
    [HTTP_X_CLOUD_TRACE_CONTEXT] => bddbbaf806edd51bcf3c40f2f3353434/2895227500004152964;o=1
    [HTTP_X_FORWARDED_FOR] => 34.75.177.36
    [HTTP_X_FORWARDED_PROTO] => https
    [HTTP_X_SHOPIFY_TRACE_CONTEXT] => bddbbaf806edd51bcf3c40f2f3353434/2895227500004152964;o=1
    [REQUEST_TIME_FLOAT] => 1654493478.7338
    [REQUEST_TIME] => 1654493478
)

If i am not wrong this request is suppose to have all the parameters regarding the payment. https://shopify.dev/apps/payments/processing-a-payment i.e amount etc...

My question is what is making shopify send empty requests to my payment session URL. Or is the data getting lost in the process somewhere?

The app is using laravel built on top of generated project by shopify cli.

and the session url is a standalone php file at this moment. hosted on same server.

Upvotes: 1

Views: 952

Answers (1)

Shabab Siddique
Shabab Siddique

Reputation: 26

The back-end request from Shopify checkout has post data as raw json. Which does not show when dumping either $_POST. or laravel $request->input()

In order to get the request data in php.

$rawdata = file_get_contents("php://input");
$decoded = json_decode($rawdata, true);

Upvotes: 1

Related Questions