Skip to content

Commit f3bd462

Browse files
authored
Upgrade underlying SDKs (checkout-sheet-kit) (#52)
* Upgrade underlying SDKs (checkout-sheet-kit) * Update test to reflect to new preloading.enabled default (true)
1 parent ff0b2a8 commit f3bd462

File tree

14 files changed

+273
-270
lines changed

14 files changed

+273
-270
lines changed

modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Pod::Spec.new do |s|
1515
s.authors = package["author"]
1616

1717
s.platforms = { :ios => "13.0" }
18-
s.source = { :git => "https://github.com/Shopify/checkout-kit-react-native.git", :tag => "#{s.version}" }
18+
s.source = { :git => "https://github.com/Shopify/checkout-sheet-kit-react-native.git", :tag => "#{s.version}" }
1919

2020
s.source_files = "ios/*.{h,m,mm,swift}"
2121

2222
s.dependency "React-Core"
23-
s.dependency "ShopifyCheckoutKit", "~> 0.8.0"
23+
s.dependency "ShopifyCheckoutSheetKit", "~> 0.9"
2424

2525
if fabric_enabled
2626
install_modules_dependencies(s)

modules/@shopify/checkout-sheet-kit/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ dependencies {
9191
//noinspection GradleDynamicVersion
9292
implementation "com.facebook.react:react-native:+"
9393
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.0"
94-
implementation("com.shopify:checkout-kit:${SHOPIFY_CHECKOUT_SDK_VERSION}")
95-
debugImplementation("com.shopify:checkout-kit:${SHOPIFY_CHECKOUT_SDK_VERSION}")
94+
implementation("com.shopify:checkout-sheet-kit:${SHOPIFY_CHECKOUT_SDK_VERSION}")
95+
debugImplementation("com.shopify:checkout-sheet-kit:${SHOPIFY_CHECKOUT_SDK_VERSION}")
9696
}
9797

modules/@shopify/checkout-sheet-kit/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ ndkVersion=23.1.7779620
55
buildToolsVersion = "33.0.0"
66

77
# Version of Shopify Checkout SDK to use with React Native
8-
SHOPIFY_CHECKOUT_SDK_VERSION=0.3.3
8+
SHOPIFY_CHECKOUT_SDK_VERSION=0.4.1

modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/CustomCheckoutEventProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ of this software and associated documentation files (the "Software"), to deal
2424
package com.shopify.reactnative.checkoutsheetkit;
2525

2626
import android.content.Context;
27-
import com.shopify.checkoutkit.*;
27+
import com.shopify.checkoutsheetkit.*;
2828
import com.facebook.react.modules.core.DeviceEventManagerModule;
2929
import com.facebook.react.bridge.ReactMethod;
3030
import com.facebook.react.bridge.ReactApplicationContext;
@@ -64,7 +64,7 @@ public void onCheckoutCanceled() {
6464

6565
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
6666
reactContext
67-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
68-
.emit(eventName, params);
67+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
68+
.emit(eventName, params);
6969
}
7070
}

modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ of this software and associated documentation files (the "Software"), to deal
3333
import com.facebook.react.bridge.ReactMethod;
3434
import com.facebook.react.bridge.ReadableMap;
3535
import com.facebook.react.bridge.WritableNativeMap;
36-
import com.shopify.checkoutkit.*;
36+
import com.shopify.checkoutsheetkit.*;
3737

