我在我的ruby on rails项目中使用了paypal-express gem。我正在尝试实施Paypal定期付款。
我能够成功完成expresscheckout,但是我面临上述无效令牌错误的定期付款。我正在做一切正常,如paypal-express gem wiki中所述。无法弄清楚这有什么问题。
def paypal_checkout
Paypal.sandbox! if Rails.env.development?
request = Paypal::Express::Request.new(
:username => "USERNAME",
:password => "PASSWORD",
:signature => "SIGNATURE"
)
payment_request = Paypal::Payment::Request.new(
:currency_code => :USD,
:billing_type => :RecurringPayments,
:billing_agreement_description => "Recurring"
)
response = request.setup(
payment_request,
root_url,
root_url
)
uri = response.redirect_uri
token = CGI.parse(uri)['token'].join #here I successfully get the response token
profile = Paypal::Payment::Recurring.new(
:start_date => Date.today,
:description => "Recurring",
:billing => {
:period => :Week,
:frequency => "1",
:amount => "15",
:currency_code => :USD
}
)
response = request.subscribe!(token, profile) # here i face the 'invalid token error'
end
payment_request_response =
#<Paypal::Payment::Request:0x007fa3ca7b3a20 @amount=#<Paypal::Payment::Common::Amount:0x007fa3ca7b39d0 @total=0, @item=0, @fee=0, @handing=0, @insurance=0, @ship_disc=0, @shipping=0, @tax=0, @gross=0, @net=0>, @items=[], @custom_fields={}, @action=nil, @currency_code=:USD, @description=nil, @notify_url=nil, @billing_type=:RecurringPayments, @billing_agreement_description="Recurring billing description", @billing_agreement_id=nil, @request_id=nil, @seller_id=nil, @invoice_number=nil, @custom=nil>
个人资料回复=
#<Paypal::Payment::Recurring:0x007fd3f0fd78e0 @start_date=Mon, 01 Sep 2014, @description="Recurring billing description", @identifier=nil, @status=nil, @name=nil, @reference=nil, @max_fails=0, @auto_bill=nil, @aggregate_amount=0, @aggregate_optional_amount=0, @final_payment_date=nil, @billing=#<Paypal::Payment::Recurring::Billing:0x007fd3f0fd5248 @amount=#<Paypal::Payment::Common::Amount:0x007fd3f0fd5158 @total=15, @item=0, @fee=0, @handing=0, @insurance=0, @ship_disc=0, @shipping=0, @tax=0, @gross=0, @net=0>, @period=:Month, @frequency=1, @paid=0, @currency_code=:USD, @total_cycles=0>>