Created
May 1, 2020 13:47
-
-
Save egibney/ca76d6b8bc61022af118703f3e316d35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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