Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Add order_id to Charges and my_customer_id to Customers created in sample app. #35

Merged
merged 1 commit into from
Aug 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def log_info(message)
:source => source,
:description => "Example Charge",
:shipping => payload[:shipping],
:metadata => {
:order_id => '5278735C-1F40-407D-933A-286E463E72D8',
}.merge(payload[:metadata] || {}),
)
rescue Stripe::StripeError => e
status 402
Expand All @@ -78,7 +81,13 @@ def authenticate!
end
else
begin
@customer = Stripe::Customer.create(:description => "mobile SDK example customer")
@customer = Stripe::Customer.create(
:description => 'mobile SDK example customer',
:metadata => {
# Add our application's customer id for this Customer, so it'll be easier to look up
:my_customer_id => '72F8C533-FCD5-47A6-A45B-3956CA8C792D',
},
)
rescue Stripe::InvalidRequestError
end
session[:customer_id] = @customer.id
Expand All @@ -94,7 +103,10 @@ def authenticate!
:amount => params[:amount], # this number should be in cents
:currency => "usd",
:source => params[:source],
:description => "Example Charge"
:description => "Example Charge",
:metadata => {
:order_id => '5278735C-1F40-407D-933A-286E463E72D8',
}.merge(params[:metadata] || {}),
)
rescue Stripe::StripeError => e
status 402
Expand All @@ -117,6 +129,9 @@ def authenticate!
:currency => params[:currency] || 'usd',
:description => params[:description] || 'Example PaymentIntent charge',
:return_url => params[:return_url],
:metadata => {
:order_id => '5278735C-1F40-407D-933A-286E463E72D8',
}.merge(params[:metadata] || {}),
)
rescue Stripe::StripeError => e
status 402
Expand Down Expand Up @@ -151,7 +166,10 @@ def authenticate!
:currency => source.currency,
:source => source.id,
:customer => source.metadata["customer"],
:description => "Example Charge"
:description => "Example Charge",
:metadata => {
:order_id => '5278735C-1F40-407D-933A-286E463E72D8',
}.merge(source.metadata || {}),
)
rescue Stripe::StripeError => e
return log_info("Error creating charge: #{e.message}")
Expand Down