Jimmy
Jimmy

Reputation: 12487

Accepting single paypal payments

My site is coded in Python and I want to offer the ability to accept payments on my site via paypal. I want to use the free paypal service (no monthly fees) to do this where the user is redirected to paypals site to login and pay. I want the workflow to work something like this:

I understand everything apart from the bit about paypal redirecting back to my site. How can I code it so that I can tell if paypal has been successful and only process the confirmation page on a successful payment?

N.B

Upvotes: 2

Views: 773

Answers (1)

PP_MTS_Chad
PP_MTS_Chad

Reputation: 7319

You could use PayPal's PDT to check to see if the transaction was valid or not. Payment Data Transfer (PDT) is a secure method to retrieve the details about a PayPal transaction so that you can display them to your customer. It is used in combination with Website Payments Standard, so that after a customer returns to your website after paying on the PayPal site, they can instantly view a confirmation message with the details of the transaction. PDT is not meant to be used with credit card or Express Checkout transactions. This page describes how PDT works and how to configure your account to use PDT.

How PDT Works When a customer pays you, PayPal sends the transaction ID of the payment to you by appending the transaction ID to a URL you specify in your account Profile. This information is sent via a HTTP GET as this name/value pair:

tx=transactionID 

After you get the transaction ID, you post a FORM to PayPal that includes the transaction ID and your identity token, a string value that identifies your account to PayPal. There are instructions below that describe how to get your identity token. The form looks like this:

<form method=post action="https://www.paypal.com/cgi-bin/webscr"> 
<input type="hidden" name="cmd" value="_notify-synch"> 
<input type="hidden" name="tx" value="TransactionID"> 
<input type="hidden" name="at" value="YourIdentityToken"> 
<input type="submit" value="PDT"> 
</form> 

In PayPal's reply to your post, the first line will be SUCCESS or FAIL.

Activating PDT To use PDT, you must activate PDT and Auto Return in your PayPal account profile. You must also acquire a PDT identity token, which is used in all PDT communication you send to PayPal.

Follow these steps to configure your account for PDT:

1.Log in to your PayPal account. 2.Click the Profile subtab. 3.Click Website Payment Preferences in the Seller Preferences column. 4.Under Auto Return for Website Payments, click the On radio button. 5.For the Return URL, enter the URL on your site that will receive the transaction ID posted by PayPal after a customer payment. 6.Under Payment Data Transfer, click the On radio button. 7.Click Save. 8.Click Website Payment Preferences in the Seller Preferences column. 9.Scroll down to the Payment Data Transfer section of the page to view your PDT identity token.

The links below will also help you:

PDT varaibles that can be returned

Description of PDT

Sample Code

PDT Troubleshooting Tips

Upvotes: 4

Related Questions