Adaptivepayments-sdk-ruby(又称 PayPal Adaptive Payments SDK)正如名字所形容的那样,这是一个 RUBY 编写的自适应支付 SDK(Adaptive Payment SDK )。
PayPal Adaptive Payments SDK 提供了 Ruby APIs 来创建、处理和管理简单和复杂(parallel and chained)支付方式,并且使用 Adaptive Payments API 实现预批准申请。
代码示例:
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.payment_exec_status != "ERROR" @response.payKey @api.payment_url(@response) # Url to complete payment else @response.error[0].message end