Simulate IPN for recurring_payment_skipped from developer.sandbox.com

拈花ヽ惹草 提交于 2019-12-23 09:39:22

问题


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_types

  • 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 or recurring_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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!