Skip to content

Commit 6f51e46

Browse files
authored
Merge pull request #6922 from woocommerce/issue/6905-change-text-after-card-payment
[Mobile Payments] Change text after card payment
2 parents c7c27fa + fcf9b45 commit 6f51e46

File tree

13 files changed

+34
-47
lines changed

13 files changed

+34
-47
lines changed

WooCommerce/Classes/ViewModels/CardPresentPayments/CardPresentModalSuccess.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class CardPresentModalSuccess: CardPresentPaymentsModalViewModel {
2626

2727
let secondaryButtonTitle: String? = Localization.emailReceipt
2828

29-
let auxiliaryButtonTitle: String?
29+
let auxiliaryButtonTitle: String? = Localization.saveReceiptAndContinue
3030

3131
let bottomTitle: String? = nil
3232

@@ -38,12 +38,10 @@ final class CardPresentModalSuccess: CardPresentPaymentsModalViewModel {
3838

3939
init(printReceipt: @escaping () -> Void,
4040
emailReceipt: @escaping () -> Void,
41-
noReceiptTitle: String,
4241
noReceiptAction: @escaping () -> Void) {
4342
self.printReceiptAction = printReceipt
4443
self.emailReceiptAction = emailReceipt
4544
self.noReceiptAction = noReceiptAction
46-
self.auxiliaryButtonTitle = noReceiptTitle
4745
}
4846

4947
func didTapPrimaryButton(in viewController: UIViewController?) {
@@ -81,5 +79,10 @@ private extension CardPresentModalSuccess {
8179
"Email receipt",
8280
comment: "Button to email receipts. Presented to users after a payment has been successfully collected"
8381
)
82+
83+
static let saveReceiptAndContinue = NSLocalizedString(
84+
"Save receipt and continue",
85+
comment: "Button when the user does not want to print or email receipt. Presented to users after a payment has been successfully collected"
86+
)
8487
}
8588
}

WooCommerce/Classes/ViewModels/CardPresentPayments/CardPresentModalSuccessWithoutEmail.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class CardPresentModalSuccessWithoutEmail: CardPresentPaymentsModalViewMod
2020

2121
let primaryButtonTitle: String? = Localization.printReceipt
2222

23-
let secondaryButtonTitle: String?
23+
let secondaryButtonTitle: String? = Localization.saveReceiptAndContinue
2424

2525
let auxiliaryButtonTitle: String? = nil
2626

@@ -33,11 +33,9 @@ final class CardPresentModalSuccessWithoutEmail: CardPresentPaymentsModalViewMod
3333
}
3434

3535
init(printReceipt: @escaping () -> Void,
36-
noReceiptTitle: String,
3736
noReceiptAction: @escaping () -> Void) {
3837
self.printReceiptAction = printReceipt
3938
self.noReceiptAction = noReceiptAction
40-
self.secondaryButtonTitle = noReceiptTitle
4139
}
4240

4341
func didTapPrimaryButton(in viewController: UIViewController?) {
@@ -66,5 +64,10 @@ private extension CardPresentModalSuccessWithoutEmail {
6664
"Print receipt",
6765
comment: "Button to print receipts. Presented to users after a payment has been successfully collected"
6866
)
67+
68+
static let saveReceiptAndContinue = NSLocalizedString(
69+
"Save receipt and continue",
70+
comment: "Button when the user does not want to print the receipt. Presented to users after a payment has been successfully collected"
71+
)
6972
}
7073
}

WooCommerce/Classes/ViewModels/Order Details/OrderDetailsPaymentAlerts.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ final class OrderDetailsPaymentAlerts: OrderDetailsPaymentAlertsProtocol {
6969
presentViewModel(viewModel: viewModel)
7070
}
7171

