I have site with a members area that I've set up and want to make it so when people register, they need to subscribe to paypal, and only then the user is created in the database.

I don't know much how paypal works. Does anyone have any pointers? How or where do I start?

Basically I need to somehow redirect the visitor to paypal after he presses the "Register" button, make the payment, and then make Paypal return to my site and tell it that the payment was processed, so the user can be created...

有帮助吗?

解决方案

Look at the Paypal IPN API, this is used in most paid membership scripts: https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/library_code

其他提示

Paypal IPN is the Paypal deployment for this kind of requirement.

IPN (Instant Payment Notification) allows you to delegate an endpoint URL that the payment gateway will send postdata to when a payment is completed successfully.

Most of the time this requires utilizing some kind of database to save the registration state while the user is forwarded over to Paypal for the payment process, making use of their SSL encryption and payment logic. When the process is completed, your application is notified with post data containing a unique identitfier generated by your app and passed with the original redirect in order to identify the user's session that has completed payment.

You will want to generate a unique id either using PHP uniqueid() function or by hashing a timestamp. This will be passed along to paypal in your redirect, and paypal will send it along with success/fail flags when the payment is processed. When the user fills out their form and is redirected to Paypal, save a boolean value for IsPaid in your database associated with their ID (i'd recommend using both a primary key as well as this unique transaction id mentioned earlier.) Your IPN script can then listen for the post data, parse it out and change the false IsPaid boolean for that id to true.

There are numerous good tutorials available. I've only used this in MVC deployments, so if you're doing procedural, googling around will help a great deal. Paypal's documentation has the most up to date parameter guides but there are other great, if a bit old, tutorials available independent of them.

http://www.web-development-blog.com/archives/easy-payments-using-paypal-ipn/

http://net.tutsplus.com/tutorials/php/using-paypals-instant-payment-notification-with-php/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top