#nishp77

1 messages · Page 1 of 1 (latest)

upbeat cometBOT
warm wraith
#

Hey there

#

What do you mean exactly by "paymentOptionButton"?

#

You are having an issue presenting the Payment Sheet?

brazen musk
#

Option that shows apple pay or card, yes payment sheet isn't working with my code but I just made few changes from example in github repo

#

Example code

let backendCheckoutUrl = URL(string: "https://stripe-mobile-payment-sheet.glitch.me/checkout")! // An example backend endpoint
var request = URLRequest(url: backendCheckoutUrl)
request.httpMethod = "POST"
let task = URLSession.shared.dataTask(
with: request,
completionHandler: { (data, _, error) in
guard let data = data,
let json = try? JSONSerialization.jsonObject(with: data, options: [])
as? [String: Any],
let customerId = json["customer"] as? String,
let customerEphemeralKeySecret = json["ephemeralKey"] as? String,
let paymentIntentClientSecret = json["paymentIntent"] as? String,
let publishableKey = json["publishableKey"] as? String
else {
// Handle error
return

warm wraith
#

Okay so it looks like you are trying to use FlowController

#

But I don't see any paymentSheetFlowController.presentPaymentOptions call in your code?

brazen musk
#

This is the view

var body: some View {
VStack {
if let paymentSheetFlowController = model.paymentSheetFlowController {
PaymentSheet.FlowController.PaymentOptionsButton(
paymentSheetFlowController: paymentSheetFlowController,
onSheetDismissed: model.onOptionsCompletion
) {
PaymentOptionView(
paymentOptionDisplayData: paymentSheetFlowController.paymentOption)
}
Button(action: {
// If you need to update the PaymentIntent's amount, you should do it here and
// set the isConfirmingPayment binding after your update completes.
isConfirmingPayment = true
}) {
if isConfirmingPayment {
LoadingView()
} else {
PaymentButtonView()
}
}.paymentConfirmationSheet(
isConfirming: $isConfirmingPayment,
paymentSheetFlowController: paymentSheetFlowController,
onCompletion: model.onCompletion
)
.disabled(paymentSheetFlowController.paymentOption == nil || isConfirmingPayment)
} else {
LoadingView()
}
if let result = model.paymentResult {
PaymentStatusView(result: result)
}
}
.onAppear { model.preparePaymentSheet(amount: 50) }
}

warm wraith
#

Okay just dumping a bunch of code isn't really going to help.

#

Let's back up

#

Are you seeing a specific error?

brazen musk
#

Not really

#

In the view it's showing my loading view

warm wraith
#

Okay so then you need to look at your logic specifically for what is needed to show your button, right?

brazen musk
#

I tried but not understanding why? because If replace with example code it does show up

warm wraith
#

Well what is the difference between your code and the example code?

brazen musk
#

just making a post request, where I'm using appwrite sdk and underneath it's using post request as well

#

It's fine no worries I will try to find

#

Thanks though, sorry for hitting you up

warm wraith
#

Okay so based on what you are saying it sounds like you may not be getting the client secret back from your backend?

#

Have you logged out the dependent variables for your button to show instead of your "loading" to show?

brazen musk
#

I did that and I do get the secrets

warm wraith
#

Okay so what is the specific conditional statement for whether the button will show vs "loading"?

brazen musk
#

@State var isConfirmingPayment = false

warm wraith
#

Great so did you print isConfirmingPayment prior to that statement?

brazen musk
#

Bismarck thank you though, I don't think it's stripe issue

warm wraith
#

Yeah I mean I'm happy to help you debug but I can't do it for you.

#

I'd recommend adding a bunch of logs to your code to pinpoint exactly where the issue is.