贝宝的交易记录创建一个额外的定期付款

问题描述:

我使用贝宝经常性的宝石:贝宝的交易记录创建一个额外的定期付款

https://github.com/fnando/paypal-recurring

为on Rails应用程序红宝石

这里是我的代码选定部分:

def make_recurring 

    process :request_payment 

    if @plan 
     create_units 
     process :create_recurring_profile, period: @plan.recurring, amount: (@plan.price), frequency: 1, start_at: Time.zone.now   
    end 
    end 


def process(action, options={}) 
    not_recurring_amount = @cart.total_price 
    not_recurring_amount += 19.95 if @plan #add activation price for first payment 

    options = options.reverse_merge(
     token: @order.paypal_payment_token, 
     payer_id: @order.paypal_customer_token, 
     description: "Your product total is below", 
     amount: not_recurring_amount.round(2), 
     currency: "USD" 
    ) 

    response = PayPal::Recurring.new(options).send(action) 
    raise response.errors.inspect if response.errors.present? 
    response 
    end 

基本上,用户购买产品并收取239.95。然后用户通过一次激活购买产品的计划,并收取33.95。这些都是一次性付款。然后,当他们购买该计划时,他们还会收取该通话时间计划每月14.95美元的费用。一切似乎工作,但我在我的PayPal沙盒帐户注意到另一个经常性费用是空白:

enter image description here

这是为什么空费怎么回事?

这不是实际收费,它只是创建配置文件的记录。您必须首先创建配置文件,然后才能对其进行收费。这在您看到的PayPal帐户中反映出来。

+0

那么我所做的正确吗?我不确定结果是否符合我的期望。 – JohnMerlino 2013-05-10 13:26:23

+0

你所做的事看起来是正确的。但是,关于一次性设置33.95的费用,您可以将其仅分配给仅收取一次的配置文件,但不包括它作为常规循环配置文件chage的一部分。创建配置文件时,如果使用NVP,则只需使用变量INITAMT设置此数量即可。您也可以使用变量FAILEDINITAMTACTION来设置操作。 – 2013-05-10 13:50:04