Skip to content

Instantly share code, notes, and snippets.

@egibney
Created May 1, 2020 13:47
Show Gist options
  • Save egibney/ca76d6b8bc61022af118703f3e316d35 to your computer and use it in GitHub Desktop.
Save egibney/ca76d6b8bc61022af118703f3e316d35 to your computer and use it in GitHub Desktop.
def create
@streamplay = Streamplay.find(params[:id])
page_read = @streamplay.page_read
price = page_read * 400
session = Stripe::Checkout::Session.create(
payment_method_types: ['card'],
customer_email: current_user.email,
line_items: [{
name: 'Convert screenplay to audio',
amount: price,
currency: 'usd',
quantity: 1,
}],
metadata: {
page_read: page_read,
},
success_url: 'https://streamplayed.com/checkout/success?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'https://streamplayed.com/checkout/cancel',
)
@session_id = session.id
@streamplay.update(stripe_session: @session_id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment