根据我收集的几篇stackoverflow帖子,当用户取消贝宝定期付款时,会向IPN设置中设置的指定url发送即时付款通知。但我无法收集的是查询字符串中发送到该url的数据。我偶然发现了这个链接:
https://www.paypal.com/cgi-bin/webscr?cmd=p/acc/ipn-subscriptions-outside
它提供了一个变量列表,我认为这些变量是作为查询字符串的一部分发送的,该字符串使用IPN设置中指定的url发送。如果这是真的,那么这意味着我知道这个通知是一个取消通知,因为txn_type的值将是"substra_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是否也包括在内。
取消配置文件时,在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
)