Skip to content

Instantly share code, notes, and snippets.

@AHEADer
Created July 21, 2017 11:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AHEADer/9803ae8d4a5b738c30ac03e0fc91bc88 to your computer and use it in GitHub Desktop.
alipay
require "stripe"
# fill your secrete key below
Stripe.api_key = ""
=begin
Stripe::Charge.create({
:amount => 2000,
:currency => "usd",
:source => "tok_1AfmufFvcm7x2qiEmA1KYAgk", # obtained with Stripe.js
:description => "Charge for emily.williams@example.com"
}, {
:idempotency_key => "DBkOKacrMsDOgRxG"
})
=end
a = Stripe::Source.create(
:type => "alipay",
:amount => 50,
:currency => 'usd',
:redirect => {
:return_url => 'http://www.baidu.com',
},
:owner => {
:email => 'development@17cow.com',
},
)
puts a.redirect.url
puts a.id
while TRUE do
source = Stripe::Source.retrieve(a.id)
source.save
if source.status != "pending"
puts source.status
puts "ok"
break
end
end
charge = Stripe::Charge.create({
amount: 50,
currency: 'usd',
source: a.id,
})
# puts charge.capture
puts charge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment