我在哪里可以获得 Stripe 中客户创建的 SourceToken?
Where can I get the SourceToken for the customer creation in Stripe?
我在哪里可以获得 Stripe 中创建客户的 SourceToken?
这是使用 SourceToken
:
的代码示例
if (Request.Form["stripeToken"] != null) {
var customers = new CustomerService();
var charges = new ChargeService();
var customer = customers.Create(new CustomerCreateOptions {
Email = Request.Form["stripeEmail"],
SourceToken = Request.Form["stripeToken"]
});
var charge = charges.Create(new ChargeCreateOptions {
Amount = 500,
Description = "Sample Charge",
Currency = "usd",
CustomerId = customer.Id
});
Console.WriteLine(charge);
}
这个 json
中的 SourceToken
是什么?
{
"id": "tok_1EL43MKfPgrABB02rh7IGG7l",
"object": "token",
"card": {
"id": "card_1EL43MKfPgrABB02yFgReMXc",
"object": "card",
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"cvc_check": "pass",
"dynamic_last4": null,
"exp_month": 12,
"exp_year": 2020,
"funding": "credit",
"last4": "4242",
"metadata": {},
"name": "foo@gmail.com",
"tokenization_method": null
},
"client_ip": "194.44.142.6",
"created": 1554278556,
"email": "foo@gmail.com",
"livemode": false,
"type": "card",
"used": false
}
这是我如何得到 json:
var stripe = Stripe('pk_test_ob6s7KZxZU1mouJbbsuFBjEe');
var handler = StripeCheckout.configure({
key: 'pk_test_ob6s7KZxZU1mouJbbsuFBjEe',
token: function(token, args) {
var stop = 0;
}
});
document.getElementById('myBtn').addEventListener('click', function(e) {
// Open Checkout with further options
handler.open({
name: 'Demo Site',
description: '2 widgets (.00)',
amount: 2000
});
e.preventDefault();
});
在线 var stop = 0;
。
例子取自here.
谢谢。
那个JSON里面的SourceToken是"tok_1EL43MKfPgrABB02rh7IGG7l"
。
创建客户并附加源(例如该令牌)后,您可以 retrieve the customer 这将包括该客户的源(它们将列在 sources
对象中 customer
记录).
令牌本身在源和客户的创建过程中被消耗,结果是一个可重复使用的源。
我在哪里可以获得 Stripe 中创建客户的 SourceToken?
这是使用 SourceToken
:
if (Request.Form["stripeToken"] != null) {
var customers = new CustomerService();
var charges = new ChargeService();
var customer = customers.Create(new CustomerCreateOptions {
Email = Request.Form["stripeEmail"],
SourceToken = Request.Form["stripeToken"]
});
var charge = charges.Create(new ChargeCreateOptions {
Amount = 500,
Description = "Sample Charge",
Currency = "usd",
CustomerId = customer.Id
});
Console.WriteLine(charge);
}
这个 json
中的 SourceToken
是什么?
{
"id": "tok_1EL43MKfPgrABB02rh7IGG7l",
"object": "token",
"card": {
"id": "card_1EL43MKfPgrABB02yFgReMXc",
"object": "card",
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"cvc_check": "pass",
"dynamic_last4": null,
"exp_month": 12,
"exp_year": 2020,
"funding": "credit",
"last4": "4242",
"metadata": {},
"name": "foo@gmail.com",
"tokenization_method": null
},
"client_ip": "194.44.142.6",
"created": 1554278556,
"email": "foo@gmail.com",
"livemode": false,
"type": "card",
"used": false
}
这是我如何得到 json:
var stripe = Stripe('pk_test_ob6s7KZxZU1mouJbbsuFBjEe');
var handler = StripeCheckout.configure({
key: 'pk_test_ob6s7KZxZU1mouJbbsuFBjEe',
token: function(token, args) {
var stop = 0;
}
});
document.getElementById('myBtn').addEventListener('click', function(e) {
// Open Checkout with further options
handler.open({
name: 'Demo Site',
description: '2 widgets (.00)',
amount: 2000
});
e.preventDefault();
});
在线 var stop = 0;
。
例子取自here.
谢谢。
那个JSON里面的SourceToken是"tok_1EL43MKfPgrABB02rh7IGG7l"
。
创建客户并附加源(例如该令牌)后,您可以 retrieve the customer 这将包括该客户的源(它们将列在 sources
对象中 customer
记录).
令牌本身在源和客户的创建过程中被消耗,结果是一个可重复使用的源。