Skip to content

Commit 4443e39

Browse files
committed
iOS: add StripeSdkEmitter implementation
1 parent 4001c4b commit 4443e39

File tree

1 file changed

+67
-3
lines changed

1 file changed

+67
-3
lines changed

packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/StripePlugin.swift

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func RCTMakeAndLogError(_ error: String, _ something: String?, _ anotherSomethin
1717

1818
@objc(StripePlugin)
1919
class StripePlugin: StripeSdkImpl, FlutterPlugin, ViewManagerDelegate {
20-
20+
2121

2222
private var channel: FlutterMethodChannel
2323

@@ -26,6 +26,7 @@ class StripePlugin: StripeSdkImpl, FlutterPlugin, ViewManagerDelegate {
2626
let channel = FlutterMethodChannel(name: "flutter.stripe/payments", binaryMessenger: registrar.messenger(), codec: FlutterJSONMethodCodec())
2727

2828
let instance = StripePlugin(channel: channel)
29+
instance.emitter = instance
2930
registrar.addMethodCallDelegate(instance, channel: channel)
3031
registrar.addApplicationDelegate(instance)
3132

@@ -238,10 +239,9 @@ class StripePlugin: StripeSdkImpl, FlutterPlugin, ViewManagerDelegate {
238239
}
239240
}
240241

241-
/*override
242242
func sendEvent(withName name: String, body: [String: Any]) {
243243
channel.invokeMethod(name, arguments: body)
244-
}*/
244+
}
245245

246246
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
247247
return StripeAPI.handleURLCallback(with: url)
@@ -258,6 +258,70 @@ class StripePlugin: StripeSdkImpl, FlutterPlugin, ViewManagerDelegate {
258258
}
259259
}
260260

261+
extension StripePlugin: StripeSdkEmitter {
262+
263+
func emitOnConfirmHandlerCallback(_ value: [String : Any]) {
264+
self.sendEvent(withName: "onConfirmHandlerCallback", body: value)
265+
}
266+
267+
func emitOnFinancialConnectionsEvent(_ value: [String : Any]) {
268+
self.sendEvent(withName: "onFinancialConnectionsEvent", body: value)
269+
}
270+
271+
func emitOnOrderTrackingCallback() {
272+
self.sendEvent(withName: "onOrderTrackingCallback", body:[:])
273+
}
274+
275+
func emitOnCustomerAdapterFetchPaymentMethodsCallback() {
276+
self.sendEvent(withName: "onCustomerAdapterFetchPaymentMethodsCallback", body:[:])
277+
}
278+
279+
func emitOnCustomerAdapterAttachPaymentMethodCallback(_ value: [String : Any]) {
280+
self.sendEvent(withName: "onCustomerAdapterAttachPaymentMethodCallback", body:value)
281+
}
282+
283+
func emitOnCustomerAdapterDetachPaymentMethodCallback(_ value: [String : Any]) {
284+
self.sendEvent(withName: "onCustomerAdapterDetachPaymentMethodCallback", body:value)
285+
}
286+
287+
func emitOnCustomerAdapterSetSelectedPaymentOptionCallback(_ value: [String : Any]) {
288+
self.sendEvent(withName: "onCustomerAdapterSetSelectedPaymentOptionCallback", body:value)
289+
}
290+
291+
func emitOnCustomerAdapterFetchSelectedPaymentOptionCallback() {
292+
self.sendEvent(withName: "onCustomerAdapterFetchSelectedPaymentOptionCallback", body:[:])
293+
}
294+
295+
func emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback() {
296+
self.sendEvent(withName: "onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback", body:[:])
297+
}
298+
299+
func emitEmbeddedPaymentElementDidUpdateHeight(_ value: [String : Any]) {
300+
self.sendEvent(withName: "embeddedPaymentElementDidUpdateHeight", body:value)
301+
}
302+
303+
func emitEmbeddedPaymentElementWillPresent() {
304+
self.sendEvent(withName: "embeddedPaymentElementWillPresent", body:[:])
305+
}
306+
307+
func emitEmbeddedPaymentElementDidUpdatePaymentOption(_ value: [String : Any]) {
308+
self.sendEvent(withName: "embeddedPaymentElementDidUpdatePaymentOption", body: value)
309+
}
310+
311+
func emitEmbeddedPaymentElementFormSheetConfirmComplete(_ value: [String : Any]) {
312+
self.sendEvent(withName: "embeddedPaymentElementFormSheetConfirmComplete", body: value)
313+
}
314+
315+
func emitEmbeddedPaymentElementRowSelectionImmediateAction() {
316+
self.sendEvent(withName: "embeddedPaymentElementRowSelectionImmediateAction", body:[:])
317+
}
318+
319+
func emitEmbeddedPaymentElementLoadingFailed(_ value: [String : Any]) {
320+
self.sendEvent(withName: "embeddedPaymentElementLoadingFailed", body:value)
321+
}
322+
323+
}
324+
261325

262326
// Mark: MethodChannel handlers
263327
extension StripePlugin {

0 commit comments

Comments
 (0)