Skip to content

Commit

Permalink
feat(ios): add code and declineCode to failed event
Browse files Browse the repository at this point in the history
  • Loading branch information
rdlabo committed Oct 31, 2024
1 parent b43d2c9 commit ebc35f8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/terminal/ios/Plugin/StripeTerminal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg
} else if let paymentIntent = retrieveResult {
self.collectCancelable = Terminal.shared.collectPaymentMethod(paymentIntent) { collectResult, collectError in
if let error = collectError {
self.plugin?.notifyListeners(TerminalEvents.Failed.rawValue, data: [:])
self.plugin?.notifyListeners(TerminalEvents.Failed.rawValue, data: [
"message": error.localizedDescription,
// "code": error.code,
// "declineCode": error.declineCode ?? "",
])
var errorDetails: [String: Any] = ["message": error.localizedDescription]
call.reject(error.localizedDescription, nil, nil, errorDetails)
} else if let paymentIntent = collectResult {
Expand All @@ -231,7 +235,11 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg
Terminal.shared.confirmPaymentIntent(paymentIntent) { confirmResult, confirmError in
if let error = confirmError {
print("confirmPaymentIntent failed: \(error)")
self.plugin?.notifyListeners(TerminalEvents.Failed.rawValue, data: [:])
self.plugin?.notifyListeners(TerminalEvents.Failed.rawValue, data: [
"message": error.localizedDescription,
"code": error.code,
"declineCode": error.declineCode ?? "",
])
var errorDetails: [String: Any] = ["message": error.localizedDescription]
if let paymentIntent = error.paymentIntent,
let originalJSON = paymentIntent.originalJSON as? [AnyHashable: Any],
Expand Down

0 comments on commit ebc35f8

Please sign in to comment.