Revisions
-
briankung revised this gist
Aug 2, 2017 . 1 changed file with 11 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,18 +4,6 @@ From https://stripe.com/docs/testing#cards # CARD DETAILS BUCKET 4000_0000_0000_0127 { @@ -115,6 +103,17 @@ From https://stripe.com/docs/testing#cards charge: "ch_12345" } } 4100_0000_0000_0019 { error: { message: "Your card was declined.", type: "card_error", code: "card_declined", decline_code: "fraudulent", charge: "ch_12345" } } # And basically everything else... ``` -
briankung revised this gist
Aug 2, 2017 . 1 changed file with 42 additions and 32 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,8 @@ From https://stripe.com/docs/testing#cards ```ruby # CARD DETAILS BUCKET 4100_0000_0000_0019 @@ -21,7 +12,7 @@ From https://stripe.com/docs/testing#cards type: "card_error", code: "card_declined", decline_code: "fraudulent", charge: "ch_12345" } } @@ -33,10 +24,22 @@ From https://stripe.com/docs/testing#cards type: "card_error", param: "cvc", code: "incorrect_cvc", charge: "ch_12345" } } 4000_0000_0000_0101 { error: { message: "Your card's security code is incorrect.", type: "card_error", param: "cvc", code: "incorrect_cvc", charge: "ch_12345" } } 4000_0000_0000_0069 { @@ -45,32 +48,36 @@ From https://stripe.com/docs/testing#cards type: "card_error", param: "exp_month", code: "expired_card", charge: "ch_12345" } } 4242_4242_4242_4241 { error: { message: "Your card number is incorrect.", type: "card_error", param: "number", code: "incorrect_number" } } # PROCESSING ISSUES 4000_0000_0000_0119 { error: { message: "An error occurred while processing your card. Try again in a little bit.", type: "card_error", code: "processing_error", charge: "ch_12345" } } # ADDRESS ISSUES 4000_0000_0000_0010 { @@ -95,16 +102,19 @@ From https://stripe.com/docs/testing#cards } } # GENERIC DECLINE 4000_0000_0000_0002 { error: { message: "Your card was declined.", type: "card_error", code: "card_declined", decline_code: "generic_decline", charge: "ch_12345" } } # And basically everything else... ``` -
briankung revised this gist
Aug 2, 2017 . 1 changed file with 25 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -82,4 +82,29 @@ From https://stripe.com/docs/testing#cards charge: "ch_12345" } } 4000_0000_0000_0036 { error: { message: "The zip code you supplied failed validation.", type: "card_error", param: "address_zip", code: "incorrect_zip", charge: "ch_12345" } } 4000_0000_0000_0101 { error: { message: "Your card's security code is incorrect.", type: "card_error", param: "cvc", code: "incorrect_cvc", charge: "ch_12345" } } ``` -
briankung revised this gist
Aug 2, 2017 . 2 changed files with 24 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -70,4 +70,16 @@ From https://stripe.com/docs/testing#cards code: "incorrect_number" } } 4000_0000_0000_0010 { error: { message: "The zip code you supplied failed validation.", type: "card_error", param: "address_zip", code: "incorrect_zip", charge: "ch_12345" } } ``` This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,17 @@ def test_charge Stripe::Charge.create( amount: 50, currency: "usd", capture: false, source: @source, description: "Test charge", ) end @source = { exp_month: '12', exp_year: '21', number: '4000000000000010', object: "card", cvc: '123', } -
briankung revised this gist
Aug 2, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ def create_auth_charge(number, description = nil) Stripe::Charge.create( amount: 50, currency: "usd", @@ -10,6 +10,6 @@ def create_auth_charge(number) object: "card", cvc: '123', }, description: "Test charge #{Time.zone.now}#{' - ' + description if description}", ) end -
briankung revised this gist
Aug 2, 2017 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ def create_auth_charge(number) Stripe::Charge.create( amount: 50, currency: "usd", capture: false, source: { exp_month: '12', exp_year: '21', number: number, object: "card", cvc: '123', }, description: "Test authorization charge", ) end -
briankung renamed this gist
Aug 2, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ From https://stripe.com/docs/testing#cards ```ruby 4000_0000_0000_0002 { @@ -67,3 +70,4 @@ code: "incorrect_number" } } ``` -
briankung revised this gist
Jul 27, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -122,6 +122,8 @@ Stripe::Subscription.create( ## ...with discounts NOTE! This should be changed to use invoice items A Discount is the application of a Coupon to a Subscription or a Charge. Create a Coupon @@ -164,6 +166,8 @@ Stripe::Charge.create( ## Pay Early / Some now, some later NOTE! This should be changed to use invoice items ```ruby # Accept early payment -
briankung revised this gist
Jul 27, 2017 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
briankung renamed this gist
Jul 27, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
briankung revised this gist
Jul 27, 2017 . 1 changed file with 69 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ 4000_0000_0000_0002 { error: { message: "Your card was declined.", type: "card_error", code: "card_declined", decline_code: "generic_decline", charge: "ch_1AkHvOK3cnS75wRwvtyxdMOx" } } 4100_0000_0000_0019 { error: { message: "Your card was declined.", type: "card_error", code: "card_declined", decline_code: "fraudulent", charge: "ch_1AkHxGK3cnS75wRww0g2CMDr" } } 4000_0000_0000_0127 { error: { message: "Your card's security code is incorrect.", type: "card_error", param: "cvc", code: "incorrect_cvc", charge: "ch_1AkHyOK3cnS75wRwqd7Dn0nK" } } 4000_0000_0000_0069 { error: { message: "Your card has expired.", type: "card_error", param: "exp_month", code: "expired_card", charge: "ch_1AkHzHK3cnS75wRwCXa8FqGw" } } 4000_0000_0000_0119 { error: { message: "An error occurred while processing your card. Try again in a little bit.", type: "card_error", code: "processing_error", charge: "ch_1AkHzaK3cnS75wRwRmIoqq1i" } } 4242_4242_4242_4241 { error: { message: "Your card number is incorrect.", type: "card_error", param: "number", code: "incorrect_number" } } -
briankung revised this gist
Jul 7, 2017 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -177,7 +177,7 @@ Stripe::Charge.create( :description => "Charge for early payment to subscription" ) # Create equivalent coupon coupon = Stripe::Coupon.create( :amount_off => early_payment_amount, @@ -186,6 +186,8 @@ coupon = Stripe::Coupon.create( :id => "ONETIME#{early_payment_amount}OFF" ) # Apply coupon to subscription via coupon subscription = Stripe::Subscription.retrieve("sub_Aydt4F9jHlfI1a") subscription.coupon = coupon.id -
briankung revised this gist
Jul 7, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -162,7 +162,7 @@ Stripe::Charge.create( #=> Stripe::CardError: (Status 402) (Request req_Az0QuH7K9P0XC6) Your card was declined. ``` ## Pay Early / Some now, some later ```ruby # Accept early payment -
briankung revised this gist
Jul 7, 2017 . 1 changed file with 30 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -160,4 +160,34 @@ Stripe::Charge.create( ) #=> Stripe::CardError: (Status 402) (Request req_Az0QuH7K9P0XC6) Your card was declined. ``` ## Pay Early ```ruby # Accept early payment early_payment_amount = 2000 Stripe::Charge.create( :amount => early_payment_amount, :currency => "usd", :capture => false, :source => "tok_visa", :description => "Charge for early payment to subscription" ) # Apply equivalent discount coupon = Stripe::Coupon.create( :amount_off => early_payment_amount, :currency => 'USD', :duration => 'once', :id => "ONETIME#{early_payment_amount}OFF" ) subscription = Stripe::Subscription.retrieve("sub_Aydt4F9jHlfI1a") subscription.coupon = coupon.id subscription.save ``` -
briankung revised this gist
Jul 7, 2017 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -147,3 +147,17 @@ Stripe::Subscription.create( :coupon => "25OFF" ) ``` ## Unauthorized Charges ```ruby Stripe::Charge.create( :amount => 2000, :currency => "usd", :capture => false, :source => "tok_chargeDeclined", :description => "Charge for aubrey.anderson@example.com" ) #=> Stripe::CardError: (Status 402) (Request req_Az0QuH7K9P0XC6) Your card was declined. ``` -
briankung revised this gist
Jul 7, 2017 . 1 changed file with 9 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ https://stripe.com/docs/api/ruby#create_customer ```ruby require "stripe" Stripe.api_key = "sk_test_hExNrRPAXSQNiQjGdp5AXu8y" @@ -30,7 +30,7 @@ Ruby: https://stripe.com/docs/api#create_source ```ruby require "stripe" Stripe.api_key = "sk_test_hExNrRPAXSQNiQjGdp5AXu8y" @@ -63,7 +63,7 @@ customer.sources.create( https://stripe.com/docs/api#create_charge ```ruby Stripe::Charge.create( :amount => 2000, :currency => "usd", @@ -74,7 +74,7 @@ Stripe::Charge.create( ## ...without capturing funds ```ruby Stripe::Charge.create( :amount => 2000, :currency => "usd", @@ -86,7 +86,7 @@ Stripe::Charge.create( Then capture with: ```ruby ch = Stripe::Charge.retrieve("ch_1Acfm8K3cnS75wRwzYmREQKL") ch.capture ``` @@ -97,7 +97,7 @@ Create a plan https://stripe.com/docs/api#create_plan ```ruby Stripe::Plan.create( :amount => 5000, :interval => "month", @@ -113,8 +113,7 @@ https://stripe.com/docs/api#create_subscription Requires a customer and a plan. ```ruby Stripe::Subscription.create( :customer => "cus_AyZ0IsC62Eng98", :plan => "Test Plan 01" @@ -129,7 +128,7 @@ Create a Coupon https://stripe.com/docs/api#create_coupon ```ruby Stripe::Coupon.create( :amount_off => 2500, :currency => 'USD', @@ -141,7 +140,7 @@ Stripe::Coupon.create( Create a Discounted Subscription ```ruby Stripe::Subscription.create( :customer => "cus_AyZ0IsC62Eng98", :plan => "Test Plan 01", -
briankung created this gist
Jul 7, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,150 @@ # Stripe - https://stripe.com/docs - https://stripe.com/docs/api ## Creating a User https://stripe.com/docs/api/ruby#create_customer ``` require "stripe" Stripe.api_key = "sk_test_hExNrRPAXSQNiQjGdp5AXu8y" Stripe::Customer.create # Or... Stripe::Customer.create( :email => "sofia.martin@example.com", :source => "tok_1AcfGbK3cnS75wRw1Dp7Efwq" # Payment source if one exists ) ``` ## Adding a Payment Method - [Checkout](https://stripe.com/checkout) - Premade checkout form - [Elements](https://stripe.com/docs/elements) - composable checkout form elements - [SDK](https://stripe.com/docs/api/ruby) (Ruby) Ruby: https://stripe.com/docs/api#create_source ``` require "stripe" Stripe.api_key = "sk_test_hExNrRPAXSQNiQjGdp5AXu8y" Stripe::Source.create( :type => "card", :amount => 1000, :currency => 'usd', :owner => { :email => 'jenny.rosen@example.com', }, ) # Or... customer = Stripe::Customer.retrieve("cus_AyZ0IsC62Eng98") customer.sources.create(source: "tok_1AcfGbK3cnS75wRw1Dp7Efwq") # Or... customer.sources.create( :object => 'card', :exp_month => 8, :exp_year => 2018, :number => 4111_1111_1111_1111 ) ``` ## Creating a single charge https://stripe.com/docs/api#create_charge ``` Stripe::Charge.create( :amount => 2000, :currency => "usd", :source => "tok_1AcfGbK3cnS75wRw1Dp7Efwq", # Payment source or customer required :description => "Charge for aubrey.anderson@example.com" ) ``` ## ...without capturing funds ``` Stripe::Charge.create( :amount => 2000, :currency => "usd", :capture => false, # Defaults to true :source => "tok_1AcfGbK3cnS75wRw1Dp7Efwq", # Payment source or customer required :description => "Charge for aubrey.anderson@example.com" ) ``` Then capture with: ``` ch = Stripe::Charge.retrieve("ch_1Acfm8K3cnS75wRwzYmREQKL") ch.capture ``` ## Creating a recurring charge Create a plan https://stripe.com/docs/api#create_plan ``` Stripe::Plan.create( :amount => 5000, :interval => "month", :name => "Silver beginner", :currency => "usd", :id => "silver-beginner" ) ``` Create a subscription: https://stripe.com/docs/api#create_subscription Requires a customer and a plan. ``` Stripe::Subscription.create( :customer => "cus_AyZ0IsC62Eng98", :plan => "Test Plan 01" ) ``` ## ...with discounts A Discount is the application of a Coupon to a Subscription or a Charge. Create a Coupon https://stripe.com/docs/api#create_coupon ``` Stripe::Coupon.create( :amount_off => 2500, :currency => 'USD', :duration => 'repeating', :duration_in_months => 3, :id => '25OFF' ) ``` Create a Discounted Subscription ``` Stripe::Subscription.create( :customer => "cus_AyZ0IsC62Eng98", :plan => "Test Plan 01", :coupon => "25OFF" ) ```