Skip to content

Commit 0c188a3

Browse files
committed
Merge branch 'feature/SP-100-error-state-for-when-abort-is-not-allowed' into 'feature/sdk-version-5.0.2'
Resolve SP-100 "Feature/ error state for when abort is not allowed" See merge request swedbank-pay/swedbank-pay-example-app-ios!15
2 parents 4da01cb + 3e05858 commit 0c188a3

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Example-app/Base.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"stand_alone_url_payment_abort" = "Abort";
2626
"stand_alone_url_payment_session_end_state_reached" = "Something went wrong with the payment";
2727
"stand_alone_internal_inconsistency_error" = "Something was called it the wrong order";
28+
"stand_alone_abort_payment_not_allowed" = "Abort payment currently not possible";
2829
"stand_alone_generic_error_title" = "Something went wrong";
2930
"stand_alone_url_seamless_title" = "Seamless View";
3031
"stand_alone_url_payment_web" = "Get payment menu";

Example-app/ViewModels/StandaloneUrlViewModel.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,15 @@ extension StandaloneUrlView {
111111
retry: retry)
112112
}
113113

114-
private func showAlert(errorTitle: String?, errorMessage: String?, retry: (()->Void)? = nil) {
114+
private func showAlert(errorTitle: String?, errorMessage: String?, stopLoading: Bool = true, retry: (()->Void)? = nil) {
115115
self.errorTitle = errorTitle
116116
self.errorMessage = errorMessage
117117
self.retry = retry
118118
self.showingAlert = true
119119

120-
isLoadingNativePayment = false
120+
if stopLoading {
121+
isLoadingNativePayment = false
122+
}
121123
}
122124

123125
private func showAlertOnPaymentSession3DSecureViewController(error: Error, retry: (()->Void)?) {
@@ -183,6 +185,8 @@ extension StandaloneUrlView {
183185
setPaymentResult(success: false, resultText: "stand_alone_internal_inconsistency_error".localize)
184186
case .automaticConfigurationFailed:
185187
setPaymentResult(success: false, resultText: "stand_alone_automatic_configuration_failed".localize)
188+
case .abortPaymentNotAllowed:
189+
showAlert(errorTitle: nil, errorMessage: "stand_alone_abort_payment_not_allowed".localize, stopLoading: false)
186190
}
187191
}
188192

Example-app/Views/StandaloneUrlView.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ struct StandaloneUrlView: View {
336336
.frame(height: 48)
337337
.accessibilityIdentifier("swishButton")
338338
}
339-
.disabled(viewModel.swishNumber.isEmpty)
339+
.disabled(viewModel.swishNumber.isEmpty || viewModel.isLoadingNativePayment)
340340
.foregroundColor(!viewModel.swishNumber.isEmpty ? .white : .gray)
341341
.background(!viewModel.swishNumber.isEmpty ? .black : .backgroundGray)
342342
.cornerRadius(30)
@@ -354,6 +354,7 @@ struct StandaloneUrlView: View {
354354
.frame(height: 48)
355355
.accessibilityIdentifier("swishButton")
356356
}
357+
.disabled(viewModel.isLoadingNativePayment)
357358
.foregroundColor(.white)
358359
.background(.black)
359360
.cornerRadius(30)
@@ -373,6 +374,7 @@ struct StandaloneUrlView: View {
373374
.frame(height: 48)
374375
.accessibilityIdentifier("swishPrefillButton")
375376
}
377+
.disabled(viewModel.isLoadingNativePayment)
376378
.foregroundColor(.white)
377379
.background(.black)
378380
.cornerRadius(30)
@@ -398,6 +400,7 @@ struct StandaloneUrlView: View {
398400
.accessibilityIdentifier("creditCardPrefillButton")
399401

400402
}
403+
.disabled(viewModel.isLoadingNativePayment)
401404
.foregroundColor(.white)
402405
.background(.black)
403406
.cornerRadius(30)
@@ -417,6 +420,7 @@ struct StandaloneUrlView: View {
417420
.frame(height: 48)
418421
.accessibilityIdentifier("newCreditCardButton")
419422
}
423+
.disabled(viewModel.isLoadingNativePayment)
420424
.foregroundColor(.white)
421425
.background(.black)
422426
.cornerRadius(30)
@@ -447,6 +451,7 @@ struct StandaloneUrlView: View {
447451
.frame(height: 48)
448452
.accessibilityIdentifier("applePayExampleAppButton")
449453
}
454+
.disabled(viewModel.isLoadingNativePayment)
450455
.foregroundColor(.white)
451456
.background(.black)
452457
.cornerRadius(30)
@@ -467,6 +472,7 @@ struct StandaloneUrlView: View {
467472
.frame(height: 48)
468473
.accessibilityIdentifier("applePayCharityButton")
469474
}
475+
.disabled(viewModel.isLoadingNativePayment)
470476
.foregroundColor(.white)
471477
.background(.black)
472478
.cornerRadius(30)
@@ -488,6 +494,7 @@ struct StandaloneUrlView: View {
488494
.accessibilityIdentifier("webBasedButton")
489495

490496
}
497+
.disabled(viewModel.isLoadingNativePayment)
491498
.foregroundColor(.white)
492499
.background(.black)
493500
.cornerRadius(30)
@@ -507,6 +514,7 @@ struct StandaloneUrlView: View {
507514
.accessibilityIdentifier("webBasedButton")
508515

509516
}
517+
.disabled(viewModel.isLoadingNativePayment)
510518
.foregroundColor(.white)
511519
.background(.black)
512520
.cornerRadius(30)
@@ -532,6 +540,7 @@ struct StandaloneUrlView: View {
532540
.accessibilityIdentifier("webBasedButton")
533541

534542
}
543+
.disabled(viewModel.isLoadingNativePayment)
535544
.foregroundColor(.white)
536545
.background(.black)
537546
.cornerRadius(30)

Example-app/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"stand_alone_url_payment_abort" = "Abort";
2626
"stand_alone_url_payment_session_end_state_reached" = "Something went wrong with the payment";
2727
"stand_alone_internal_inconsistency_error" = "Something was called it the wrong order";
28+
"stand_alone_abort_payment_not_allowed" = "Abort payment currently not possible";
2829
"stand_alone_generic_error_title" = "Something went wrong";
2930
"stand_alone_url_seamless_title" = "Seamless View";
3031
"stand_alone_url_payment_web" = "Get payment menu";

0 commit comments

Comments
 (0)