#nishp77
1 messages · Page 1 of 1 (latest)
Hey there
What do you mean exactly by "paymentOptionButton"?
You are having an issue presenting the Payment Sheet?
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
Okay so it looks like you are trying to use FlowController
But I don't see any paymentSheetFlowController.presentPaymentOptions call in your code?
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) }
}
Okay just dumping a bunch of code isn't really going to help.
Let's back up
Are you seeing a specific error?
Okay so then you need to look at your logic specifically for what is needed to show your button, right?
I tried but not understanding why? because If replace with example code it does show up
Well what is the difference between your code and the example code?
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
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?
I did that and I do get the secrets
Okay so what is the specific conditional statement for whether the button will show vs "loading"?
@State var isConfirmingPayment = false
Great so did you print isConfirmingPayment prior to that statement?
Bismarck thank you though, I don't think it's stripe issue