Skip to content

Instantly share code, notes, and snippets.

@brandoncordell
Last active December 25, 2015 12:39
Show Gist options
  • Save brandoncordell/6977761 to your computer and use it in GitHub Desktop.
Save brandoncordell/6977761 to your computer and use it in GitHub Desktop.
# Buyer's credit card was created in JS using OUR publishable key (as the docs say this is ok if you're sharing customers)... I think
@item = Item.find(1)
#<Item id: 1, user_id: 1, category_id: 1, status: "buy_it_now", name: "Time Traveling DeLoreanzz", description: "Lorem ipsum dolor sit amet, consectetuer adipiscing...", content: "Lorem ipsum dolor sit amet, consectetuer adipiscing...", price: #<BigDecimal:7f88b5f80a08,'0.15E6',9(18)>, reserve: #<BigDecimal:7f88b5f80990,'0.149E6',9(18)>, shipping: nil, is_shippable: false, is_featured: false, created_at: "2013-08-30 14:41:55", updated_at: "2013-10-09 15:22:57", auction_id: 1, buy_it_now_price: #<BigDecimal:7f88b5f80828,'0.15E6',9(18)>, accepted_credit_amount: 0, slug: "time-traveling-deloreanzz", deleted_at: nil, buyer_responsible_for_shipping: false, payment_status: "paid">
@seller = User.find(1)
#<User id: 1, email: "[email protected]", encrypted_password: "$2a$10$2knLYeWdDmkJA4l.UOa2nO4qYt3gfQ89ekibN/fGk/Xy...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 16, current_sign_in_at: "2013-10-04 17:54:35", last_sign_in_at: "2013-09-23 12:55:34", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", confirmation_token: nil, confirmed_at: "2013-08-20 14:43:55", confirmation_sent_at: "2013-08-20 14:43:46", unconfirmed_email: nil, created_at: "2013-08-20 14:43:46", updated_at: "2013-10-04 17:54:35", stripe_id: "cus_2Q6uuObrEhjSBC", provider: "stripe_connect", uid: "acct_2PmHSAv3txCIIkAqCLNr", token: "sk_test_9fRgp5VmlBWPbWZWCjYHNjLU", deleted_at: nil, access_token: nil>
@buyer = User.find(4)
#<User id: 4, email: "[email protected]", encrypted_password: "$2a$10$OSKAlCmDFCCeOb8sbbZMpOGHUNNmfyeKGe.r2M/J6QbC...", reset_password_token: "014748f488939252f254b6ba66025e83bd2a3df7f83b46a02de...", reset_password_sent_at: "2013-09-20 18:21:45", remember_created_at: nil, sign_in_count: 3, current_sign_in_at: "2013-10-14 14:16:18", last_sign_in_at: "2013-10-11 20:39:57", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", confirmation_token: nil, confirmed_at: "2013-09-09 18:44:43", confirmation_sent_at: "2013-09-09 18:44:05", unconfirmed_email: nil, created_at: "2013-09-09 18:44:05", updated_at: "2013-10-14 14:39:03", stripe_id: "cus_2Xf1yPo8FTWz52", provider: "stripe_connect", uid: "acct_2E8oqiveAsKlfRBdumEj", token: "sk_test_1CaKdG1dAXb8KslcL31SCiXw", deleted_at: nil, access_token: nil>
Stripe::Token.create({ customer: @buyer.stripe_id }, @seller.token)
#<Stripe::StripeObject:0x3fc45cf4f08c> JSON: {"id":"tok_2kiXNTyRPVqhcl","livemode":false,"created":1381763863,"used":false,"object":"token","type":"card","card":{"id":"card_2kiXeeGVHKmGiG","object":"card","last4":"4242","type":"Visa","exp_month":1,"exp_year":2014,"fingerprint":"pLBdFRqD0wgWj7pC","customer":"cus_2Xf1yPo8FTWz52","country":"US","name":"Michael Bluth","address_line1":null,"address_line2":null,"address_city":null,"address_state":null,"address_zip":null,"address_country":null}}
Stripe::Charge.create({ currency: :usd, amount: 100 * @item.buy_it_now_price.to_i, description: "Payment for #{@item.name}", customer: 'tok_2kiXNTyRPVqhclb' }, @seller.token)
# Stripe::InvalidRequestError: (Status 400) No such customer: tok_2kiXNTyRPVqhclb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment