问题
I need to simulate IPN when a recurring payment fails. My application can then create create pending invoices and send it to the customers.
I searched and found that I would need to setup IPN that will handle below txn_type
recurring_payment_skipped
recurring_payment_failed
Will these two be sufficient?
Also, Recently paypal has provided a new tool called IPN Simulator where you can send a sample IPN to a URL. It only supports below txn_type
s
web_accept
(eCheck-pending, eCheck-declined, eCheck-complete)cart
(Express checkout, Cart checkout)web_accept
(Web Accept, Refund)and so on. But no
recurring_payment_skipped
orrecurring_payment_failed
Where can I simulate those from?
Please help me out.
回答1:
You are correct, currently, the IPN Simulator does not support Transaction type for subscriptions. Yesterday, May 29, 2015, I put in a request for this at PayPal-PHP-SDK github
https://github.com/paypal/PayPal-PHP-SDK/issues/316
There is a workaround,
For IPN Simulator, I choose some transaction type like "Cart checkout". Then down in the "custom" field I put "sim".
In my IPN listener, I have a block of code that checks if the "custom" field is set to "sim", if it is, then I hard code in test values.
// if data is coming from the IPN Simulator then
// just hard code the data in here
if ( $rawData[custom] == "sim") {
$rawData[txn_type] = "recurring_payment";
$rawData[recurring_payment_id] = "I-ABCDEF123456";
}
If "custom" is not set to "sim", then your IPN listener bypasses this code block and functions normally. Note: rawData is an array for holding the raw data. At the beginning of the IPN listener, I get all the raw data and put it into an array.
This will allow you to get your IPN script working, and at the same time, not interfere with any other real IPN data coming in.
来源:https://stackoverflow.com/questions/28497895/simulate-ipn-for-recurring-payment-skipped-from-developer-sandbox-com