PayPal Integration And IPN (Instant Payment Notification), Wiki, Yii PHP Framework, кэшбэк ipn

Кэшбэк ipn



Had to implement PayPal payments for a client and would like to share part of my code with you. Because the tutorial will become too long, I'll leave some code to be done by you, e. g. creating models, controllers and db tables for products, orders.



Preparation ¶



Sign up a developer account ¶

Head to https://developer. paypal. com/ and sign up a developer account. Grap a cool PHP IPN Listener from https://github. com/Quixotix/PHP-PayPal-IPN and put the file IpnListener. php in protected/components/ directory. On my host the default setting for using CURL d >¶

Edit protected/config/main. php and add blocks of code for LIVE and DEV environment.



Implementation of payments ¶



Assuming we're going to use the HTML forms method, in your view script enter:



Note: You will have to login in https://developer. paypal. com/ in advance, before making a test payment.



IPN (Instant Payment Notification) Listener Script ¶



The listener script is there to accept the request from PayPal about the status of payments. Remember that we're going to use a ready IPN class and we set the notify URL to be order/paypalNotify? Here's a sample: OrderController::actionPaypalNotify()



This assumes we have a PayPal. php file and PayPal class in protected/components dir.



And here's part of Order model just to show some constants and statuses:



That's about it folks ¶



Hope the tutorial is clear enough. Will update it if needed. Help me improve it by comments and opinions. Please use the Forum if you have any questions. Thank you.



Related Articles



A few questions



Hi,

Thanks for your helpful contribution.

I'm developing a small app store and paypal interactions (expecially for subscriptions) is quite annoying. Luckily for me I found the following module which helped me a lot: http://www. yiiframework. com/extension/ppext/



Anyway I would like to ask you a few questions.

First, why did you choose not to you use a CFormModel to manage Paypal purchase form?

And second, did you use different methods to handle PDT and IPN notifications?

Thank you for your time



Re: A few questions



@cgabbanini good question. In this case one may use CFormModel instead of CActiveForm. The form however submits to order/create and a record is created in table order. Also I had other fields for user's data if they choose to checkout as a guest and they are inserted in table order too. If an error is returned from the model, it will be displayed in the JavaScript alert window.



I looked at Yii login. php view script that is created in the basic application with the "yiic webapp " command. They also use CActiveForm in the view though the login form can be done with CFormModel and isn't a typical CRUD operation. To be honest I don't understand in depth when what should be used and could not find much info too.



About your second question. I'm not sure I understand it. I do not use other methods that those mentioned in the article.



PS If you want to take the discussion further, please post in the forums. Thanks.



Make sure your listener outputs html



I spent a very long time before I figured out that the listener (even though nobody is expected to go directly there) MUST output some html or paypal will claim that the url is invalid and will not flag the transaction as complete.

Комментарии

Популярные сообщения из этого блога

DNS Кэшбэк - особенности и алгоритм получения, cash back dns

Альфа Банк кэшбэк по кредитной и дебетовой карте условия, отзывы, альфа кэшбэк дебетовая