raphael

Joined

70 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Stripe integration on Ruby On Rails

thank you very much :D

this is working! wonderful :D

  def create
    begin
    customer = current_user.stripe_customer
    customer.sources.create(source: params[:stripeToken])
    subscription = customer.subscriptions.create(plan: params[:plan])

Posted in Stripe integration on Ruby On Rails

thank you but i still get error

undefined local variable or method `subscription' for #<SubscriptionsController:0x007ff010ecd7d8> Did you mean? subscription_url
Extracted source (around line #20):

18customer.subscriptions.create(plan: params[:plan])
19
20  current_user.assign_attributes(stripe_subscription_id: subscription.id)
21      current_user.assign_attributes(
22       card_brand: params[:card_brand],
23        card_last4: params[:card_last4],

with updated code:

class SubscriptionsController < ApplicationController
  before_action :authenticate_user!

  def new
  end

  def create
    customer = current_user.stripe_customer

    begin
  #    subscription = customer.subscriptions.create(
  #     customer = Stripe::Customer.create
  #       customer.sources.create(source: params[:stripeToken])
        # customer.subscriptions.create(plan: params[:plan])
  #     )
        customer = Stripe::Customer.create
        customer.sources.create(source: params[:stripeToken])
        customer.subscriptions.create(plan: params[:plan])

Posted in Stripe integration on Ruby On Rails

Hi Thank you for your great course:

i am coding with : https://www.lynda.com/Stripe-API-tutorials/Adding-Stripe-Payments-your-Ruby-Rails-Application/540343-2.html

then i got an error as follows:


Stripe::InvalidRequestError in SubscriptionsController#create
Received unknown parameter: source
Extracted source (around line #11):
begin
subscription = customer.subscriptions.create(
source: params[:stripeToken],
plan: params[:plan]
)


other functions are working but only "Subscription" related part is not working.
as far as i researched, it's attribute to version upgrade of Stripe from 1.5 to 2
"The subscription endpoints no longer support the source parameter."
source: https://stripe.com/docs/upgrades

Is there any way i can quickly fix this?

thank you