[英]Stripe - How to get billing address information in Checkout.Session
我正在尝试通过 Webhook 调用从 Stripe Checkout 获取账单地址。
我想要实现的是从黄色矩形中的表单中获取信息。
这是我的结帐配置:
var options = new SessionCreateOptions()
{
CustomerEmail = user.Email,
BillingAddressCollection = "required",
ShippingAddressCollection = new SessionShippingAddressCollectionOptions
{
AllowedCountries = new List<string>
{
"FR",
},
},
PaymentMethodTypes = new List<string>() {
result.Payment.Type
},
LineItems = new List<SessionLineItemOptions>{
new SessionLineItemOptions
{
PriceData = new SessionLineItemPriceDataOptions
{
UnitAmountDecimal = result.Payment.Amount * 100,
Currency = result.Payment.Currency,
ProductData = new SessionLineItemPriceDataProductDataOptions
{
Name = _stringLocalizer.GetString("StripeProductLabel"),
},
},
Quantity = 1,
},
},
Mode = result.Payment.Mode,
SuccessUrl = $"{request.Scheme}://{request.Host}" + "/payment/complete",
CancelUrl = $"{request.Scheme}://{request.Host}" + "/payment/cancel",
Metadata = new Dictionary<string, string>()
{
{ Constants.StripeMetaDataOrderId, result.Id }
}
};
and when I receive the session objet in the completed event: session = stripeEvent.Data.Object as Stripe.Checkout.Session;
我无法获取信息,因为 paymentIntent object 是 null (信息来自: Retrieve Billing Address from Stripe checkout session? )。
这是 Sripe 的一个重要功能,因为该应用程序是一个 B2B 应用程序,可帮助专业人士为其 B2C 业务创建订单。 它将避免从 Stripe API 中退出的东西制作自定义代码:)
提前致谢
您链接到的答案是从payment_method
上的payment_intent
获取此信息的正确方法。 我不确定如何/为什么不会填充您的payment_intent
值,因为我的测试表明这将在创建 session 时进行初始化,即使我从未重定向到它。
您确定您正在创建mode=payment
session? 我在您共享的代码中看到了这一点,但是如果您实际上是在进行setup
或subscription
模式,情况会有所改变。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.