#sagar_code
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1217537081346359459
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi, can you share the request id where you only see the card payment?
here is my payment intent created
const paymentIntent = await stripe.paymentIntents.create({
amount: amount,
currency: "sek",
payment_method_types: ['card','swish','klarna'],
// automatic_payment_methods: {enabled: true, allow_redirects: "never"},
customer: customer.id,
receipt_email: user.email,
confirm: true,
transfer_group: booking,
use_stripe_sdk:true,
// payment_method_data: {
// type: 'swish',
// },
return_url: foodarna,
});
req_xik9TEZZKj2q15
I think the issue is that the customer need to be located in Sweden for Swish https://docs.stripe.com/payments/swish and for Klarna: https://docs.stripe.com/payments/klarna we list the customer location. We look at the IP address for location and surface the payment methods supported by looking at the currency as well. What is the customer location here?
we are currently using the test mode of payment and the simulator location is set to sweden.
can you guides us for creating the payment intents
what should be in the payment intent object if
payment_method_types: ['card','swish','klarna'],
and what should be
payment_method_data
return_url
considering the types as card ,swish,klarna at once.
Yeah, that is surprising that the payment sheet is only showing cards. Trying to think of what may be happening here. Can you show me your code for setting up your payment sheet once the intent has been created?
Sure
const paymentIntent = await stripe.paymentIntents.create({
amount: amount,
currency: "sek",
payment_method_types: ['card','swish','klarna'],
// automatic_payment_methods: {enabled: true, allow_redirects: "never"},
customer: customer.id,
receipt_email: user.email,
confirm: true,
transfer_group: booking,
use_stripe_sdk:true,
// payment_method_data: {
// type: 'swish',
// },
return_url: cravioz,
});
return {
paymentIntentId: paymentIntent.id,
paymentIntentClientSecret: paymentIntent.client_secret,
ephemeralKey: ephemeralKey.secret,
customer: customer.id,
publishableKey: process.env.STRIPE_PUBLISHABLE_KEY
}
Gotcha and what is your client side code for initiating the sheet?
client side code
STPAPIClient.shared.publishableKey = self.objOrderProject.objOrderProductStripeUserModel?.data?.publishableKey ?? ""
// MARK: Create a PaymentSheet instance
var configuration = PaymentSheet.Configuration()
configuration.merchantDisplayName = "Foodarna"
configuration.customer = .init(id: self.objOrderProject.objOrderProductStripeUserModel?.data?.customer ?? "", ephemeralKeySecret: self.objOrderProject.objOrderProductStripeUserModel?.data?.ephemeralKey ?? "")
// Set allowsDelayedPaymentMethods to true if your business can handle payment
// methods that complete payment after a delay, like SEPA Debit and Sofort.
configuration.allowsDelayedPaymentMethods = true
self.paymentSheet = PaymentSheet(paymentIntentClientSecret: self.objOrderProject.objOrderProductStripeUserModel?.data?.paymentIntentClientSecret ?? "", configuration: configuration)
self.paymentSheet?.present(from: self) { paymentResult in
// MARK: Handle the payment result
switch paymentResult {
case .completed:
print("Your order is confirmed")
case .canceled:
print("Canceled!")
case .failed(let error):
print("Payment failed: \(error)")
}
}
Thank you, looking in to what may be causing this
๐
Strangely I am getting these payment methods ot show up properly with very similar code.
What version of stripe-ios are you using? I think support for these payment methods was added in specific versions
can you share the server side and client side code
that will be much helpful
My parameters for the payment intent are:
amount: 1099,
currency: 'sek',
payment_method_types: [
'card',
'swish',
'klarna'
],
on_behalf_of: 'acct_1OtxBjR3L23i9uRi',
customer: 'cus_123'
}```
For the payment sheet I am just passing in
merchantDisplayName: 'Company name',
allowsDelayedPaymentMethods: true,
customerEphemeralKeySecret: 'ephkey_45678```
Can you try this again in your app and print out the payment intent ID before you send the client secret to your app? I am wondering if a PI that only has cards is somehow getting used instead