Quantity not being returned in PDT

stevsnet
Contributor
Contributor

Hi everyone,

 

I have a product with quantities however the quantity isn't being returned in the PDT when the customer is returned to the website.

 

I'm receiving this in the PDT. 2 items were ordered.

amt=11.00&cc=USD&item_name=THE-PRODUCT&item_number=the-product-code&st=Completed&tx=71xxxxxxxxxxxxxx

 

The quantity is the only field I actually need. Ideally as POST instead of GET data.

 

I can't see anything in the button setup outside of allow customer to change quantities checkbox.

 

Any help would be appreciated.

 

Thanks

Steve

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

MariaMiArt
Contributor
Contributor

I use this code in PHP:

 

if (isset($_GET['tx'])) {
            $query_data = [
                'cmd' => '_notify-synch',
                'tx' => $_GET['tx'],
                'at' => /* my token from paypal settings */
            ];
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_USERAGENT, 'PayPal');
            curl_setopt($ch, CURLOPT_HEADER, false);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query_data));
            curl_setopt($ch, CURLOPT_URL, $this->url);
            $response = curl_exec($ch);
            $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            curl_close($ch);
}

View solution in original post

Login to Me Too
7 REPLIES 7

MariaMiArt
Contributor
Contributor

The following steps illustrate the basic flow of a PDT transaction.

  1. A customer submits a payment.
  2. PayPal sends the transaction ID of the payment through HTTP as a GET variable (tx). This information is sent to the Return URL you specified in your PayPal account profile.

(You are here. You need to make POST request. Read below.)

  1. Your return URL web page contains an HTML POST form that retrieves the transaction ID and sends the transaction ID and your unique PDT token to PayPal.
  2. PayPal replies with a message indicating SUCCESS or FAIL. The SUCCESS message includes transaction details, one per line, in the <Key>=<Value> format. This key-value pair string is URL encoded.
  3. Your web page parses the message and then displays the information for the customer.
Login to Me Too

stevsnet
Contributor
Contributor

Thanks,

 

this helps with the post/get data.

 

I'm still not receiving the quantity though.

 

Cheers

Steve

Login to Me Too

MariaMiArt
Contributor
Contributor

Do you send POST request to Paypal with your TX (transaction ID returned to you with GET response)?

Login to Me Too

stevsnet
Contributor
Contributor

Not yet.

 

At the moment I'm just looking at the data being returned by Paypal in the GET response.
I'm currently receiving amt, cc, item_name, item_number, st & tx. I thought quantity would be in there too.

Login to Me Too

MariaMiArt
Contributor
Contributor

No, would not. You are not finished the whole process. I mean at this step you are not sure that transaction is successful.

 

At your step Paypal returns you only one important parameter - "tx", and Paypal wait you necessarily check transaction through POST.

 

When you will request (POST) and get response you will get all of parameters about transaction, include quantity.

 

Read this - https://developer.paypal.com/docs/classic/products/payment-data-transfer/

Login to Me Too
Solved

MariaMiArt
Contributor
Contributor

I use this code in PHP:

 

if (isset($_GET['tx'])) {
            $query_data = [
                'cmd' => '_notify-synch',
                'tx' => $_GET['tx'],
                'at' => /* my token from paypal settings */
            ];
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_USERAGENT, 'PayPal');
            curl_setopt($ch, CURLOPT_HEADER, false);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query_data));
            curl_setopt($ch, CURLOPT_URL, $this->url);
            $response = curl_exec($ch);
            $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            curl_close($ch);
}
Login to Me Too

stevsnet
Contributor
Contributor
Thanks for that. I ended up using something similar and it works great. Appreciate the help.
Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.