@@ -30,69 +30,18 @@ of this software and associated documentation files (the "Software"), to deal
3030import com .facebook .react .bridge .Promise ;
3131import com .facebook .react .bridge .ReactApplicationContext ;
3232import com .facebook .react .bridge .ReactContextBaseJavaModule ;
33- import com .facebook .react .turbomodule .core .interfaces .TurboModule ;
34- #if RCT_NEW_ARCH_ENABLED
35- import com .facebook .react .bridge .ReactApplicationContext ;
33+ import com .shopify .reactnative .checkoutsheetkit .NativeShopifyCheckoutSheetKitSpec ;
3634import com .facebook .react .bridge .ReactMethod ;
37- import com .facebook .react .bridge .Promise ;
38- import com .facebook .react .module .annotations .ReactModule ;
3935import com .facebook .react .bridge .ReadableMap ;
40- import com .facebook .react .bridge .WritableNativeMap ;
41- import com .facebook .react .bridge .UiThreadUtil ;
4236import com .facebook .react .bridge .ReadableArray ;
43- import com .facebook .react .bridge .ReactNoCrashSoftException ;
44- import com .facebook .react .module .annotations .ReactModuleList ;
45- import com .facebook .react .bridge .NativeModule ;
46- import com .facebook .react .turbomodule .core .interfaces .TurboModule ;
47- import com .facebook .react .fabric .events .EventDispatcher ;
48- import com .facebook .react .uimanager .events .EventDispatcherImpl ;
49- import com .facebook .react .codegen .module .JavaModuleWrapper ;
50- import com .facebook .react .bridge .ReactMarker ;
51- import com .facebook .react .modules .core .DeviceEventManagerModule ;
52- import com .facebook .react .modules .core .DeviceEventManagerModule .RCTDeviceEventEmitter ;
53- import com .facebook .react .bridge .NoSuchKeyException ;
54- import com .facebook .react .module .model .ReactModuleInfo ;
55- import com .facebook .react .module .model .ReactModuleInfoProvider ;
56- import com .facebook .jni .HybridData ;
57- import com .facebook .proguard .annotations .DoNotStrip ;
58- import com .facebook .react .bridge .JavaScriptContextHolder ;
59- import com .facebook .proguard .annotations .DoNotStripAny ;
60- import com .facebook .react .bridge .queue .MessageQueueThread ;
61- import com .facebook .react .bridge .Dynamic ;
62- import com .facebook .react .bridge .Arguments ;
63- import com .facebook .react .common .MapBuilder ;
64- import com .facebook .react .codegen .ReactNativeFeatureFlags ;
65- import com .facebook .react .bridge .WritableMap ;
66- import com .facebook .react .bridge .ReactSoftExceptionLogger ;
67- import com .facebook .react .bridge .Callback ;
68- import com .facebook .react .modules .core .DeviceEventManagerModule ;
69- import com .facebook .react .bridge .ActivityEventListener ;
70- import com .facebook .react .bridge .BaseJavaModule ;
71- import com .facebook .react .bridge .LifecycleEventListener ;
72- // Generated spec
73- import com .facebook .react .bridge .ReactContext ;
74- import com .facebook .react .module .annotations .ReactModule ;
75- import com .facebook .react .module .annotations .ReactModuleList ;
76- import com .facebook .react .turbomodule .core .interfaces .TurboModule ;
77- import com .facebook .react .bridge .WritableMap ;
78- import com .facebook .react .bridge .arguments ;
79- import com .facebook .react .module .model .ReactModuleInfo ;
80- import com .facebook .react .module .model .ReactModuleInfoProvider ;
81- import com .facebook .react .module .annotations .ReactModule ;
82- import com .facebook .react .turbomodule .core .interfaces .TurboModule ;
83- #endif
84- import com .facebook .react .bridge .ReactMethod ;
85- import com .facebook .react .bridge .ReadableMap ;
8637import com .facebook .react .bridge .WritableNativeMap ;
8738import com .shopify .checkoutsheetkit .*;
8839
8940import java .util .HashMap ;
9041import java .util .Map ;
9142import java .util .Objects ;
9243
93- public class ShopifyCheckoutSheetKitModule extends ReactContextBaseJavaModule implements TurboModule {
94- private static final String MODULE_NAME = "ShopifyCheckoutSheetKit" ;
95-
44+ public class ShopifyCheckoutSheetKitModule extends NativeShopifyCheckoutSheetKitSpec {
9645 public static Configuration checkoutConfig = new Configuration ();
9746
9847 private final ReactApplicationContext reactContext ;
@@ -112,12 +61,6 @@ public ShopifyCheckoutSheetKitModule(ReactApplicationContext reactContext) {
11261 });
11362 }
11463
115- @ NonNull
116- @ Override
117- public String getName () {
118- return MODULE_NAME ;
119- }
120-
12164 @ Override
12265 public Map <String , Object > getConstants () {
12366 final Map <String , Object > constants = new HashMap <>();
@@ -131,11 +74,12 @@ public void addListener(String eventName) {
13174 }
13275
13376 @ ReactMethod
134- public void removeListeners (Integer count ) {
77+ public void removeListeners (double count ) {
13578 // No-op but required for RN to register module
13679 }
13780
13881 @ ReactMethod
82+ @ Override
13983 public void present (String checkoutURL ) {
14084 Activity currentActivity = getCurrentActivity ();
14185 if (currentActivity instanceof ComponentActivity ) {
@@ -148,6 +92,7 @@ public void present(String checkoutURL) {
14892 }
14993
15094 @ ReactMethod
95+ @ Override
15196 public void dismiss () {
15297 if (checkoutSheet != null ) {
15398 checkoutSheet .dismiss ();
@@ -156,6 +101,7 @@ public void dismiss() {
156101 }
157102
158103 @ ReactMethod
104+ @ Override
159105 public void preload (String checkoutURL ) {
160106 Activity currentActivity = getCurrentActivity ();
161107
@@ -165,11 +111,13 @@ public void preload(String checkoutURL) {
165111 }
166112
167113 @ ReactMethod
114+ @ Override
168115 public void invalidateCache () {
169116 ShopifyCheckoutSheetKit .invalidate ();
170117 }
171118
172119 @ ReactMethod
120+ @ Override
173121 public void getConfig (Promise promise ) {
174122 WritableNativeMap resultConfig = new WritableNativeMap ();
175123
@@ -180,6 +128,7 @@ public void getConfig(Promise promise) {
180128 }
181129
182130 @ ReactMethod
131+ @ Override
183132 public void setConfig (ReadableMap config ) {
184133 Context context = getReactApplicationContext ();
185134
@@ -213,13 +162,41 @@ public void setConfig(ReadableMap config) {
213162 });
214163 }
215164
165+ @ Override
166+ public void isApplePayAvailable (Promise promise ) {
167+ promise .resolve (false );
168+ }
169+
170+ @ Override
171+ public void isAcceleratedCheckoutAvailable (Promise promise ) {
172+ promise .resolve (false );
173+ }
174+
175+ @ Override
176+ public void configureAcceleratedCheckouts (
177+ String storefrontDomain ,
178+ String storefrontAccessToken ,
179+ String customerEmail ,
180+ String customerPhoneNumber ,
181+ String customerAccessToken ,
182+ String applePayMerchantIdentifier ,
183+ ReadableArray applePayContactFields ,
184+ Promise promise ) {
185+ promise .resolve (false );
186+ }
187+
216188 @ ReactMethod
217- public void initiateGeolocationRequest (Boolean allow ) {
189+ public void initiateGeolocationRequest (boolean allow ) {
218190 if (checkoutEventProcessor != null ) {
219191 checkoutEventProcessor .invokeGeolocationCallback (allow );
220192 }
221193 }
222194
195+ @ Override
196+ public String getVersion () {
197+ return ShopifyCheckoutSheetKit .version ;
198+ }
199+
223200 // Private
224201
225202 private ColorScheme getColorScheme (String colorScheme ) {
@@ -308,10 +285,10 @@ private Colors createColorsFromConfig(ReadableMap config) {
308285 headerBackground ,
309286 headerFont ,
310287 progressIndicator ,
311- // Parameter allows passing a custom drawable, we'll just support custom color for now
288+ // Parameter allows passing a custom drawable, we'll just support custom color
289+ // for now
312290 null ,
313- closeButtonColor
314- );
291+ closeButtonColor );
315292 }
316293
317294 return null ;
0 commit comments