3838
import java.util.HashMap;
3939
import java.util.Map;
@@ -60,7 +60,7 @@ public String getName() {
6060
@Override
6161
public Map<String, Object> getConstants() {
6262
final Map<String, Object> constants = new HashMap<>();
63-
constants.put("version", ShopifyCheckoutKit.version);
63+
constants.put("version", ShopifyCheckoutSheetKit.version);
6464
return constants;
6565
}
6666

@@ -81,7 +81,7 @@ public void present(String checkoutURL) {
8181
Context appContext = getReactApplicationContext();
8282
CheckoutEventProcessor checkoutEventProcessor = new CustomCheckoutEventProcessor(appContext, this.reactContext);
8383
currentActivity.runOnUiThread(() -> {
84-
ShopifyCheckoutKit.present(checkoutURL, (ComponentActivity) currentActivity,
84+
ShopifyCheckoutSheetKit.present(checkoutURL, (ComponentActivity) currentActivity,
8585
checkoutEventProcessor);
8686
});
8787
}
@@ -92,7 +92,7 @@ public void preload(String checkoutURL) {
9292
Activity currentActivity = getCurrentActivity();
9393

9494
if (currentActivity instanceof ComponentActivity) {
95-
ShopifyCheckoutKit.preload(checkoutURL, (ComponentActivity) currentActivity);
95+
ShopifyCheckoutSheetKit.preload(checkoutURL, (ComponentActivity) currentActivity);
9696
}
9797
}
9898

@@ -216,7 +216,7 @@ private ColorScheme getColors(ColorScheme colorScheme, ReadableMap config) {
216216
public void setConfig(ReadableMap config) {
217217
Context context = getReactApplicationContext();
218218

219-
ShopifyCheckoutKit.configure(configuration -> {
219+
ShopifyCheckoutSheetKit.configure(configuration -> {
220220
if (config.hasKey("preloading")) {
221221
configuration.setPreloading(new Preloading(config.getBoolean("preloading")));
222222
}

modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO
2222
*/
2323

2424
import Foundation
25-
import ShopifyCheckoutKit
25+
import ShopifyCheckoutSheetKit
2626
import UIKit
2727
import React
2828

@@ -63,7 +63,7 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
6363
}
6464
}
6565

66-
func checkoutDidFail(error checkoutError: ShopifyCheckoutKit.CheckoutError) {
66+
func checkoutDidFail(error checkoutError: ShopifyCheckoutSheetKit.CheckoutError) {
6767
if hasListeners {
6868
let errorInfo: [String: Any] = [
6969
"message": checkoutError.localizedDescription
@@ -83,7 +83,7 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
8383

8484
@objc override func constantsToExport() -> [AnyHashable: Any]! {
8585
return [
86-
"version": ShopifyCheckoutKit.version
86+
"version": ShopifyCheckoutSheetKit.version
8787
]
8888
}
8989

@@ -92,31 +92,31 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
9292
let sharedDelegate = UIApplication.shared.delegate
9393

9494
if let url = URL(string: checkoutURL), let rootViewController = sharedDelegate?.window??.rootViewController {
95-
ShopifyCheckoutKit.present(checkout: url, from: rootViewController, delegate: self)
95+
ShopifyCheckoutSheetKit.present(checkout: url, from: rootViewController, delegate: self)
9696
}
9797
}
9898
}
9999

100100
@objc func preload(_ checkoutURL: String) {
101101
DispatchQueue.main.async {
102102
if let url = URL(string: checkoutURL) {
103-
ShopifyCheckoutKit.preload(checkout: url)
103+
ShopifyCheckoutSheetKit.preload(checkout: url)
104104
}
105105
}
106106
}
107107

108-
private func getColorScheme(_ colorScheme: String) -> ShopifyCheckoutKit.Configuration.ColorScheme {
108+
private func getColorScheme(_ colorScheme: String) -> ShopifyCheckoutSheetKit.Configuration.ColorScheme {
109109
switch colorScheme {
110110
case "web_default":
111-
return ShopifyCheckoutKit.Configuration.ColorScheme.web
111+
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.web
112112
case "automatic":
113-
return ShopifyCheckoutKit.Configuration.ColorScheme.automatic
113+
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.automatic
114114
case "light":
115-
return ShopifyCheckoutKit.Configuration.ColorScheme.light
115+
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.light
116116
case "dark":
117-
return ShopifyCheckoutKit.Configuration.ColorScheme.dark
117+
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.dark
118118
default:
119-
return ShopifyCheckoutKit.Configuration.ColorScheme.automatic
119+
return ShopifyCheckoutSheetKit.Configuration.ColorScheme.automatic
120120
}
121121
}
122122

@@ -125,26 +125,26 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
125125
let iosConfig = colorConfig?["ios"] as? [String: String]
126126

127127
if let preloading = configuration["preloading"] as? Bool {
128-
ShopifyCheckoutKit.configuration.preloading.enabled = preloading
128+
ShopifyCheckoutSheetKit.configuration.preloading.enabled = preloading
129129
}
130130

131131
if let colorScheme = configuration["colorScheme"] as? String {
132-
ShopifyCheckoutKit.configuration.colorScheme = getColorScheme(colorScheme)
132+
ShopifyCheckoutSheetKit.configuration.colorScheme = getColorScheme(colorScheme)
133133
}
134134

135135
if let spinnerColorHex = iosConfig?["spinnerColor"] as? String {
136-
ShopifyCheckoutKit.configuration.spinnerColor = UIColor(hex: spinnerColorHex)
136+
ShopifyCheckoutSheetKit.configuration.spinnerColor = UIColor(hex: spinnerColorHex)
137137
}
138138

139139
if let backgroundColorHex = iosConfig?["backgroundColor"] as? String {
140-
ShopifyCheckoutKit.configuration.backgroundColor = UIColor(hex: backgroundColorHex)
140+
ShopifyCheckoutSheetKit.configuration.backgroundColor = UIColor(hex: backgroundColorHex)
141141
}
142142
}
143143

144144
@objc func getConfig(_ resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
145145
let config: [String: Any] = [
146-
"preloading": ShopifyCheckoutKit.configuration.preloading.enabled,
147-
"colorScheme": ShopifyCheckoutKit.configuration.colorScheme.rawValue
146+
"preloading": ShopifyCheckoutSheetKit.configuration.preloading.enabled,
147+
"colorScheme": ShopifyCheckoutSheetKit.configuration.colorScheme.rawValue
148148
]
149149

150150
resolve(config)

modules/@shopify/checkout-sheet-kit/src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
type ShopifyCheckoutSheetKit,
3636
} from './index.d';
3737

38-
const RNShopifyCheckoutKit = NativeModules.ShopifyCheckoutSheetKit;
38+
const RNShopifyCheckoutSheetKit = NativeModules.ShopifyCheckoutSheetKit;
3939

4040
if (!('ShopifyCheckoutSheetKit' in NativeModules)) {
4141
throw new Error(`
@@ -46,7 +46,7 @@ if (!('ShopifyCheckoutSheetKit' in NativeModules)) {
4646

4747
class ShopifyCheckoutSheet implements ShopifyCheckoutSheetKit {
4848
private static eventEmitter: NativeEventEmitter = new NativeEventEmitter(
49-
RNShopifyCheckoutKit,
49+
RNShopifyCheckoutSheetKit,
5050
);
5151

5252
constructor(configuration?: Configuration) {
@@ -55,22 +55,22 @@ class ShopifyCheckoutSheet implements ShopifyCheckoutSheetKit {
5555
}
5656
}
5757

58-
public readonly version: string = RNShopifyCheckoutKit.version;
58+
public readonly version: string = RNShopifyCheckoutSheetKit.version;
5959

6060
public preload(checkoutUrl: string): void {
61-
RNShopifyCheckoutKit.preload(checkoutUrl);
61+
RNShopifyCheckoutSheetKit.preload(checkoutUrl);
6262
}
6363

6464
public present(checkoutUrl: string): void {
65-
RNShopifyCheckoutKit.present(checkoutUrl);
65+
RNShopifyCheckoutSheetKit.present(checkoutUrl);
6666
}
6767

6868
public async getConfig(): Promise<Configuration> {
69-
return RNShopifyCheckoutKit.getConfig();
69+
return RNShopifyCheckoutSheetKit.getConfig();
7070
}
7171

7272
public setConfig(configuration: Configuration): void {
73-
RNShopifyCheckoutKit.setConfig(configuration);
73+
RNShopifyCheckoutSheetKit.setConfig(configuration);
7474
}
7575

7676
public addEventListener(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"pod-install": "^0.1.39",
4242
"prettier": "^2.4.1",
4343
"react": "^18.2.0",
44-
"react-native": "0.72.9",
44+
"react-native": "0.72.8",
4545
"react-native-dotenv": "^3.4.9",
4646
"react-native-gradle-plugin": "^0.71.19",
4747
"react-test-renderer": "18.2.0",

sample/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ dependencies {
130130
androidTestImplementation "org.mockito:mockito-android:4.11.0"
131131
testImplementation "org.mockito:mockito-inline:4.6.1"
132132
testImplementation "org.assertj:assertj-core:3.24.2"
133-
testImplementation("com.shopify:checkout-kit:${SHOPIFY_CHECKOUT_SDK_VERSION}")
133+
testImplementation("com.shopify:checkout-sheet-kit:${SHOPIFY_CHECKOUT_SDK_VERSION}")
134134

135135
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
136136
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {

sample/android/app/src/test/java/com/shopify/checkoutkitreactnative/ShopifyCheckoutSheetKitModuleTest.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import com.facebook.react.bridge.JavaOnlyMap;
66
import com.facebook.react.bridge.ReactApplicationContext;
7-
import com.shopify.checkoutkit.ShopifyCheckoutKit;
7+
import com.shopify.checkoutsheetkit.ShopifyCheckoutSheetKit;
88
import com.shopify.reactnative.checkoutsheetkit.ShopifyCheckoutSheetKitModule;
99

1010
import org.junit.Before;
@@ -43,44 +43,46 @@ public void setup() {
4343

4444
@Test
4545
public void callsPresentWithCheckoutURL() {
46-
try (MockedStatic<ShopifyCheckoutKit> mockedShopifyCheckoutKit = Mockito.mockStatic(ShopifyCheckoutKit.class)) {
46+
try (MockedStatic<ShopifyCheckoutSheetKit> mockedShopifyCheckoutSheetKit = Mockito
47+
.mockStatic(ShopifyCheckoutSheetKit.class)) {
4748
String checkoutUrl = "https://shopify.com";
4849
shopifyCheckoutSheetKitModule.present(checkoutUrl);
4950

5051
verify(mockComponentActivity).runOnUiThread(runnableCaptor.capture());
5152
runnableCaptor.getValue().run();
5253

53-
mockedShopifyCheckoutKit.verify(() -> {
54-
ShopifyCheckoutKit.present(eq(checkoutUrl), any(), any());
54+
mockedShopifyCheckoutSheetKit.verify(() -> {
55+
ShopifyCheckoutSheetKit.present(eq(checkoutUrl), any(), any());
5556
});
5657
}
5758
}
5859

5960
@Test
6061
public void callsPreloadWithCheckoutURL() {
61-
try (MockedStatic<ShopifyCheckoutKit> mockedShopifyCheckoutKit = Mockito.mockStatic(ShopifyCheckoutKit.class)) {
62+
try (MockedStatic<ShopifyCheckoutSheetKit> mockedShopifyCheckoutSheetKit = Mockito
63+
.mockStatic(ShopifyCheckoutSheetKit.class)) {
6264
String checkoutUrl = "https://shopify.com";
6365
shopifyCheckoutSheetKitModule.preload(checkoutUrl);
6466

65-
mockedShopifyCheckoutKit.verify(() -> {
66-
ShopifyCheckoutKit.preload(eq(checkoutUrl), any());
67+
mockedShopifyCheckoutSheetKit.verify(() -> {
68+
ShopifyCheckoutSheetKit.preload(eq(checkoutUrl), any());
6769
});
6870
}
6971
}
7072

7173
@Test
7274
public void setsInternalConfig() {
73-
assertFalse(ShopifyCheckoutSheetKitModule.checkoutConfig.getPreloading().getEnabled());
75+
assertTrue(ShopifyCheckoutSheetKitModule.checkoutConfig.getPreloading().getEnabled());
7476

7577
JavaOnlyMap updatedConfig = new JavaOnlyMap();
76-
updatedConfig.putBoolean("preloading", true);
78+
updatedConfig.putBoolean("preloading", false);
7779
updatedConfig.putString("colorScheme", "dark");
7880
shopifyCheckoutSheetKitModule.setConfig(updatedConfig);
7981

8082
boolean preloadingEnabled = ShopifyCheckoutSheetKitModule.checkoutConfig.getPreloading().getEnabled();
8183
String colorScheme = ShopifyCheckoutSheetKitModule.checkoutConfig.getColorScheme().getId();
8284

83-
assertTrue(preloadingEnabled);
85+
assertFalse(preloadingEnabled);
8486
assertEquals(colorScheme, "dark");
8587
}
8688
}

0 commit comments

Comments
 (0)