“ ChargeCreateOptions”不包含“ SourceId”的定义

时间:2019-06-09 15:12:47

标签: stripe-payments

我使用Stripe v27。当我向ChargeCreateOptions添加选项时,它有一个错误:

  

'ChargeCreateOptions'不包含'SourceId'的定义

这是我的代码段:

public IActionResult Processing(StripePaymentRequest paymentRequest)
    {
        Dictionary<string, string> Metadata = new Dictionary<string, string>();
        Metadata.Add("Product", "RubberDuck");
        Metadata.Add("Quantity", "10");
        var options = new ChargeCreateOptions
        {
            Amount = 100,
            Currency = "USD",
            Description = "Buying 10 rubber ducks",
            SourceId = paymentRequest.tokenId,
            Metadata = Metadata
        };
        var service = new ChargeService();
        Charge charge = service.Create(options);
        return Json(charge);
    }

1 个答案:

答案 0 :(得分:2)

看着图书馆的source codeSourceId在v27中变成了Source。尝试使用Source = paymentRequest.tokenId代替SourceId

    var options = new ChargeCreateOptions
    {
        Amount = 123,
        Currency = "usd",
        Source = "tok_visa",
    };