Created
July 21, 2017 11:51
-
-
Save AHEADer/9803ae8d4a5b738c30ac03e0fc91bc88 to your computer and use it in GitHub Desktop.
alipay
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 characters
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 [email protected]" | |
}, { | |
:idempotency_key => "DBkOKacrMsDOgRxG" | |
}) | |
=end | |
a = Stripe::Source.create( | |
:type => "alipay", | |
:amount => 50, | |
:currency => 'usd', | |
:redirect => { | |
:return_url => 'http://www.baidu.com', | |
}, | |
:owner => { | |
:email => '[email protected]', | |
}, | |
) | |
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