开发者

PHP Paypal intergration with instant feedback

Is it possible to get an instant response from a paypal transaction and do they hav开发者_JAVA技巧e to leave your site to pay by paypal?

I am working on a site where the user needs to make a one off payment so I have been looking for donation scripts, but most of them are pay for and the only one I found does not give an instant response http://www.ibdhost.com/donation/. If you have any related scripts that you have used before It would be greatly appreciated if you could post them.

Thanks


My application, www.perqworks.com, uses Paypal Website Payment Pro. In the API is a notion of Instant Payment Notification (IPN). https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/library_code_ipn_code_samples

How it works is that a person pays with a credit card. Paypal sends an https response to a 'listener' on my server. With the listener, you can decide to continue the process or throw an error based on the response codes from Paypal.

The documentation and sandbox helped, but the Paypal API can be a little tricky to get your head wrapped around.


In order to be certain you're paying securely, it is necessary for the user to be transferred to paypal's site, otherwise phishing-type attacks would be much easier!

I'm not sure what you mean by instant response, I was under the impression that PayPal merchant accounts can inform the merchant in real time in order for things like registration keys and such to be generated and sent?


Firstly, take this all with a grain of salt: I haven't actively used Paypal for at least a year...

You can (or could) use Paypal without having the user leave your site: it was called something like "Merchant Services Pro" and had a monthly fee associated with it.

Not bad timing to ask, actually, with Paypal announcing their Open API yesterday (see http://www.pcworld.com/businesscenter/article/181382/paypal_introduces_open_api_to_put_payments_into_apps.html ).

Anyway, as far as 'instant' notification is concerned: it doesn't technically happen. When the user is pushed off to Paypal and make their payment, two things happen:

  1. the user is eventually pushed back to your site, with a transaction ID
  2. when the transaction is cleared (although this normally occurs 'instantly', it can take a couple of days), Paypal hits your site, asynchronously, totally separated from the user, to another predetermined URL with a different ID (I'm pretty sure it's different)

Anyway, between the two you normally are OK. Normally my coding workflow would be something like:

  1. send user off to Paypal with unique ID 'my_defined_transaction_id'
  2. when the user finishes payment, have them come back to user_finished.php (Paypal with give me an ID)
  3. have my Paypal settings set so that on transaction clearance, Paypal will hit transaction_cleared.php with a GET parameter indicating 'my_defined_transaction_id' (again Paypal will give me an ID).
  4. Paypal generally hits transaction_cleared.php well before the user gets to user_finished.php: when Paypal hits that URL, I mark 'my_defined_transaction_id' as "OK" (after cross referencing back to Paypal to ensure validity).
  5. When the user ends up back at user_finished.php, I can cross reference the transaction ID back to Paypal, ensure validity and then mark 'my_defined_transaction_id' as "OK".

Doing this all in two steps allows the user to close the browser without going back to my site and still having the transaction marked as "OK".

Sorry... haven't started my coffee yet, but I hope that makes some sense.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