【发布时间】:2014-03-07 03:08:42
【问题描述】:
我是 Rails 新手,我想尝试建立一个买家和卖家市场,我想使用 paypal ruby adaptive payment sdk gem 进行此实验。github 页面提供了用于设置它的示例代码。
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 => "platfo_1255612361_per@gmail.com" }] },
: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 中?我只是需要一些指导。
【问题讨论】:
标签: ruby-on-rails paypal