applepay-rn 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/ApplepayRn.podspec +22 -0
  2. package/LICENSE +20 -0
  3. package/README.md +551 -0
  4. package/android/build.gradle +67 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/applepayrn/ApplepayRnPackage.kt +17 -0
  7. package/android/src/main/java/com/applepayrn/ApplepayRnView.kt +15 -0
  8. package/android/src/main/java/com/applepayrn/ApplepayRnViewManager.kt +41 -0
  9. package/ios/ApplePayBridge.swift +68 -0
  10. package/ios/ApplepayRnView.h +14 -0
  11. package/ios/ApplepayRnView.mm +110 -0
  12. package/lib/module/ApplePayView.js +70 -0
  13. package/lib/module/ApplePayView.js.map +1 -0
  14. package/lib/module/NativeApplePayView.js +7 -0
  15. package/lib/module/NativeApplePayView.js.map +1 -0
  16. package/lib/module/index.js +4 -0
  17. package/lib/module/index.js.map +1 -0
  18. package/lib/module/package.json +1 -0
  19. package/lib/module/types.js +2 -0
  20. package/lib/module/types.js.map +1 -0
  21. package/lib/typescript/package.json +1 -0
  22. package/lib/typescript/src/ApplePayView.d.ts +17 -0
  23. package/lib/typescript/src/ApplePayView.d.ts.map +1 -0
  24. package/lib/typescript/src/NativeApplePayView.d.ts +26 -0
  25. package/lib/typescript/src/NativeApplePayView.d.ts.map +1 -0
  26. package/lib/typescript/src/index.d.ts +4 -0
  27. package/lib/typescript/src/index.d.ts.map +1 -0
  28. package/lib/typescript/src/types.d.ts +71 -0
  29. package/lib/typescript/src/types.d.ts.map +1 -0
  30. package/package.json +177 -0
  31. package/src/ApplePayView.tsx +118 -0
  32. package/src/NativeApplePayView.ts +20 -0
  33. package/src/index.tsx +16 -0
  34. package/src/types.ts +91 -0
