首页 文章

测试Paypal订阅IPN

提问于
浏览
37

我想测试paypal订阅IPN,包括创建订阅时收到的IPN,以及稍后发送的下一次付款的IPN(如每月订阅为$ x,则为每月) .

但是我宁愿不等一个月或一天才能收到第二个IPN . 有没有办法使用paypal或他们的沙箱更快地发送IPN,例如每小时?

在文档中,它说您只能指定年,月,日和周作为订阅期 .

5 回答

  • 0

    过去,测试服务器会将以天为单位指定的时间段视为分钟,因此在指定'd3'时每3分钟调用一次 . 我认为他们删除了这个,我不知道有任何替换功能来测试订阅 .

  • 6

    PayPal的开发人员支持和文档令他们感到尴尬 . 但是这种特殊的限制并不像乍一看那样令人虚弱 .

    要进行测试,请定义您的定期付款,以便免费试用 . 当您创建新订阅时,您的服务器将快速连续收到两封IPN消息,一封用于创建订阅,另一封用于应用付款 . 这基本上就是你需要测试的全部内容 .

    如果你有一个免费试用版,你将得到基本相同的一对消息,只是它们之间的试用期 . :)

    第一条消息(“创建订阅”)看起来像这样 . 注意'txn_type' - 这是消除两个消息歧义的关键信息:

    {
      "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"=>"test_xxxx@example.com",
      "residence_country"=>"US",
    
      "business"=>"seller_xxxxxxx@example.com",
      "receiver_email"=>"seller_xxxxxxx@example.com",
    
      "reattempt"=>"1",
    
      "charset"=>"windows-1252","notify_version"=>"2.9","test_ipn"=>"1",
    }
    

    在这种情况下,第二条消息更有趣 . 它将基本上是您在以后应用定期付款时获得的完全相同的消息 . 它看起来像这样:

    {
      "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"=>"test_xxxx@example.com",
      "residence_country"=>"US",
    
      "receiver_id"=>"your_merchant_id",
      "business"=>"seller_xxxxxxx@example.com",
      "receiver_email"=>"seller_xxxxxxx@example.com",
    
      "protection_eligibility"=>"Ineligible",
      "transaction_subject"=>"",
      "charset"=>"windows-1252","notify_version"=>"2.9","test_ipn"=>"1",
    }
    

    因此,您无需等待一天即可完成几乎所有测试 . 当您认为已经确定它时,您将在第二天收到大量订阅IPN消息 .

    此外,here是PayPal文档的链接,以供进一步参考 .

  • 8

    可以重新发送测试IPN,因此您只需要“购买”一个订阅进行测试 . 一旦您购买了一个订阅,这里是做什么的:

    • 登录您的PayPal沙箱 seller 帐户 .

    • 选择'Profile' => 'My Selling Preferences' .

    • 从第三列中选择'Instant Payment Notification Preferences' .

    • 确认已启用IPN且URL正确无误 .

    • 单击指向 IPN History 页面的链接 .

    • 向下滚动,勾选一个或多个IPN,然后单击'Resend' .

    确认后,所选的IPN现在将重新发送到您指定的URL . 您可以使用相同的IPN重复无限次 .

    @dondo的优秀答案涵盖了其余部分 .

  • 56

    嘿,我只想向Neil大声喊叫,因为这正是我所寻找的,而且我没有足够的声誉来回复或赞成 .

    信不信由贝宝仍然不容易用ipn文件进行订阅测试:/

    所以,仅仅因为我没有在这里看到它而且OP听起来像他们的印象只是期待教皇的两个可能的回应 -

    如果其他人有问题,这里有一些其他txn_type在测试时击中了我的ipn:

    //when paypal subscription profile is created for the subscriber
    subscr_signup 
    
    //payment made for a given billing cycle
    subscr_payment 
    
    //when subscription fails
    subscr_failed 
    
    //user cancels subscription - not
    subscr_cancel 
    
    //end of term - paypal is "done" with that subscriber 
    subscr_eot 
    
    //why I was looking for this thread to begin with lol
    recurring_payment_suspended_due_to_max_failed_payment
    

    今天早上最后一个人在我的测试用户中遇到了最后一个 . 当我查找这意味着什么时,我发现以下内容也可以获得:

    recurring_payment_profile_created
    
    recurring_payment_profile_cancel
    
    recurring_payment_profile_modify
    
    recurring_payment
    
    recurring_payment_skipped
    
    recurring_payment_failed
    

    我不知道我做了什么才能得到这个,因为订阅和定期付款在PayPal的眼中在技术上是不同的(订阅可能永远不会终止但是定期付款对某人可以为任何“订阅”支付的总付款有上限)但是他们的文档也不总是直截了当,所以我不知道 . 我还在努力弄清楚这是一个由沙盒商家帐户生成的订阅按钮,但无论如何 .

    快乐的头痛:)

    更新:我刚才发现了我的问题 - 所以听起来我知道我在做什么我会解释......

    我认为paypal的订阅沙箱环境正在慢慢消亡 . 我注意到有一天,当我在sandbox.paypal.com上乱搞时,我很多次遭遇“致命失败” . 刷新页面似乎可以纠正这个问题,尽管有时我需要刷新几次才能让屏幕回来 .

    我从他们的IPN文件中获得相同的响应,这解释了为什么我今天暂停的每个订阅 . 感谢Neil我能够重新发送IPN响应和我将它捕获到一个文本文件(lol)然后我在响应中点击ipn文件读取并将其扔回到paypal(它真的比我只是让它听起来更复杂) .

    在任何情况下,通过刷新页面,我可以或多或少按需启动paypal握手,当我这样做时,它是50/50 - 有时我得到验证,有时我会致命致命失败 - 就像我尝试做任何事情一样在他们的沙箱网站(致命的失败) .

    下面是我从他们那里获得的失败响应的一部分的例子......我得到200,所以我认为击中他们的服务器不是连接问题,但我开始看到这里有“致命失败”的模式这表明他们的结局比我的更多

    HTTP/1.1 200 OK 
    Date: Tue, 29 Sep 2015 02:41:00 GMT 
    Server: Apache 
    
    Fatal Failure
    
  • 7

    您也可以从沙箱中手动创建IPN:

    https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session

相关问题