我尝试使用 Stripe 代表某人收费。我成功完成了连接部分,但之后我尝试创建一个令牌/费用,但它不起作用。
有关代码中使用的参数的一些信息:
- “acct_158fBBAOizDDfp9B” - 从 Connect 用户处获取;
- WebConfig.AppSettings.StripeClientId - 我的客户端 ID 从 Stripe 仪表板获取;
- WebConfig.AppSettings.StripeSecretApiKey - 我的 Stripe Secret API 密钥;
- “sk_test_5E9d7UHs9CVa3Ansop2JzIxI” - 从 Connect 用户获取私有 API 密钥。
这是我的代码:
StripeRequestOptions requestOptions = new StripeRequestOptions();
requestOptions.StripeConnectAccountId = "acct_158fBBAOizDDfp9B";
var myToken = new StripeTokenCreateOptions();
myToken.Card = new StripeCreditCardOptions()
{
// set these properties if passing full card details (do not
// set these properties if you set TokenId)
Number = "4242424242424242",
ExpirationYear = "2022",
ExpirationMonth = "10",
AddressCountry = "US", // optional
AddressLine1 = "24 Beef Flank St", // optional
AddressLine2 = "Apt 24", // optional
AddressCity = "Biggie Smalls", // optional
AddressState = "NC", // optional
AddressZip = "27617", // optional
Name = "Joe Meatballs", // optional
Cvc = "1223" // optional
};
// set this property if using a customer (stripe connect only)
myToken.CustomerId = WebConfig.AppSettings.StripeClientId; // My client ID get from Stripe dashboard.
//var tokenService = new StripeTokenService(WebConfig.AppSettings.StripeSecretApiKey);
var tokenService = new StripeTokenService("sk_test_5E9d7UHs9CVa3Ansop2JzIxI");
StripeToken stripeToken = tokenService.Create(myToken, requestOptions);
我有一个«您必须为此客户传递一个有效的卡 ID。“ 错误。