Paypal经常性付款使用快速结账,在成功付款后不退还发票

时间:2017-09-20 11:50:17

标签: ruby-on-rails paypal paypal-sandbox paypal-ipn paypal-subscriptions

我正在尝试使用ruby on rails中的快速结账设置PayPal定期付款。我已经使用paypal集成了第一次定期付款,所以很抱歉这是一个愚蠢的问题。

我正在使用" SetExpressCheckout"将值传递给paypal的方法。

我将此数据传递到重定向网址中。

data = 'USER='+Settings.paypal_user+'&PWD='+Settings.paypal_password+'&SIGNATURE='+Settings.paypal_signature+'&VERSION=86.0&L_BILLINGTYPE0=RecurringPayments&METHOD=SetExpressCheckout&L_BILLINGAGREEMENTDESCRIPTION0='+description+'&cancelUrl='+Settings.paypal_profile_return_url+'&returnUrl='+returnUrl+'&PROFILESTARTDATE='+Time.now().to_s+'&BILLINGPERIOD=Day&AMT='+order.total_price.to_s+'&CURRENCYCODE=CAD'+'&PAYMENTREQUEST_n_INVNUM='+invoice

这是我重定向到paypal的代码。

uri = URI.parse('https://api-3t.sandbox.paypal.com/nvp')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path)
request.body = data
response = http.request(request)
response_body = URI.decode(response.body)
if response_body.split("&")[0].include?("TOKEN")
   token = response_body.split("&")[0]
   token.slice!('TOKEN=')
   redirect_to "https://www.sandbox.paypal.com/cgi-bin/webscrcmd=_express-checkout&token=#{token}"
   return
end

一切正常。可以付款。我已经为重定向设置了IPN网址。在使用notifacation控制器调用成功支付IPN重定向url并且重定向url返回到我在通知控制器中的应用程序。我希望将发票编号作为来自WEBHOOK请求的参数发送到通知控制器中。 WEBHOOK请求不能作为参数给我发票号。

缺少什么,不知道,请帮助我。

这是成功付款后的webhook请求。

webhook request:::::: {"mc_gross"=>"191.40", "outstanding_balance"=>"0.00", "period_type"=>" Regular",  "next_payment_date"=>"03:00:00 Sep 26, 2017 PDT", "protection_eligibility"=>"Eligible", "payment_cycle"=>"every 7 Days", "address_status"=>"confirmed", "tax"=>"0.00", "payer_id"=>"XYZ", "address_street"=>"XYZ", "payment_date"=>"04:21:08 Sep 20, 2017 PDT", "payment_status"=>"Completed", "product_name"=>"Subscription - XYZ", "charset"=>"windows-1252", "recurring_payment_id"=>"I-ACEDHN4CW1F0E", "address_zip"=>"123456", "first_name"=>"sanjay", "mc_fee"=>"5.85", "address_country_code"=>"US", "address_name"=>"xyz", "notify_version"=>"3.8", "amount_per_cycle"=>"191.40", "payer_status"=>"verified", "currency_code"=>"CAD", "business"=>"ankita.koitiya-facilitator@bacancytechnology.com", "address_country"=>"United States", "address_city"=>"xyz", "verify_sign"=>"cas52InFHk3cJ5j80u2Udq.A26J4AqTyZhG.AwL7vRFZd2nF9yBvISOP", "payer_email"=>"xyz@gmail.com", "initial_payment_amount"=>"0.00", "profile_status"=>"Active", "amount"=>"191.40", "txn_id"=>"3B470367SX972320F", "payment_type"=>"instant", "last_name"=>"vyas", "address_state"=>"CA", "receiver_email"=>"sandboxtestaccount@gmail.com", "payment_fee"=>"", "receiver_id"=>"NW67DH9TEACW6", "txn_type"=>"recurring_payment", "mc_currency"=>"CAD", "residence_country"=>"US", "test_ipn"=>"1", "transaction_subject"=>"Subscription - xyz", "payment_gross"=>"", "shipping"=>"0.00", "product_type"=>"1", "time_created"=>"04:16:21 Sep 20, 2017 PDT", "ipn_track_id"=>"a0e1f9e94e7c2", "controller"=>"notifications", "action"=>"create"}

提前致谢。

0 个答案:

没有答案