#cptnstabbin_api

1 messages ยท Page 1 of 1 (latest)

hollow latchBOT
#

๐Ÿ‘‹ 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.

jolly lintel
#

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.)

native acorn
#

Hi, let me help you with this.

jolly lintel
#

aw thanks

native acorn
#

Could you please share the code that you use to confirm the PaymentIntent?

jolly lintel
native acorn
#

Are you following any docs?

jolly lintel
#

yes

#

im sorry im not very good at this

hollow latchBOT
jolly lintel
#

im following this

#

im having an issue with paymentMethodType

languid vector
jolly lintel
#

doing my best

#

it's almost working..

languid vector
#

What specific step are you stuck on exactly?

jolly lintel
#

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"
            )
languid vector
jolly lintel
#

the two files i attached on the thread. my code

languid vector
#

I see. What about Step 7? Are you seeing the Apple Pay payment sheet in your app?

jolly lintel
#

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

languid vector
jolly lintel
#

completion: @escaping STPIntentClientSecretCompletionBlock

#

I have this

languid vector
#

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)?

jolly lintel
#

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?

languid vector
#

I can't run or debug your code. You need to do this on your end.

jolly lintel
#

my asnwer to your questions

languid vector
#

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.

jolly lintel
#

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"
]

languid vector
#

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?

jolly lintel
#

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

languid vector
#

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?

jolly lintel
#

and im not receiving the secret - it would be in the logs there

languid vector
#

Okay, so that's likely the issue.

#

Also that 500 status code.

languid vector
#

Is that 500 coming from your server when you try to fetch the client secret?

jolly lintel
#

yesss

#

the server outputs this

languid vector
#

Okay, so you'll need to figure out why that's happening and fix it before you can proceed.

jolly lintel
#

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

languid vector
#

Seems like your app is trying to call a /confirm-payment endpoint on your server which doesn't exist.

jolly lintel
#

so everything is working, it's just trying to confirm and im not listening? so the payment fails?

languid vector
#

It doesn't seem like everything is working based on the screenshot you shared.

jolly lintel
#

so what should I do @languid vector , confirm payment intent on my server?

languid vector
#

That's up to you. What's your goal? Do you want to confirm client-side or server-side?

jolly lintel
#

whats better

languid vector
#

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?

jolly lintel
#

i hace no idea what im doing

languid vector
#

Okay, let's back up. What is your high-level goal? What are you trying to build?

jolly lintel
#

spa admission in an ios app

languid vector
#

What is "spa"?

jolly lintel
#

a spa

languid vector
#

Is that an acronym or are you talking about a place with baths?

jolly lintel
#

a place with baths and saunasa and interior pool. a hotel resort

languid vector
#

Okay, so people use an iOS app to pay to get access to a spa?

jolly lintel
#

yesss

languid vector
#

Okay, so is there a specific reason you want to confirm payments on your server instead of the client (inside the iOS app)?

jolly lintel
#

idk is it "safer"

#

?

languid vector
#

Neither is safer than the other.

#

If you don't have a specific reason you should confirm client-side, it's easier and simpler.

hollow latchBOT
jolly lintel
#

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

languid vector
jolly lintel
#

LOOK

#

DONE

#

SOLVED SORTED