admin管理员组文章数量:1134246
I am currently working on the proof of concept project where I need to use Stripe's Connect direct charge function to charge a connected account when a payment is made. I do not have much experience with payment gateways, but I managed to set up a connection between my Stripe account and application and successfully received payments. However, I am struggling to implement the direct charge function.
I have followed this documentation, where I am using the Stripe-hosted page to charge the customer. However, when I click the button which should be taking me to the hosted page, nothing happens, and I get a blank screen on my solution.
This is the one direct charge which is not working and giving me a blank screen.
var options = new Stripe.Checkout.SessionCreateOptions
{
LineItems = new List<Stripe.Checkout.SessionLineItemOptions>
{
new Stripe.Checkout.SessionLineItemOptions
{
PriceData = new Stripe.Checkout.SessionLineItemPriceDataOptions
{
Currency = "gbp",
ProductData = new Stripe.Checkout.SessionLineItemPriceDataProductDataOptions
{
Name = "T-shirt",
},
UnitAmount = 1000,
},
Quantity = 1,
},
},
PaymentIntentData = new Stripe.Checkout.SessionPaymentIntentDataOptions
{
ApplicationFeeAmount = 123,
},
Mode = "payment",
SuccessUrl = "={CHECKOUT_SESSION_ID}",
};
var requestOptions = new RequestOptions
{
StripeAccount = "ACCOUNTID",
};
var service = new Stripe.Checkout.SessionService();
service.Create(options, requestOptions);
return new StatusCodeResult(303);
This code that I have works perfectly with no issues. Takes me to the Stripe-hosted payment page
public IActionResult CheckOut(ProductViewModel product)
{
var domain = "http://localhost:5184/";
var options = new Stripe.Checkout.SessionCreateOptions
{
SuccessUrl = domain + $"CheckOut/Confirm",
CancelUrl = domain + $"CheckOut/Cancel",
LineItems = new List<Stripe.Checkout.SessionLineItemOptions>
{
new Stripe.Checkout.SessionLineItemOptions
{
PriceData = new Stripe.Checkout.SessionLineItemPriceDataOptions
{
Currency = "gbp",
ProductData = new Stripe.Checkout.SessionLineItemPriceDataProductDataOptions
{
Name = "T-shirt",
},
UnitAmount = 1000,
},
Quantity = 1,
},
},
Mode = "payment"
};
var service = new Stripe.Checkout.SessionService();
Stripe.Checkout.Session session = service.Create(options);
Response.Headers.Add("Location", session.Url);
return new StatusCodeResult(303);
}
I am currently working on the proof of concept project where I need to use Stripe's Connect direct charge function to charge a connected account when a payment is made. I do not have much experience with payment gateways, but I managed to set up a connection between my Stripe account and application and successfully received payments. However, I am struggling to implement the direct charge function.
I have followed this documentation, where I am using the Stripe-hosted page to charge the customer. However, when I click the button which should be taking me to the hosted page, nothing happens, and I get a blank screen on my solution.
This is the one direct charge which is not working and giving me a blank screen.
var options = new Stripe.Checkout.SessionCreateOptions
{
LineItems = new List<Stripe.Checkout.SessionLineItemOptions>
{
new Stripe.Checkout.SessionLineItemOptions
{
PriceData = new Stripe.Checkout.SessionLineItemPriceDataOptions
{
Currency = "gbp",
ProductData = new Stripe.Checkout.SessionLineItemPriceDataProductDataOptions
{
Name = "T-shirt",
},
UnitAmount = 1000,
},
Quantity = 1,
},
},
PaymentIntentData = new Stripe.Checkout.SessionPaymentIntentDataOptions
{
ApplicationFeeAmount = 123,
},
Mode = "payment",
SuccessUrl = "https://example.com/success?session_id={CHECKOUT_SESSION_ID}",
};
var requestOptions = new RequestOptions
{
StripeAccount = "ACCOUNTID",
};
var service = new Stripe.Checkout.SessionService();
service.Create(options, requestOptions);
return new StatusCodeResult(303);
This code that I have works perfectly with no issues. Takes me to the Stripe-hosted payment page
public IActionResult CheckOut(ProductViewModel product)
{
var domain = "http://localhost:5184/";
var options = new Stripe.Checkout.SessionCreateOptions
{
SuccessUrl = domain + $"CheckOut/Confirm",
CancelUrl = domain + $"CheckOut/Cancel",
LineItems = new List<Stripe.Checkout.SessionLineItemOptions>
{
new Stripe.Checkout.SessionLineItemOptions
{
PriceData = new Stripe.Checkout.SessionLineItemPriceDataOptions
{
Currency = "gbp",
ProductData = new Stripe.Checkout.SessionLineItemPriceDataProductDataOptions
{
Name = "T-shirt",
},
UnitAmount = 1000,
},
Quantity = 1,
},
},
Mode = "payment"
};
var service = new Stripe.Checkout.SessionService();
Stripe.Checkout.Session session = service.Create(options);
Response.Headers.Add("Location", session.Url);
return new StatusCodeResult(303);
}
Share
Improve this question
edited Jan 8 at 4:51
marc_s
754k183 gold badges1.4k silver badges1.5k bronze badges
asked Jan 7 at 21:46
Abdullah ErgunAbdullah Ergun
112 bronze badges
1 Answer
Reset to default 0I found the solution. I needed to add at the end of the code.
Response.Headers.Add("Location", session.Url);
本文标签: cStripe Connect Direct Charges in ASPNET MVCStack Overflow
版权声明:本文标题:c# - Stripe Connect Direct Charges in ASP.NET MVC - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736772822a1952179.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论