Skip to content

Commit

Permalink
Add debug output to console for Source and Token Id's in ExampleApp
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Solovev committed Mar 20, 2024
1 parent 2a4ef0e commit bd49cff
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions ExampleApp/Views/ProductDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,39 +81,10 @@ extension ProductDetailViewController: AuthorizingPaymentViewControllerDelegate
}
}

// MARK: - Custom Credit Card Form View Controller Delegate

extension ProductDetailViewController: CustomCreditCardPaymentControllerDelegate {
func creditCardFormViewController(_ controller: CustomCreditCardPaymentController, didSucceedWithToken token: Token) {
dismissForm {
let alertController = UIAlertController(
title: "Token Created",
message: "A token with id of \(token.id) was successfully created. Please send this id to server to create a charge.",
preferredStyle: .alert
)
let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)
}
}

func creditCardFormViewController(_ controller: CustomCreditCardPaymentController, didFailWithError error: Error) {
dismissForm {
let alertController = UIAlertController(
title: "Error",
message: error.localizedDescription,
preferredStyle: .alert
)
let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)
}
}
}

/// Processing result of choosing Payment Method screen
extension ProductDetailViewController: ChoosePaymentMethodDelegate {
func choosePaymentMethodDidComplete(with source: Source) {
print("Source is created with id '\(source.id)'")
omiseSDK.dismiss {
let alertController = UIAlertController(
title: "Source Created\n(\(source.paymentInformation.sourceType.rawValue))",
Expand All @@ -127,6 +98,7 @@ extension ProductDetailViewController: ChoosePaymentMethodDelegate {
}

func choosePaymentMethodDidComplete(with token: Token) {
print("Token is created with id '\(token.id)'")
omiseSDK.dismiss {
let alertController = UIAlertController(
title: "Token Created",
Expand All @@ -152,3 +124,33 @@ extension ProductDetailViewController: ChoosePaymentMethodDelegate {
omiseSDK.dismiss()
}
}

// MARK: - Custom Credit Card Form View Controller Delegate
extension ProductDetailViewController: CustomCreditCardPaymentControllerDelegate {
func creditCardFormViewController(_ controller: CustomCreditCardPaymentController, didSucceedWithToken token: Token) {
print("Token is created by using custom form with id '\(token.id)'")
dismissForm {
let alertController = UIAlertController(
title: "Token Created",
message: "A token with id of \(token.id) was successfully created. Please send this id to server to create a charge.",
preferredStyle: .alert
)
let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)
}
}

func creditCardFormViewController(_ controller: CustomCreditCardPaymentController, didFailWithError error: Error) {
dismissForm {
let alertController = UIAlertController(
title: "Error",
message: error.localizedDescription,
preferredStyle: .alert
)
let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)
}
}
}

0 comments on commit bd49cff

Please sign in to comment.