Stripe.net - 尝试代充

Stripe.net - Try to charge on behalf

我尝试用Stripe代人收费。我成功地完成了连接部分,但之后我尝试创建一个 token/charge 但它不起作用。

关于代码中使用的参数的一些信息:

这是我的代码:

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。”错误。

几件事:

由于您使用的是 Stripe Connect,因此您只能使用 Stripe.js 或 Stripe Checkout 创建令牌,您的服务器永远无法访问卡信息。另外我不知道为什么要将令牌的 customerId 设置为客户 ID,客户不是客户。

此外,API 密钥应该是您的 API 密钥,因为您使用的是 Stripe 帐户 header,选项是(您的 API 密钥和已连接帐户的帐户 ID)或(访问令牌)。这在 Stripe Connect documentation.

的身份验证部分进行了讨论