72-
func success(printReceipt: @escaping () -> Void, emailReceipt: @escaping () -> Void, noReceiptTitle: String, noReceiptAction: @escaping () -> Void) {
72+
func success(printReceipt: @escaping () -> Void, emailReceipt: @escaping () -> Void, noReceiptAction: @escaping () -> Void) {
7373
let viewModel = successViewModel(printReceipt: printReceipt,
7474
emailReceipt: emailReceipt,
75-
noReceiptTitle: noReceiptTitle,
7675
noReceiptAction: noReceiptAction)
7776
presentViewModel(viewModel: viewModel)
7877
}
@@ -115,15 +114,13 @@ private extension OrderDetailsPaymentAlerts {
115114

116115
func successViewModel(printReceipt: @escaping () -> Void,
117116
emailReceipt: @escaping () -> Void,
118-
noReceiptTitle: String,
119117
noReceiptAction: @escaping () -> Void) -> CardPresentPaymentsModalViewModel {
120118
if MFMailComposeViewController.canSendMail() {
121119
return CardPresentModalSuccess(printReceipt: printReceipt,
122120
emailReceipt: emailReceipt,
123-
noReceiptTitle: noReceiptTitle,
124121
noReceiptAction: noReceiptAction)
125122
} else {
126-
return CardPresentModalSuccessWithoutEmail(printReceipt: printReceipt, noReceiptTitle: noReceiptTitle, noReceiptAction: noReceiptAction)
123+
return CardPresentModalSuccessWithoutEmail(printReceipt: printReceipt, noReceiptAction: noReceiptAction)
127124
}
128125
}
129126

WooCommerce/Classes/ViewModels/Order Details/OrderDetailsPaymentAlertsProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ protocol OrderDetailsPaymentAlertsProtocol {
1212

1313
func processingPayment()
1414

15-
func success(printReceipt: @escaping () -> Void, emailReceipt: @escaping () -> Void, noReceiptTitle: String, noReceiptAction: @escaping () -> Void)
15+
func success(printReceipt: @escaping () -> Void, emailReceipt: @escaping () -> Void, noReceiptAction: @escaping () -> Void)
1616

1717
func error(error: Error, tryAgain: @escaping () -> Void, dismissCompletion: @escaping () -> Void)
1818

WooCommerce/Classes/ViewModels/Order Details/OrderDetailsViewModel.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ extension OrderDetailsViewModel {
534534
/// Checks onboarding status before connecting to a reader.
535535
/// Handles receipt sharing.
536536
///
537-
func collectPayment(rootViewController: UIViewController, backButtonTitle: String, onCollect: @escaping (Result<Void, Error>) -> Void) {
537+
func collectPayment(rootViewController: UIViewController, onCollect: @escaping (Result<Void, Error>) -> Void) {
538538
cardPresentPaymentsOnboardingPresenter.showOnboardingIfRequired(from: rootViewController) { [weak self] in
539539
guard let self = self else { return }
540540
guard let paymentGateway = self.cardPresentPaymentGatewayAccounts.first else {
@@ -559,7 +559,6 @@ extension OrderDetailsViewModel {
559559
configuration: self.configurationLoader.configuration)
560560

561561
self.collectPaymentsUseCase?.collectPayment(
562-
backButtonTitle: backButtonTitle,
563562
onCollect: onCollect,
564563
onCompleted: { [weak self] in
565564
// Make sure we free all the resources

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ protocol CollectOrderPaymentProtocol {
1515
/// Starts the collect payment flow.
1616
///
1717
///
18-
/// - Parameter backButtonTitle: Title for the back button after a payment is successful.
1918
/// - Parameter onCollect: Closure Invoked after the collect process has finished.
2019
/// - Parameter onCompleted: Closure Invoked after the flow has been totally completed.
21-
func collectPayment(backButtonTitle: String, onCollect: @escaping (Result<Void, Error>) -> (), onCompleted: @escaping () -> ())
20+
func collectPayment(onCollect: @escaping (Result<Void, Error>) -> (), onCompleted: @escaping () -> ())
2221
}
2322

2423
/// Use case to collect payments from an order.
@@ -126,10 +125,9 @@ final class CollectOrderPaymentUseCase: NSObject, CollectOrderPaymentProtocol {
126125
/// 4. If failure: Allows retry
127126
///
128127
///
129-
/// - Parameter backButtonTitle: Title for the back button after a payment is successful.
130128
/// - Parameter onCollect: Closure Invoked after the collect process has finished.
131129
/// - Parameter onCompleted: Closure Invoked after the flow has been totally completed, Currently after merchant has handled the receipt.
132-
func collectPayment(backButtonTitle: String, onCollect: @escaping (Result<Void, Error>) -> (), onCompleted: @escaping () -> ()) {
130+
func collectPayment(onCollect: @escaping (Result<Void, Error>) -> (), onCompleted: @escaping () -> ()) {
133131
guard isTotalAmountValid() else {
134132
let error = totalAmountInvalidError()
135133
onCollect(.failure(error))
@@ -150,7 +148,7 @@ final class CollectOrderPaymentUseCase: NSObject, CollectOrderPaymentProtocol {
150148
guard let paymentData = try? result.get() else {
151149
return onCompleted()
152150
}
153-
self?.presentReceiptAlert(receiptParameters: paymentData.receiptParameters, backButtonTitle: backButtonTitle, onCompleted: onCompleted)
151+
self?.presentReceiptAlert(receiptParameters: paymentData.receiptParameters, onCompleted: onCompleted)
154152
})
155153
case .failure(let error):
156154
onCollect(.failure(error))
@@ -377,7 +375,7 @@ private extension CollectOrderPaymentUseCase {
377375

378376
/// Allow merchants to print or email the payment receipt.
379377
///
380-
func presentReceiptAlert(receiptParameters: CardPresentReceiptParameters, backButtonTitle: String, onCompleted: @escaping () -> ()) {
378+
func presentReceiptAlert(receiptParameters: CardPresentReceiptParameters, onCompleted: @escaping () -> ()) {
381379
// Present receipt alert
382380
alerts.success(printReceipt: { [order, configuration, weak self] in
383381
guard let self = self else { return }
@@ -405,8 +403,7 @@ private extension CollectOrderPaymentUseCase {
405403
paymentOrchestrator.emailReceipt(for: order, params: receiptParameters) { [weak self] emailContent in
406404
self?.presentEmailForm(content: emailContent, onCompleted: onCompleted)
407405
}
408-
}, noReceiptTitle: backButtonTitle,
409-
noReceiptAction: {
406+
}, noReceiptAction: {
410407
// Inform about flow completion.
411408
onCompleted()
412409
})

WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ private extension OrderDetailsViewController {
725725
}
726726

727727
@objc private func collectPaymentTapped() {
728-
viewModel.collectPayment(rootViewController: self, backButtonTitle: Localization.Payments.backToOrder) { [weak self] result in
728+
viewModel.collectPayment(rootViewController: self) { [weak self] result in
729729
guard let self = self else { return }
730730
// Refresh date & view once payment has been collected.
731731
if result.isSuccess {
@@ -980,11 +980,6 @@ private extension OrderDetailsViewController {
980980
comment: "Track shipment of a shipping label from the shipping label tracking more menu action sheet")
981981
}
982982

983-
enum Payments {
984-
static let backToOrder = NSLocalizedString("Back to Order",
985-
comment: "Button to dismiss modal overlay and go back to the order after a sucessful payment")
986-
}
987-
988983
enum ActionsMenu {
989984
static let cancelAction = NSLocalizedString("Cancel", comment: "Cancel the main more actions menu sheet.")
990985
static let paymentLink = NSLocalizedString("Share Payment Link", comment: "Title to share an order payment link.")

WooCommerce/Classes/ViewRelated/Orders/Simple Payments/Method/SimplePaymentsMethodsViewModel.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ final class SimplePaymentsMethodsViewModel: ObservableObject {
209209
configuration: CardPresentConfigurationLoader().configuration)
210210

211211
self.collectPaymentsUseCase?.collectPayment(
212-
backButtonTitle: Localization.continueToOrders,
213212
onCollect: { [weak self] result in
214213
guard case let .failure(error) = result else { return }
215214

@@ -299,8 +298,6 @@ private extension SimplePaymentsMethodsViewModel {
299298
comment: "Text when there is an error while marking the order as paid for simple payments.")
300299
static let genericCollectError = NSLocalizedString("There was an error while trying to collect the payment.",
301300
comment: "Text when there is an unknown error while trying to collect payments")
302-
static let continueToOrders = NSLocalizedString("Continue To Orders",
303-
comment: "Button to dismiss modal overlay and go back to the orders list after a sucessful payment")
304301

305302
static let title = NSLocalizedString("Take Payment (%1$@)",
306303
comment: "Navigation bar title for the Simple Payments Methods screens. " +

WooCommerce/WooCommerceTests/Mocks/MockOrderDetailsPaymentAlerts.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension MockOrderDetailsPaymentAlerts: OrderDetailsPaymentAlertsProtocol {
3939
// no-op
4040
}
4141

42-
func success(printReceipt: @escaping () -> Void, emailReceipt: @escaping () -> Void, noReceiptTitle: String, noReceiptAction: @escaping () -> Void) {
42+
func success(printReceipt: @escaping () -> Void, emailReceipt: @escaping () -> Void, noReceiptAction: @escaping () -> Void) {
4343
printReceiptFromSuccessAlert = printReceipt
4444
emailReceiptFromSuccessAlert = emailReceipt
4545
}

WooCommerce/WooCommerceTests/ViewModels/CardPresentPayments/CardPresentModalSuccessTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ final class CardPresentModalSuccessTests: XCTestCase {
1010
closures = Closures()
1111
viewModel = CardPresentModalSuccess(printReceipt: closures.printReceipt(),
1212
emailReceipt: closures.emailReceipt(),
13-
noReceiptTitle: "Back",
1413
noReceiptAction: closures.noReceiptAction())
1514
}
1615

@@ -42,7 +41,6 @@ final class CardPresentModalSuccessTests: XCTestCase {
4241

4342
func test_auxiliary_button_title_is_not_nil() {
4443
XCTAssertNotNil(viewModel.auxiliaryButtonTitle)
45-
XCTAssertEqual(viewModel.auxiliaryButtonTitle, "Back")
4644
}
4745

4846
func test_bottom_title_is_nil() {

0 commit comments

Comments
 (0)