【发布时间】:2019-08-31 18:24:47
【问题描述】:
我正在尝试使用Stripe 和ASP.NET WebForm 进行测试付款。我能够在测试帐户中获得响应,但想做更多的事情。我知道,它已经完成了,但对它来说是新的。我已经在链接的帮助下完成了这项工作 - Stripe Payment
API 响应在我的测试帐户中成功。所以这是我使用教程所做的:
Default.aspx:
<form action="Charge.aspx" method="POST"> //Confused here a bit
<script>
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<%= stripePublishableKey %>"
data-amount="500"
data-name="Stripe.com"
data-description="Sample Charge"
data-locale="auto"
data-zip-code="true">
</script>
</form>
Charge.aspx:
protected void Page_Load(object sender, EventArgs e)
{
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);
}
}
这是响应,我进入我的帐户 - 200 OK POST /v1/tokens。我还尝试使用Stripe 生成的令牌将购买或订单详细信息存储在我的项目数据库中。所以尝试了以下在我的测试帐户中创建订单的方法:
StripeConfiguration.SetApiKey("##########");
var options = new OrderCreateOptions
{
Currency = "usd",
Email = "jenny.rosen@example.com",
Items = new List<OrderItemOptions> {
new OrderItemOptions {
Type = "sku",
Parent = "sku_EqMkslKy9JiXAc",
Quantity = 2,
},
},
Shipping = new ShippingOptions
{
Name = "Jenny Rosen",
Address = new AddressOptions
{
Line1 = "1234 Main Street",
City = "San Francisco",
State = "CA",
PostalCode = "94111",
Country = "US",
},
},
};
var service = new OrderService();
Order order = service.Create(options);
这会在测试帐户中创建一个订单,但带有来自ASP.NET 项目的按钮,因此我无法输入卡号或其他信息以供Stripe 验证。我很想知道我是否可以使用ASP.NET WebForm 结帐并提供所有相关详细信息。
【问题讨论】:
-
有关 Stripe 结账的最新解决方案,请在以下位置测试演示:techtolia.com/Stripe 在 ASP.NET Web 表单中使用 Stripe 从所有卡和多种付款方式接收付款。
标签: c# asp.net webforms stripe-payments