@@ -150,6 +150,7 @@ final class CollectOrderPaymentUseCase: NSObject, CollectOrderPaymentProtocol {
150150 // Inform about the collect payment state
151151 switch result {
152152 case . failure( CollectOrderPaymentUseCaseError . flowCanceledByUser) :
153+ self . rootViewController. presentedViewController? . dismiss ( animated: true )
153154 return onCancel ( )
154155 default :
155156 onCollect ( result. map { _ in ( ) } ) // Transforms Result<CardPresentCapturedPaymentData, Error> to Result<Void, Error>
@@ -271,13 +272,11 @@ private extension CollectOrderPaymentUseCase {
271272 return
272273 }
273274
274- // Show reader ready alert
275- alerts. readerIsReady ( title: Localization . collectPaymentTitle ( username: order. billingAddress? . firstName) ,
276- amount: formattedAmount,
277- onCancel: { [ weak self] in
278- self ? . cancelPayment {
275+ // Show preparing reader alert
276+ alerts. preparingReader ( onCancel: { [ weak self] in
277+ self ? . cancelPayment ( onCompleted: {
279278 onCompletion ( . failure( CollectOrderPaymentUseCaseError . flowCanceledByUser) )
280- }
279+ } )
281280 } )
282281
283282 // Start collect payment process
@@ -288,12 +287,14 @@ private extension CollectOrderPaymentUseCase {
288287 paymentMethodTypes: configuration. paymentMethods. map ( \. rawValue) ,
289288 stripeSmallestCurrencyUnitMultiplier: configuration. stripeSmallestCurrencyUnitMultiplier,
290289 onWaitingForInput: { [ weak self] in
291- // Request card input
292- self ? . alerts. tapOrInsertCard ( onCancel: { [ weak self] in
293- self ? . cancelPayment {
294- onCompletion ( . failure( CollectOrderPaymentUseCaseError . flowCanceledByUser) )
295- }
296- } )
290+ guard let self = self else { return }
291+ self . alerts. readerIsReady ( title: Localization . collectPaymentTitle ( username: self . order. billingAddress? . firstName) ,
292+ amount: self . formattedAmount,
293+ onCancel: { [ weak self] in
294+ self ? . cancelPayment {
295+ onCompletion ( . failure( CollectOrderPaymentUseCaseError . flowCanceledByUser) )
296+ }
297+ } )
297298
298299 } , onProcessingMessage: { [ weak self] in
299300 // Waiting message
0 commit comments