views:

1206

answers:

2

I'd like to test paypal subscription IPNs, both the ones received when a subscription is created, and the ones sent later with the next payment (such as monthly if the subscription is $x per month).

However I'd prefer not to wait a month or a day to receive the second IPN. Is there a way to have an IPN sent quicker, such as hourly, using paypal or their sandbox?

On the documentation it says you can only specify years, months, days, and weeks as the subscription period.

+2  A: 

It used to be that the period specified in days would be treated by the test server as minutes so you'd be called every 3 minutes when specified 'd3'. I think they removed this and I'm not aware of any replacement feature to test subscriptions.

Remus Rusanu
You sure they removed this? Any links?
Click Upvote
Remus Rusanu
Yea, you're right, i've tested this and the days-mins thing doesn't work any more. Funny since https://www.paypal.com/en_US/ebook/PP_Sandbox_UserGuide/testing_recurringpayments.html they still describe this feature. I'll wait a few days to see if anyone has any other suggestions
Click Upvote
Yeap, that's the link. I tested mine over three days :)
Remus Rusanu
+4  A: 

PayPal's developer support and documentation is an embarrassment to them. But this particular limitation isn't as debilitating as it seems at first blush.

For testing, define your recurring payment to not have a free trial. When you create a new subscription, your server will receive two IPN messages in quick succession, one to create the subscription and the second to apply a payment. That's basically all you need to test.

If you have a free trial, you'll get basically the same pair of messages, just with a trial period between them. :)

The first message ("create subscription") will look something like this. Note the 'txn_type' -- that's the key bit of information for disambiguating the two messages:

{
  "txn_type"=>"subscr_signup",
  "subscr_id"=>"unique_id",
  "verify_sign"=>"random_gibberish",

  "item_number"=>"your_subscription_name"
  "subscr_date"=>"14:32:23 Feb 15, 2010 PST",
  "btn_id"=>"1111111",
  "item_name"=>"Your Subscription Description",
  "recurring"=>"1",
  "period1"=>"1 M",

  # This example is from a "free trial" IPN notification-- if you don't have a 
  # free trial defined, there will only be 'period1' fields, and they'll
  # have the data that appears here in the 'period3' fields.
  "amount1"=>"0.00",
  "mc_amount1"=>"0.00",
  "period3"=>"1 M",
  "amount3"=>"34.95",
  "mc_amount3"=>"34.95",
  "mc_currency"=>"USD",

  "payer_status"=>"verified",
  "payer_id"=>"payer_unique_id",
  "first_name"=>"Test",
  "last_name"=>"User",
  "payer_email"=>"[email protected]",
  "residence_country"=>"US",

  "business"=>"[email protected]",
  "receiver_email"=>"[email protected]",

  "reattempt"=>"1",

  "charset"=>"windows-1252","notify_version"=>"2.9","test_ipn"=>"1",
}

The second message is the more interesting one in this case. It will essentially be the exact same message you'll get later when the recurring payment is applied. It looks something like this:

{
  "txn_type"=>"subscr_payment",
  "subscr_id"=>"unique_id",
  "verify_sign"=>"random_gibberish",

  "txn_id"=>"payment_unique_id",
  "payment_status"=>"Completed",
  "payment_date"=>"12:45:33 Feb 16, 2010 PST",

  "item_number"=>"your_subscription_name"
  "subscr_date"=>"14:32:23 Feb 15, 2010 PST",
  "custom"=>"data-you-sent-in-a-custom-field",

  "id"=>"1",
  "payment_gross"=>"34.95",
  "mc_currency"=>"USD",
  "payment_type"=>"instant",
  "payment_fee"=>"1.31",
  "payer_status"=>"verified",
  "mc_fee"=>"1.31",
  "mc_gross"=>"34.95",
  "btn_id"=>"1111111",

  "payer_id"=>"payer_unique_id",
  "first_name"=>"Test",
  "last_name"=>"User",
  "payer_email"=>"[email protected]",
  "residence_country"=>"US",

  "receiver_id"=>"your_merchant_id",
  "business"=>"[email protected]",
  "receiver_email"=>"[email protected]",

  "protection_eligibility"=>"Ineligible",
  "transaction_subject"=>"",
  "charset"=>"windows-1252","notify_version"=>"2.9","test_ipn"=>"1",
}

So you can do almost all of your testing without waiting a day. By the time you think you've got it nailed down, you'll be receiving lots of subscription IPN messages the next day.