@@ -0,0 +1,41 @@
1
+ package com.applepayrn
2
+
3
+ import android.graphics.Color
4
+ import com.facebook.react.module.annotations.ReactModule
5
+ import com.facebook.react.uimanager.SimpleViewManager
6
+ import com.facebook.react.uimanager.ThemedReactContext
7
+ import com.facebook.react.uimanager.ViewManagerDelegate
8
+ import com.facebook.react.uimanager.annotations.ReactProp
9
+ import com.facebook.react.viewmanagers.ApplepayRnViewManagerInterface
10
+ import com.facebook.react.viewmanagers.ApplepayRnViewManagerDelegate
11
+
12
+ @ReactModule(name = ApplepayRnViewManager.NAME)
13
+ class ApplepayRnViewManager : SimpleViewManager<ApplepayRnView>(),
14
+ ApplepayRnViewManagerInterface<ApplepayRnView> {
15
+ private val mDelegate: ViewManagerDelegate<ApplepayRnView>
16
+
17
+ init {
18
+ mDelegate = ApplepayRnViewManagerDelegate(this)
19
+ }
20
+
21
+ override fun getDelegate(): ViewManagerDelegate<ApplepayRnView>? {
22
+ return mDelegate
23
+ }
24
+
25
+ override fun getName(): String {
26
+ return NAME
27
+ }
28
+
29
+ public override fun createViewInstance(context: ThemedReactContext): ApplepayRnView {
30
+ return ApplepayRnView(context)
31
+ }
32
+
33
+ @ReactProp(name = "color")
34
+ override fun setColor(view: ApplepayRnView?, color: Int?) {
35
+ view?.setBackgroundColor(color ?: Color.TRANSPARENT)
36
+ }
37
+
38
+ companion object {
39
+ const val NAME = "ApplepayRnView"
40
+ }
41
+ }
@@ -0,0 +1,68 @@
1
+ import ApplePay_iOS
2
+ import UIKit
3
+
4
+ /// Fabric content view for the Apple Pay button.
5
+ /// Owns ApplePayView and routes delegate callbacks to @objc closures.
6
+ /// ApplePayDelegate conformance is kept in a private class so it never
7
+ /// appears in the generated ApplepayRn-Swift.h header.
8
+ @objc public class ApplePayBridge: UIView {
9
+
10
+ private var applePayView: ApplePayView?
11
+ private var delegateImpl: ApplePayDelegateImpl?
12
+
13
+ // MARK: - @objc callbacks (set by ApplepayRnView.mm)
14
+
15
+ @objc public var onReadyHandler: (() -> Void)?
16
+ @objc public var onClickHandler: (() -> Void)?
17
+ @objc public var onSuccessHandler: ((String) -> Void)?
18
+ @objc public var onChargeCreatedHandler: ((String) -> Void)?
19
+ @objc public var onOrderCreatedHandler: ((String) -> Void)?
20
+ @objc public var onCancelHandler: (() -> Void)?
21
+ @objc public var onErrorHandler: ((String) -> Void)?
22
+ @objc public var onMerchantValidationHandler: ((String) -> Void)?
23
+
24
+ // MARK: - Public API
25
+
26
+ @objc public func initApplePay(configJSON: String) {
27
+ guard
28
+ let data = configJSON.data(using: .utf8),
29
+ let configDict = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
30
+ else { return }
31
+
32
+ if applePayView == nil {
33
+ let view = ApplePayView()
34
+ applePayView = view
35
+ addSubview(view)
36
+ view.translatesAutoresizingMaskIntoConstraints = false
37
+ NSLayoutConstraint.activate([
38
+ view.topAnchor.constraint(equalTo: topAnchor),
39
+ view.leadingAnchor.constraint(equalTo: leadingAnchor),
40
+ view.trailingAnchor.constraint(equalTo: trailingAnchor),
41
+ view.bottomAnchor.constraint(equalTo: bottomAnchor),
42
+ ])
43
+ }
44
+
45
+ let impl = ApplePayDelegateImpl(bridge: self)
46
+ delegateImpl = impl
47
+ applePayView?.initApplePay(configDict: configDict, delegate: impl)
48
+ }
49
+ }
50
+
51
+ // MARK: - Private delegate implementation (never exported to ObjC header)
52
+
53
+ private class ApplePayDelegateImpl: NSObject, ApplePayDelegate {
54
+ private weak var bridge: ApplePayBridge?
55
+
56
+ init(bridge: ApplePayBridge) {
57
+ self.bridge = bridge
58
+ }
59
+
60
+ func onReady() { bridge?.onReadyHandler?() }
61
+ func onClick() { bridge?.onClickHandler?() }
62
+ func onSuccess(data: String) { bridge?.onSuccessHandler?(data) }
63
+ func onChargeCreated(data: String) { bridge?.onChargeCreatedHandler?(data) }
64
+ func onOrderCreated(data: String) { bridge?.onOrderCreatedHandler?(data) }
65
+ func onCanceled() { bridge?.onCancelHandler?() }
66
+ func onError(data: String) { bridge?.onErrorHandler?(data) }
67
+ func onMerchantValidation(data: String) { bridge?.onMerchantValidationHandler?(data) }
68
+ }
@@ -0,0 +1,14 @@
1
+ #import <React/RCTViewComponentView.h>
2
+ #import <UIKit/UIKit.h>
3
+
4
+ #ifndef ApplepayRnView_h
5
+ #define ApplepayRnView_h
6
+
7
+ NS_ASSUME_NONNULL_BEGIN
8
+
9
+ @interface ApplepayRnView : RCTViewComponentView
10
+ @end
11
+
12
+ NS_ASSUME_NONNULL_END
13
+
14
+ #endif /* ApplepayRnView_h */
@@ -0,0 +1,110 @@
1
+ #import "ApplepayRnView.h"
2
+
3
+ #import <react/renderer/components/NativeApplePayViewSpec/ComponentDescriptors.h>
4
+ #import <react/renderer/components/NativeApplePayViewSpec/Props.h>
5
+ #import <react/renderer/components/NativeApplePayViewSpec/RCTComponentViewHelpers.h>
6
+ #import <react/renderer/components/NativeApplePayViewSpec/EventEmitters.h>
7
+
8
+ #import "RCTFabricComponentsPlugins.h"
9
+ #import "ApplepayRn-Swift.h"
10
+
11
+ using namespace facebook::react;
12
+
13
+ @implementation ApplepayRnView {
14
+ ApplePayBridge * _bridge;
15
+ }
16
+
17
+ + (ComponentDescriptorProvider)componentDescriptorProvider
18
+ {
19
+ return concreteComponentDescriptorProvider<NativeApplePayViewComponentDescriptor>();
20
+ }
21
+
22
+ - (instancetype)initWithFrame:(CGRect)frame
23
+ {
24
+ if (self = [super initWithFrame:frame]) {
25
+ static const auto defaultProps = std::make_shared<const NativeApplePayViewProps>();
26
+ _props = defaultProps;
27
+
28
+ _bridge = [[ApplePayBridge alloc] initWithFrame:frame];
29
+ self.contentView = _bridge;
30
+
31
+ __weak __typeof(self) weakSelf = self;
32
+
33
+ _bridge.onReadyHandler = ^{
34
+ __typeof(self) strongSelf = weakSelf;
35
+ if (!strongSelf || !strongSelf->_eventEmitter) return;
36
+ auto emitter = std::static_pointer_cast<NativeApplePayViewEventEmitter const>(strongSelf->_eventEmitter);
37
+ emitter->onApplePayReady({});
38
+ };
39
+
40
+ _bridge.onClickHandler = ^{
41
+ __typeof(self) strongSelf = weakSelf;
42
+ if (!strongSelf || !strongSelf->_eventEmitter) return;
43
+ auto emitter = std::static_pointer_cast<NativeApplePayViewEventEmitter const>(strongSelf->_eventEmitter);
44
+ emitter->onApplePayClick({});
45
+ };
46
+
47
+ _bridge.onSuccessHandler = ^(NSString * data) {
48
+ __typeof(self) strongSelf = weakSelf;
49
+ if (!strongSelf || !strongSelf->_eventEmitter) return;
50
+ auto emitter = std::static_pointer_cast<NativeApplePayViewEventEmitter const>(strongSelf->_eventEmitter);
51
+ emitter->onApplePaySuccess({ .data = std::string([data UTF8String]) });
52
+ };
53
+
54
+ _bridge.onChargeCreatedHandler = ^(NSString * data) {
55
+ __typeof(self) strongSelf = weakSelf;
56
+ if (!strongSelf || !strongSelf->_eventEmitter) return;
57
+ auto emitter = std::static_pointer_cast<NativeApplePayViewEventEmitter const>(strongSelf->_eventEmitter);
58
+ emitter->onApplePayChargeCreated({ .data = std::string([data UTF8String]) });
59
+ };
60
+
61
+ _bridge.onOrderCreatedHandler = ^(NSString * data) {
62
+ __typeof(self) strongSelf = weakSelf;
63
+ if (!strongSelf || !strongSelf->_eventEmitter) return;
64
+ auto emitter = std::static_pointer_cast<NativeApplePayViewEventEmitter const>(strongSelf->_eventEmitter);
65
+ emitter->onApplePayOrderCreated({ .data = std::string([data UTF8String]) });
66
+ };
67
+
68
+ _bridge.onCancelHandler = ^{
69
+ __typeof(self) strongSelf = weakSelf;
70
+ if (!strongSelf || !strongSelf->_eventEmitter) return;
71
+ auto emitter = std::static_pointer_cast<NativeApplePayViewEventEmitter const>(strongSelf->_eventEmitter);
72
+ emitter->onApplePayCancel({});
73
+ };
74
+
75
+ _bridge.onErrorHandler = ^(NSString * data) {
76
+ __typeof(self) strongSelf = weakSelf;
77
+ if (!strongSelf || !strongSelf->_eventEmitter) return;
78
+ auto emitter = std::static_pointer_cast<NativeApplePayViewEventEmitter const>(strongSelf->_eventEmitter);
79
+ emitter->onApplePayError({ .error = std::string([data UTF8String]) });
80
+ };
81
+
82
+ _bridge.onMerchantValidationHandler = ^(NSString * data) {
83
+ __typeof(self) strongSelf = weakSelf;
84
+ if (!strongSelf || !strongSelf->_eventEmitter) return;
85
+ auto emitter = std::static_pointer_cast<NativeApplePayViewEventEmitter const>(strongSelf->_eventEmitter);
86
+ emitter->onApplePayMerchantValidation({ .data = std::string([data UTF8String]) });
87
+ };
88
+ }
89
+ return self;
90
+ }
91
+
92
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
93
+ {
94
+ const auto &newViewProps = *std::static_pointer_cast<NativeApplePayViewProps const>(props);
95
+ const auto &currentProps = *std::static_pointer_cast<NativeApplePayViewProps const>(_props);
96
+
97
+ if (!newViewProps.configuration.empty() &&
98
+ newViewProps.configuration != currentProps.configuration) {
99
+ NSString *configJSON = [NSString stringWithUTF8String:newViewProps.configuration.c_str()];
100
+ [_bridge initApplePayWithConfigJSON:configJSON];
101
+ }
102
+
103
+ [super updateProps:props oldProps:oldProps];
104
+ }
105
+
106
+ @end
107
+
108
+ Class<RCTComponentViewProtocol> ApplepayRnViewCls(void) {
109
+ return ApplepayRnView.class;
110
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ import React, { useRef, useCallback } from 'react';
4
+ import { Platform, StyleSheet } from 'react-native';
5
+ import NativeApplePayView from "./NativeApplePayView.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export function TapApplePay({
8
+ configuration,
9
+ style,
10
+ onReady,
11
+ onClick,
12
+ onSuccess,
13
+ onChargeCreated,
14
+ onOrderCreated,
15
+ onCancel,
16
+ onError,
17
+ onMerchantValidation
18
+ }) {
19
+ const inProgress = useRef(false);
20
+ const handleReady = useCallback(() => {
21
+ onReady?.();
22
+ }, [onReady]);
23
+ const handleClick = useCallback(_event => {
24
+ if (inProgress.current) return;
25
+ inProgress.current = true;
26
+ onClick?.();
27
+ }, [onClick]);
28
+ const handleSuccess = useCallback(event => {
29
+ inProgress.current = false;
30
+ onSuccess?.(event.nativeEvent.data);
31
+ }, [onSuccess]);
32
+ const handleChargeCreated = useCallback(event => {
33
+ onChargeCreated?.(event.nativeEvent.data);
34
+ }, [onChargeCreated]);
35
+ const handleOrderCreated = useCallback(event => {
36
+ onOrderCreated?.(event.nativeEvent.data);
37
+ }, [onOrderCreated]);
38
+ const handleCancel = useCallback(_event => {
39
+ inProgress.current = false;
40
+ onCancel?.();
41
+ }, [onCancel]);
42
+ const handleError = useCallback(event => {
43
+ inProgress.current = false;
44
+ onError?.(event.nativeEvent.error);
45
+ }, [onError]);
46
+ const handleMerchantValidation = useCallback(event => {
47
+ onMerchantValidation?.(event.nativeEvent.data);
48
+ }, [onMerchantValidation]);
49
+ if (Platform.OS !== 'ios') {
50
+ return null;
51
+ }
52
+ return /*#__PURE__*/_jsx(NativeApplePayView, {
53
+ style: [style, styles.minHeight],
54
+ configuration: JSON.stringify(configuration),
55
+ onApplePayReady: handleReady,
56
+ onApplePayClick: handleClick,
57
+ onApplePaySuccess: handleSuccess,
58
+ onApplePayChargeCreated: handleChargeCreated,
59
+ onApplePayOrderCreated: handleOrderCreated,
60
+ onApplePayCancel: handleCancel,
61
+ onApplePayError: handleError,
62
+ onApplePayMerchantValidation: handleMerchantValidation
63
+ });
64
+ }
65
+ const styles = StyleSheet.create({
66
+ minHeight: {
67
+ minHeight: 48
68
+ }
69
+ });
70
+ //# sourceMappingURL=ApplePayView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useRef","useCallback","Platform","StyleSheet","NativeApplePayView","jsx","_jsx","TapApplePay","configuration","style","onReady","onClick","onSuccess","onChargeCreated","onOrderCreated","onCancel","onError","onMerchantValidation","inProgress","handleReady","handleClick","_event","current","handleSuccess","event","nativeEvent","data","handleChargeCreated","handleOrderCreated","handleCancel","handleError","error","handleMerchantValidation","OS","styles","minHeight","JSON","stringify","onApplePayReady","onApplePayClick","onApplePaySuccess","onApplePayChargeCreated","onApplePayOrderCreated","onApplePayCancel","onApplePayError","onApplePayMerchantValidation","create"],"sourceRoot":"../../src","sources":["ApplePayView.tsx"],"mappings":";;AAAA,OAAOA,K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C7BoB,MAA+B,IAAK;IACnCH,UAAU,CAACI,OAAO,GAAG,KAAK;IAC1BP,QAAQ,GAAG,CAAC;EACd,CAAC,EACD,CAACA,QAAQ,CACX,CAAC;EAED,MAAMe,WAAW,GAAG7B,WAAW,CAC5BuB,KAAyC,IAAK;IAC7CN,UAAU,CAACI,OAAO,GAAG,KAAK;IAC1BN,OAAO,GAAGQ,KAAK,CAACC,WAAW,CAACM,KAAK,CAAC;EACpC,CAAC,EACD,CAACf,OAAO,CACV,CAAC;EAED,MAAMgB,wBAAwB,GAAG/B,WAAW,CACzCuB,KAAwC,IAAK;IAC5CP,oBAAoB,GAAGO,KAAK,CAACC,WAAW,CAACC,IAAI,CAAC;EAChD,CAAC,EACD,CAACT,oBAAoB,CACvB,CAAC;EAED,IAAIf,QAAQ,CAAC+B,EAAE,KAAK,KAAK,EAAE;IACzB,OAAO,IAAI;EACb;EAEA,oBACE3B,IAAA,CAACF,kBAAkB;IACjBK,KAAK,EAAE,CAACA,KAAK,EAAEyB,MAAM,CAACC,SAAS,CAAE;IACjC3B,aAAa,EAAE4B,IAAI,CAACC,SAAS,CAAC7B,aAAa,CAAE;IAC7C8B,eAAe,EAAEnB,WAAY;IAC7BoB,eAAe,EAAEnB,WAAY;IAC7BoB,iBAAiB,EAAEjB,aAAc;IACjCkB,uBAAuB,EAAEd,mBAAoB;IAC7Ce,sBAAsB,EAAEd,kBAAmB;IAC3Ce,gBAAgB,EAAEd,YAAa;IAC/Be,eAAe,EAAEd,WAAY;IAC7Be,4BAA4B,EAAEb;EAAyB,CACxD,CAAC;AAEN;AAEA,MAAME,MAAM,GAAG/B,UAAU,CAAC2C,MAAM,CAAC;EAC/BX,SAAS,EAAE;IAAEA,SAAS,EAAE;EAAG;AAC7B,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ import { codegenNativeComponent } from 'react-native';
4
+ // @ts-ignore – no .d.ts for this path; codegen requires this exact import
5
+
6
+ export default codegenNativeComponent('NativeApplePayView');
7
+ //# sourceMappingURL=NativeApplePayView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../src","sources":["NativeApplePayView.ts"],"mappings":";;AACA,SAASA,sBAAsB,QAAQ,cAAc;AACrD;;AAeA,eAAeA,sBAAsB,CACnC,oBACF,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { TapApplePay } from "./ApplePayView.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TapApplePay"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,mBAAgB","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
+ import type { ApplePayConfiguration } from './types';
4
+ export interface TapApplePayProps {
5
+ configuration: ApplePayConfiguration;
6
+ style?: StyleProp<ViewStyle>;
7
+ onReady?: () => void;
8
+ onClick?: () => void;
9
+ onSuccess?: (data: string) => void;
10
+ onChargeCreated?: (data: string) => void;
11
+ onOrderCreated?: (data: string) => void;
12
+ onCancel?: () => void;
13
+ onError?: (error: string) => void;
14
+ onMerchantValidation?: (data: string) => void;
15
+ }
16
+ export declare function TapApplePay({ configuration, style, onReady, onClick, onSuccess, onChargeCreated, onOrderCreated, onCancel, onError, onMerchantValidation, }: Readonly<TapApplePayProps>): React.ReactElement | null;
17
+ //# sourceMappingURL=ApplePayView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApplePayView.d.ts","sourceRoot":"","sources":["../../../src/ApplePayView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,qBAAqB,CAAC;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,WAAW,CAAC,EAC1B,aAAa,EACb,KAAK,EACL,OAAO,EACP,OAAO,EACP,SAAS,EACT,eAAe,EACf,cAAc,EACd,QAAQ,EACR,OAAO,EACP,oBAAoB,GACrB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CA+ExD"}
@@ -0,0 +1,26 @@
1
+ import type { ViewProps } from 'react-native';
2
+ import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
3
+ export interface NativeApplePayViewProps extends ViewProps {
4
+ configuration: string;
5
+ onApplePayReady?: DirectEventHandler<Readonly<{}>>;
6
+ onApplePayClick?: DirectEventHandler<Readonly<{}>>;
7
+ onApplePaySuccess?: DirectEventHandler<Readonly<{
8
+ data: string;
9
+ }>>;
10
+ onApplePayChargeCreated?: DirectEventHandler<Readonly<{
11
+ data: string;
12
+ }>>;
13
+ onApplePayOrderCreated?: DirectEventHandler<Readonly<{
14
+ data: string;
15
+ }>>;
16
+ onApplePayCancel?: DirectEventHandler<Readonly<{}>>;
17
+ onApplePayError?: DirectEventHandler<Readonly<{
18
+ error: string;
19
+ }>>;
20
+ onApplePayMerchantValidation?: DirectEventHandler<Readonly<{
21
+ data: string;
22
+ }>>;
23
+ }
24
+ declare const _default: import("react-native/types_generated/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeApplePayViewProps>;
25
+ export default _default;
26
+ //# sourceMappingURL=NativeApplePayView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeApplePayView.d.ts","sourceRoot":"","sources":["../../../src/NativeApplePayView.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAEpF,MAAM,WAAW,uBAAwB,SAAQ,SAAS;IACxD,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,eAAe,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,iBAAiB,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACnE,uBAAuB,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACzE,sBAAsB,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACxE,gBAAgB,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACpD,eAAe,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAClE,4BAA4B,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;CAC/E;;AAED,wBAEE"}
@@ -0,0 +1,4 @@
1
+ export { TapApplePay } from './ApplePayView';
2
+ export type { TapApplePayProps } from './ApplePayView';
3
+ export type { ApplePayConfiguration, ApplePayMerchant, ApplePayCustomer, ApplePayContact, ApplePayPhone, ApplePayName, ApplePayInterface, ApplePayAcceptance, ApplePayTransaction, ApplePayShippingMethod, ApplePayItem, ApplePayFeatures, } from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,YAAY,EACV,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,71 @@
1
+ export interface ApplePayPhone {
2
+ countryCode: string;
3
+ number: string;
4
+ }
5
+ export interface ApplePayContact {
6
+ email?: string;
7
+ phone?: ApplePayPhone;
8
+ }
9
+ export interface ApplePayName {
10
+ lang: string;
11
+ first: string;
12
+ last: string;
13
+ middle?: string;
14
+ }
15
+ export interface ApplePayCustomer {
16
+ id?: string;
17
+ name?: ApplePayName[];
18
+ contact?: ApplePayContact;
19
+ }
20
+ export interface ApplePayMerchant {
21
+ id?: string;
22
+ identifier?: string;
23
+ }
24
+ export interface ApplePayInterface {
25
+ locale?: 'en' | 'ar';
26
+ theme?: 'dark' | 'light';
27
+ edges?: 'curved' | 'straight';
28
+ type?: 'book' | 'buy' | 'check-out' | 'pay' | 'plain' | 'subscribe';
29
+ }
30
+ export interface ApplePayShippingMethod {
31
+ label: string;
32
+ detail: string;
33
+ amount: string;
34
+ identifier: string;
35
+ }
36
+ export interface ApplePayItem {
37
+ type?: 'final' | 'pending';
38
+ label: string;
39
+ amount: string;
40
+ paymentTiming?: 'immediate' | 'recurring' | 'deferred' | 'automaticReload';
41
+ }
42
+ export interface ApplePayTransaction {
43
+ amount: string;
44
+ currency: string;
45
+ couponCode?: string;
46
+ shipping?: ApplePayShippingMethod[];
47
+ items?: ApplePayItem[];
48
+ }
49
+ export interface ApplePayAcceptance {
50
+ supportedBrands?: ('amex' | 'mada' | 'masterCard' | 'visa' | 'chinaUnionPay' | 'discover' | 'electron' | 'jcb' | 'maestro')[];
51
+ supportedCards?: ('credit' | 'debit')[];
52
+ supportedRegions?: ('LOCAL' | 'REGIONAL' | 'GLOBAL')[];
53
+ supportedCountries?: string[];
54
+ }
55
+ export interface ApplePayFeatures {
56
+ supportsCouponCode?: boolean;
57
+ shippingContactFields?: ('name' | 'phone' | 'email')[];
58
+ }
59
+ export interface ApplePayConfiguration {
60
+ /** Tap Payments public key */
61
+ publicKey: string;
62
+ /** Type of token to generate */
63
+ scope: 'AppleToken' | 'TapToken';
64
+ merchant: ApplePayMerchant;
65
+ customer: ApplePayCustomer;
66
+ interface?: ApplePayInterface;
67
+ acceptance?: ApplePayAcceptance;
68
+ transaction?: ApplePayTransaction;
69
+ features?: ApplePayFeatures;
70
+ }
71
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAA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AmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACpC,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,eAAe,CAAC,EAAE,CACd,MAAM,GACN,MAAM,GACN,YAAY,GACZ,MAAM,GACN,eAAe,GACf,UAAU,GACV,UAAU,GACV,KAAK,GACL,SAAS,CACZ,EAAE,CAAC;IACJ,cAAc,CAAC,EAAE,CAAC,QAAQ,GAAG,OAAO,CAAC,EAAE,CAAC;IACxC,gBAAgB,CAAC,EAAE,CAAC,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC,EAAE,CAAC;IACvD,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,CAAC,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,EAAE,CAAC;CACxD;AAED,MAAM,WAAW,qBAAqB;IACpC,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,KAAK,EAAE,YAAY,GAAG,UAAU,CAAC;IACjC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B"}
package/package.json ADDED
@@ -0,0 +1,177 @@
1
+ {
2
+ "name": "applepay-rn",
3
+ "version": "0.0.1",
4
+ "description": "A React Native wrapper around Tap Payments’ Apple Pay iOS SDK, enabling seamless Apple Pay integration in React Native apps.",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "*.podspec",
22
+ "react-native.config.js",
23
+ "!ios/build",
24
+ "!android/build",
25
+ "!android/gradle",
26
+ "!android/gradlew",
27
+ "!android/gradlew.bat",
28
+ "!android/local.properties",
29
+ "!**/__tests__",
30
+ "!**/__fixtures__",
31
+ "!**/__mocks__",
32
+ "!**/.*"
33
+ ],
34
+ "scripts": {
35
+ "example": "yarn workspace applepay-rn-example",
36
+ "clean": "del-cli lib",
37
+ "prepare": "bob build",
38
+ "typecheck": "tsc",
39
+ "release": "release-it --only-version",
40
+ "test": "jest",
41
+ "lint": "eslint \"**/*.{js,ts,tsx}\""
42
+ },
43
+ "keywords": [
44
+ "react-native",
45
+ "ios",
46
+ "android"
47
+ ],
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/Tap-Payments/ApplePay-RN.git"
51
+ },
52
+ "author": "MahmoudAllam <m.allam@tap.company> (https://github.com/mAllamTapPayments)",
53
+ "license": "MIT",
54
+ "bugs": {
55
+ "url": "https://github.com/Tap-Payments/ApplePay-RN/issues"
56
+ },
57
+ "homepage": "https://github.com/Tap-Payments/ApplePay-RN#readme",
58
+ "publishConfig": {
59
+ "registry": "https://registry.npmjs.org/"
60
+ },
61
+ "devDependencies": {
62
+ "@commitlint/config-conventional": "^20.5.0",
63
+ "@eslint/compat": "^2.0.3",
64
+ "@eslint/eslintrc": "^3.3.5",
65
+ "@eslint/js": "^10.0.1",
66
+ "@jest/globals": "^30.0.0",
67
+ "@react-native/babel-preset": "0.83.0",
68
+ "@react-native/eslint-config": "0.83.0",
69
+ "@release-it/conventional-changelog": "^10.0.6",
70
+ "@types/react": "^19.2.0",
71
+ "commitlint": "^20.5.0",
72
+ "del-cli": "^7.0.0",
73
+ "eslint": "^9.39.4",
74
+ "eslint-config-prettier": "^10.1.8",
75
+ "eslint-plugin-ft-flow": "^3.0.11",
76
+ "eslint-plugin-prettier": "^5.5.5",
77
+ "jest": "^30.3.0",
78
+ "lefthook": "^2.1.4",
79
+ "prettier": "^3.8.1",
80
+ "react": "19.1.0",
81
+ "react-native": "0.81.5",
82
+ "react-native-builder-bob": "^0.41.0",
83
+ "release-it": "^19.2.4",
84
+ "turbo": "^2.8.21",
85
+ "typescript": "^6.0.2"
86
+ },
87
+ "peerDependencies": {
88
+ "react": "*",
89
+ "react-native": "*"
90
+ },
91
+ "workspaces": [
92
+ "example"
93
+ ],
94
+ "packageManager": "yarn@4.11.0",
95
+ "react-native-builder-bob": {
96
+ "source": "src",
97
+ "output": "lib",
98
+ "targets": [
99
+ [
100
+ "module",
101
+ {
102
+ "esm": true
103
+ }
104
+ ],
105
+ [
106
+ "typescript",
107
+ {
108
+ "project": "tsconfig.build.json"
109
+ }
110
+ ]
111
+ ]
112
+ },
113
+ "codegenConfig": {
114
+ "name": "NativeApplePayViewSpec",
115
+ "type": "all",
116
+ "jsSrcsDir": "src",
117
+ "android": {
118
+ "javaPackageName": "com.applepayrn"
119
+ },
120
+ "ios": {
121
+ "components": {
122
+ "NativeApplePayView": {
123
+ "className": "ApplepayRnView"
124
+ }
125
+ }
126
+ }
127
+ },
128
+ "commitlint": {
129
+ "extends": [
130
+ "@commitlint/config-conventional"
131
+ ]
132
+ },
133
+ "release-it": {
134
+ "git": {
135
+ "commitMessage": "chore: release ${version}",
136
+ "tagName": "v${version}"
137
+ },
138
+ "npm": {
139
+ "publish": true
140
+ },
141
+ "github": {
142
+ "release": true
143
+ },
144
+ "plugins": {
145
+ "@release-it/conventional-changelog": {
146
+ "preset": {
147
+ "name": "angular"
148
+ }
149
+ }
150
+ }
151
+ },
152
+ "jest": {
153
+ "preset": "react-native",
154
+ "modulePathIgnorePatterns": [
155
+ "<rootDir>/example/node_modules",
156
+ "<rootDir>/lib/"
157
+ ]
158
+ },
159
+ "prettier": {
160
+ "quoteProps": "consistent",
161
+ "singleQuote": true,
162
+ "tabWidth": 2,
163
+ "trailingComma": "es5",
164
+ "useTabs": false
165
+ },
166
+ "create-react-native-library": {
167
+ "type": "fabric-view",
168
+ "languages": "kotlin-objc",
169
+ "tools": [
170
+ "lefthook",
171
+ "release-it",
172
+ "jest",
173
+ "eslint"
174
+ ],
175
+ "version": "0.59.2"
176
+ }
177
+ }