Skip to content

Commit 2c407f1

Browse files
committed
8079 Show spinner while preparing reader for payment
1 parent fdb9101 commit 2c407f1

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

WooCommerce/Classes/ViewRelated/Orders/Collect Payments/CollectOrderPaymentUseCase.swift

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

WooCommerce/Classes/ViewRelated/Orders/Refund/RefundSubmissionUseCase.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,7 @@ private extension RefundSubmissionUseCase {
295295
paymentGatewayAccount: PaymentGatewayAccount,
296296
onCompletion: @escaping (Result<Void, Error>) -> ()) {
297297
// Shows reader ready alert.
298-
alerts.readerIsReady(title: Localization.refundPaymentTitle(username: order.billingAddress?.firstName),
299-
amount: formattedAmount,
300-
onCancel: { [weak self] in
298+
alerts.preparingReader(onCancel: { [weak self] in
301299
self?.cancelRefund(charge: charge, paymentGatewayAccount: paymentGatewayAccount, onCompletion: onCompletion)
302300
})
303301

@@ -307,7 +305,10 @@ private extension RefundSubmissionUseCase {
307305
paymentGatewayAccount: paymentGatewayAccount,
308306
onWaitingForInput: { [weak self] in
309307
// Requests card input.
310-
self?.alerts.tapOrInsertCard(onCancel: { [weak self] in
308+
guard let self = self else { return }
309+
self.alerts.readerIsReady(title: Localization.refundPaymentTitle(username: self.order.billingAddress?.firstName),
310+
amount: self.formattedAmount,
311+
onCancel: { [weak self] in
311312
self?.cancelRefund(charge: charge, paymentGatewayAccount: paymentGatewayAccount, onCompletion: onCompletion)
312313
})
313314
}, onProcessingMessage: { [weak self] in

0 commit comments

Comments
 (0)