我是新来的铁轨,我想尝试建立一个买方和卖方市场我想使用贝宝ruby adaptive payment sdk宝石这个实验。github页面给出和示例代码来设置它。如何使用PayPal Adaptive Payments SDK?
require 'paypal-sdk-adaptivepayments'
PayPal::SDK.configure(
:mode => "sandbox", # Set "live" for production
:app_id => "APP-80W284485P519543T",
:username => "jb-us-seller_api1.paypal.com",
:password => "WX4WTU3S8MY44S7F",
:signature => "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy")
@api = PayPal::SDK::AdaptivePayments.new
# Build request object
@pay = @api.build_pay({
:actionType => "PAY",
:cancelUrl => "http://localhost:3000/samples/adaptive_payments/pay",
:currencyCode => "USD",
:feesPayer => "SENDER",
:ipnNotificationUrl => "http://localhost:3000/samples/adaptive_payments/ipn_notify",
:receiverList => {
:receiver => [{
:amount => 1.0,
:email => "[email protected]" }] },
:returnUrl => "http://localhost:3000/samples/adaptive_payments/pay" })
# Make API call & get response
@response = @api.pay(@pay)
# Access response
if @response.success?
@response.payKey
@api.payment_url(@response) # Url to complete payment
else
@response.error[0].message
end
在哪里可以将我的自定义版本的代码放在OrdersController,applicationController或UserController中?我只需要一点指导。
您能详细解释一下您提供的解决方案吗? – abarisone