【问题标题】:cancel paypal recurring payment with instant payment notification通过即时付款通知取消贝宝定期付款
【发布时间】:2013-05-11 17:39:46
【问题描述】:

根据我收集的几篇 stackoverflow 帖子,当用户取消 paypal 定期付款时,会向 IPN 设置中设置的指定 URL 发送即时付款通知。但我无法收集的是查询字符串中发送到此 url 的数据。我遇到了这个链接:

https://www.paypal.com/cgi-bin/webscr?cmd=p/acc/ipn-subscriptions-outside

它提供了一个变量列表,我假设这些变量是作为查询字符串的一部分发送的,使用 IPN 设置中指定的 url 发送。如果这是真的,那么这意味着我知道这个通知是取消通知,因为 txn_type 值将是“subscr_cancel”。

但是,我仍然需要知道实际上取消了哪些重复计划。因此,我需要知道循环配置文件令牌才能将其作为查询字符串中的变量进行访问。

只是为了让您了解我在这里尝试做什么,这里是一些示例代码:

def notify_url
if params[:txn_type] == "subscr_cancel"
  item_id = Order.where(paypal_recurring_profile_token: params[:recurring_profile_token]).unit_id_for_plan
  agent_host = CONFIG["agent_#{Rails.env}"]["host"]
  agent_port = CONFIG["agent_#{Rails.env}"]["port"]

 url = "http://#{agent_host}:#{agent_port}/home/deactivate?item_id=#{item_id}"
 begin
    resp = Net::HTTP.get(URI.parse(url))
    resp = JSON.parse(resp)
    puts "resp is: #{resp}"
    true
  rescue => error
    raise "Error: #{error}"
  end  

  if resp["status"] == "success"
    true
  end

end    
end

我需要知道的是,当发送取消定期计费的通知时,txn_type 是否等于 subscr_cancel? @PP_MTS_Chad 已经确认包含 recurring_payment_id。我只需要知道 txn_type 是否也包括在内。

【问题讨论】:

    标签: paypal paypal-ipn


    【解决方案1】:

    当一个配置文件被取消时,您将在您的 IPN POST 中取回变量recurring_payment_id,它将具有被取消配置文件的配置文件。

    Array
    (
        [amount3] => 69.95
        [address_status] => confirmed
        [recur_times] => 5
        [subscr_date] => 07:31:10 May 17, 2013 PDT
        [payer_id] => EW4KQ9CQX45F6
        [address_street] => 1 Main St
        [mc_amount3] => 69.95
        [charset] => KOI8-R
        [address_zip] => 95131
        [first_name] => MTS
        [reattempt] => 1
        [address_country_code] => US
        [address_name] => MTS Testing
        [notify_version] => 3.7
        [subscr_id] => I-628HEBW1V99M
        [payer_status] => verified
        [business] => chad@x.com
        [address_country] => United States
        [address_city] => San Jose
        [verify_sign] => AQ3T0Omh4bXNzomBbYUO2LL1dphyAiWU5Sa7wpw8spAU-Pb1YFnm-mig
        [payer_email] => mts_us_per@ccaples.com
        [last_name] => Testing
        [address_state] => CA
        [receiver_email] => chad@x.com
        [recurring] => 1
        [txn_type] => subscr_cancel
        [item_name] => Alice's Weekly Digest
        [mc_currency] => USD
        [item_number] => DIG Weekly
        [residence_country] => US
        [test_ipn] => 1
        [period3] => 6 M
        [ipn_track_id] => 54b49fde502a4
    )
    

    【讨论】:

    • 是否 :txn_type 的值为 "subscr_cancel" 也被退回?
    • 是的,你会得到这个。我在我的原始答案中添加了一个 IPN POST 示例,我在取消个人资料时收到了该示例。
    • 在那个 IPN POST 中,我没有看到 recurring_payment_id。
    • 此特定帖子的 subscr_id 是因为它用于订阅而不是定期付款。只是为了澄清一下,您是使用订阅还是定期付款,您已经提到了两者。
    • 我都在使用。用户购买产品一次性付款。一旦他们购买了产品,他们就会购买一个计划。该计划通过定期付款完成。
    猜你喜欢
    • 2012-05-04
    • 1970-01-01
    • 2012-04-20
    • 2014-03-20
    • 2010-12-22
    • 2016-03-29
    相关资源
    最近更新 更多