#cptnstabbin_api
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/1308205977547309168
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Failed to create or confirm PaymentIntent: networkError(Agora.PaymentError.paymentFailed("{"error":"You cannot confirm this PaymentIntent because it's missing a payment method. You can either update the PaymentIntent with a payment method and then confirm it again, or confirm it again directly with a payment method or ConfirmationToken."}"))
Failed to start payment flow: The operation couldnโt be completed. (Agora.PaymentError error 0.)
Hi, let me help you with this.
aw thanks
Could you please share the code that you use to confirm the PaymentIntent?
Are you following any docs?
Hello! So you're specificially following these steps, correct? https://docs.stripe.com/apple-pay?platform=ios#accept
What specific step are you stuck on exactly?
paymentMethodType and paymentMethodID
in those two files.. it's incorrect in one or both i think
func applePayContext(_ context: STPApplePayContext, didCreatePaymentMethod paymentMethod: STPPaymentMethod, paymentInformation: PKPayment, completion: @escaping STPIntentClientSecretCompletionBlock) {
Task {
do {
print("๐ค Creating payment intent...")
let paymentMethodType = "card"
let clientSecret = try await paymentService.createPaymentIntent(
amount: 150.00,
paymentMethodId: paymentMethod.stripeId,
currency: "RON" ,
paymentMethodType: "card"
)
Not sure what you mean by "those two files"? Is everything in Step 7 working correctly? https://docs.stripe.com/apple-pay?platform=ios#present-payment-sheet
the two files i attached on the thread. my code
I see. What about Step 7? Are you seeing the Apple Pay payment sheet in your app?
yes im only stuck on the last stept - processing, failed
haptics work too
i can make requests to the stripe API just fine
{
"amount": "15000",
"confirm": "true",
"confirmation_method": "automatic",
"currency": "RON",
"payment_method_types": {
"0": "card"
}
}
if you can see the payment_method_type shows as 0
Can you confirm you're passing the expected clientSecret to the completion function as shown here? https://docs.stripe.com/apple-pay?platform=ios#client-side
Right, but what I'm asking you to do is confirm several things.
First, does the clientSecret in your app contain the expected value?
Second, are those methods running (like is your code actually calling completion() with the required arguments)?
let confirmationSuccess = try await paymentService.confirmPayment(paymentIntentId: clientSecret)
if confirmationSuccess {
print("โ
Payment successful!")
self.completion?(true, nil)
completion(clientSecret, nil)
} else {
print("โ Payment confirmation failed")
self.completion?(false, NSError(domain: "PaymentHandler", code: 0, userInfo: [NSLocalizedDescriptionKey: "Payment confirmation failed"]))
completion(nil, NSError(domain: "PaymentHandler", code: 0, userInfo: [NSLocalizedDescriptionKey: "Payment confirmation failed"]))
}
} catch {
i .. think so?
I can't run or debug your code. You need to do this on your end.
my asnwer to your questions
You need to log the value of clientSecret, or inspect it at runtime with the debugger.
You also need to do the same to make sure that code is running.
can you tell me if this is correct? // no idea if this is correct:
let body: [String: Any] = [
"amount": Int(amount * 100),
"currency": currency,
"paymentMethodID": paymentMethodId,
"paymentMethodType": paymentMethodType,
"description": "Spa entry Payment"
]
I don't have enough context to tell you if that's correct or not.
Why did you write that code? Does that part of the code work or does it throw an error? What are the values in the variables there at runtime?
yes it's throwing an error look :
Creating payment intent...
Creating payment intent for amount: 150.0 with payment method: pm_1QMdpjHmraaeZpryiY280MGZ
๐ค Request body: ["currency": "RON", "paymentMethodType": "card", "description": "Spa entry Payment", "paymentMethodID": "pm_1QMdpjHmraaeZpryiY280MGZ", "amount": 15000]
๐ค Sending request to server...
๐ฅ Response status code: 500
โ Error response body: {"error":"You cannot confirm this PaymentIntent because it's missing a payment method
this is my console
this is where im stuck
What specific line of code is throwing the Error response body: {"error":"You cannot confirm this PaymentIntent because it's missing a payment method error?
and im not receiving the secret - it would be in the logs there
Is that 500 coming from your server when you try to fetch the client secret?
Okay, so you'll need to figure out why that's happening and fix it before you can proceed.
oik
i think i progressed somehow
now it just says Error details: {
message: 'Invalid API Key provided: your_str**********_key',
is this good?
it did receive thye secret now
Seems like your app is trying to call a /confirm-payment endpoint on your server which doesn't exist.
so everything is working, it's just trying to confirm and im not listening? so the payment fails?
It doesn't seem like everything is working based on the screenshot you shared.
so what should I do @languid vector , confirm payment intent on my server?
That's up to you. What's your goal? Do you want to confirm client-side or server-side?
whats better
I can't tell you what's better for your business/situation/integration. It sounds like you're going down the server-side confirmation path. Why did you choose that path?
i hace no idea what im doing
Okay, let's back up. What is your high-level goal? What are you trying to build?
spa admission in an ios app
What is "spa"?
a spa
Is that an acronym or are you talking about a place with baths?
a place with baths and saunasa and interior pool. a hotel resort
Okay, so people use an iOS app to pay to get access to a spa?
yesss
Okay, so is there a specific reason you want to confirm payments on your server instead of the client (inside the iOS app)?
Neither is safer than the other.
If you don't have a specific reason you should confirm client-side, it's easier and simpler.
the code on my server is shorter and it's easier to add to that instead of my clinent side code
but im happy to do the simpler way
I recommend you set your current approach aside and follow this guide: https://docs.stripe.com/payments/accept-a-payment?platform=ios&uikit-swiftui=uikit
Make sure you also complete the steps in the Enable Apple Pay section: https://docs.stripe.com/payments/accept-a-payment?platform=ios&uikit-swiftui=uikit#ios-apple-pay