#Ronit

1 messages · Page 1 of 1 (latest)

worthy hawkBOT
spare cargo
#

how can i stop payment in Terminal.shared.cancelPaymentIntent(paymentIntent) as this code block shows error in cancel payment

#

error - Could not execute cancelPaymentIntent because the SDK is busy with another command: collectPaymentMethod.

long flower
#

hey there, you can't cancel the payment intent at that point, that seems right

#

but I was under the impression that collectPaymentMethod was a cancelable

spare cargo
#

i cannot find cancelable in this documentation

long flower
#

Declaration

  • (nullable SCPCancelable *)
    collectPaymentMethod:(nonnull SCPPaymentIntent *)paymentIntent
    completion:(nonnull SCPPaymentIntentCompletionBlock)completion;

func collectPaymentMethod(_ paymentIntent: PaymentIntent, completion: @escaping PaymentIntentCompletionBlock) -> SCPCancelable?

#

SCPCancelable

spare cargo
#

i am getting error in this line else if let intent = canceledPaymentIntent {
cancelEvent.result = .succeeded
cancelEvent.object = .paymentIntent(intent)
}

long flower
#

What error? you should be able to .cancel the returned cancelable

#

Or is this inside the event handler?

spare cargo
#

it is inside event handler

long flower
#
collectCancelable?.cancel { cancelError in
                            var cancelEvent = LogEvent(method: .cancelCollectPaymentMethod)
                            if let error = cancelError {
                                cancelEvent.result = .errored
                                cancelEvent.object = .error(error as NSError)
                            } else {
                                cancelEvent.result = .succeeded
                                cancelEvent.object = .paymentIntent(intent)
                            }
                            self.events.append(cancelEvent)
                            self.cancelPaymentIntent(intent: intent)
                        }
spare cargo
#

yes it works i was using something else in self.cancelPaymentIntent(intent: intent)

worthy hawkBOT
spare cargo
#

does can use this code ?
do {
try await DispatchQueue.main.async {
if let cancelable = self.cancelable {
cancelable.cancel()
// Optionally, perform any additional cleanup or handling when canceled
}
}
} catch {
// Handle the error here (if needed)
print("Error canceling payment: (error)")
}

long flower
#

Assuming self.cancelable was from your call to collectPaymentMethod I think that part would be ok, but I'm not an advance ios developer. Not familiar with what you're doing with DispatchQueue for example or if that would affect how this works

spare cargo
#

i will check this dispatchqueue

#

it works i need just wraping in the async function and and then call it from otherside

#

thanks for help