fnando / paypal-recurring

PayPal Express Checkout API Client for recurring billing.
256 stars 124 forks source link

Trial amount not considered #17

Open aklein-dex opened 11 years ago

aklein-dex commented 11 years ago

Hey, I'm following the tutorial from RailsCasts and I have no error. But the difference is that I need to add a trial period: Monthly fee: 7000yen First month (trial): 6000yen

Here is my code in PaypalPayment.rb

  def make_recurring
    process :request_payment
    process :create_recurring_profile, 
      period: @subscription.plan.period,
      frequency: @subscription.plan.frequency,
      trial_frequency: @subscription.plan.trial_frequency,
      trial_length: @subscription.plan.trial_cycle,
      trial_period: @subscription.plan.trial_period,
      trial_amount: @subscription.plan.trial_amount,
      start_at: Time.zone.now
  end

private

  def process(action, options = {})
    options = options.reverse_merge(
      token: @subscription.paypal_payment_token,
      payer_id: @subscription.paypal_customer_token,
      description: @subscription.plan.name,
      amount: @subscription.plan.amount,
      currency: @subscription.plan.currency
    )
    response = PayPal::Recurring.new(options).send(action)
    raise response.errors.inspect if response.errors.present?
    response
  end

When the user complete the subscription, in "My recent activity" on the Paypal website I can see 2 things: 1) 2 lines are added: 2012 Nov 2 | Recurring Payment To | Seller X's Test Store | Created | ... 2012 Nov 2 | Payment To | Seller X's Test Store | Completed | -¥7,000 JPY

2) If I click on "Details" for the first line, I can see: Trial Period ¥6,000 JPY 1 1 Monthly Regular Recurring Payment ¥7,000 JPY indefinite indefinite Monthly

So my question is why the "completed" transaction was not 6000yen ?

aklein-dex commented 11 years ago

The only thing I can think of is to remove the call to "process :request_payment" despite the fact the the doc says "Now, you need to request payment. " and also in the railsCast.

If you know any other solution, please let me know