Issue
I'm trying to enable wallet payments like Google Pay and Apple Pay in my Angular application using Stripe.
I'm using connected accounts, the payment is managed by the backend with the PaymentIntent
.
So the flow is the following:
- Transaction created via backend
ClientSecret
is returned to AngularStripePaymentElement
is created with theClientSecret
- Webhook captures
charge.succeed
and completes the order
The issue here is that only Google Pay is working, If I try to open the payment from an apple device, I will be able only to use credit card as payment.
I've registered the domains in the dashboard, but after reading the documentation I've found that I need to create the domains for connected accounts via API.
At this point, when the domain should be created? Should I do it inside the method where I create the transaction in my backend?
The method which creates the transaction looks like this:
private string CreateStripeTransaction(string paymentId, string orderId, string type = "MENU")
{
var keys = GetPaymentKeys(paymentId);
StripeConfiguration.ApiKey = GetStripeKey();
var amount = GetOrderAmount(orderId);
var service = new PaymentIntentService();
var options = new PaymentIntentCreateOptions
{
Amount = amount,
Currency = "eur",
Metadata = new Dictionary<string, string>
{
{ "integration_check", "accept_a_payment" },
{ "OrderId", orderId },
{ "PaymentId", paymentId },
{ "Company", _company },
{ "Type", type }
},
};
var requestOptions = new RequestOptions
{
StripeAccount = keys.publicKey
};
var intent = service.Create(options, requestOptions);
return JsonSerializer.Serialize(new { client_secret = intent.ClientSecret });
}
Then the ClientSecret
is consumed like this:
async initStripe() {
this.stripe = await loadStripe(
environment.STRIPE,
{
stripeAccount: this.publicKey,
}
);
this.paymentService
.createTransaction(this.paymentId, this.orderId, this.type, 'stripe')
.subscribe((data: any) => {
const clientSecret = data.client_secret;
const elements = this.stripe.elements({ clientSecret });
const options: StripePaymentElementOptions = {
layout: "accordion"
};
this.card = elements.create('payment', options);
this.card.mount(this.cardElement.nativeElement);
this.card.on('change', this.cardHandler);
});
}
Solution
Creating the domain only by following the official guide is not enough, after having a talk with stripe support, I've been able to resolve the issue by following these steps:
- Listing all the ApplePay domains for the connected account
- Check if the domain you're trying to activate stripe for is listed
- Delete the domain
- Recreate the domain
Answered By - NiceToMytyuk
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.