Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/actions/install-cocoapods/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ runs:
with:
path: |
sample/ios/Pods
key: ${{ runner.os }}-cocoapods-${{ hashFiles('sample/ios/Podfile.lock', 'sample/Gemfile.lock', 'sample/Gemfile', 'package.json', 'sample/package.json', 'modules/@shopify/checkout-sheet-kit/package.json', 'yarn.lock') }}
key: ${{ runner.os }}-cocoapods-na-${{ env.RCT_NEW_ARCH_ENABLED }}-${{ hashFiles('sample/ios/Podfile.lock', 'sample/Gemfile.lock', 'sample/Gemfile', 'package.json', 'sample/package.json', 'modules/@shopify/checkout-sheet-kit/package.json', 'yarn.lock') }}

- name: Install cocoapods
shell: bash
Expand All @@ -27,5 +27,6 @@ runs:
cd sample
bundle install
cd ios
bundle exec pod install --deployment --repo-update
echo "RCT_NEW_ARCH_ENABLED: ${{ env.RCT_NEW_ARCH_ENABLED }}"
bundle exec pod install --repo-update
cd $ROOT
29 changes: 25 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,18 @@ jobs:
create-new-comment: false

test-android:
name: Run Android Tests
name: Run Android Tests (${{ matrix.arch }})
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [lint, test]
strategy:
fail-fast: false
matrix:
include:
- arch: Legacy arch
new_arch_enabled: 'false'
- arch: New arch
new_arch_enabled: 'true'
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
Expand All @@ -101,11 +109,12 @@ jobs:
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}

- name: Run Android tests
- name: Run Android tests (${{ matrix.arch }})
timeout-minutes: 20
env:
GRADLE_OPTS: -Xmx4g -XX:MaxMetaspaceSize=768m
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
ORG_GRADLE_PROJECT_newArchEnabled: ${{ matrix.new_arch_enabled }}
run: |
echo "JAVA_HOME: $JAVA_HOME"
java -version
Expand All @@ -115,10 +124,18 @@ jobs:
yarn sample test:android --no-daemon

test-ios:
name: Run Swift Tests
name: Run Swift Tests (${{ matrix.arch }})
runs-on: macos-15-xlarge
timeout-minutes: 20
needs: [lint, test]
strategy:
fail-fast: false
matrix:
include:
- arch: Legacy arch
new_arch_enabled: 'false'
- arch: New arch
new_arch_enabled: 'true'
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
Expand All @@ -139,7 +156,11 @@ jobs:

- name: Install cocoapods
uses: ./.github/actions/install-cocoapods
env:
RCT_NEW_ARCH_ENABLED: ${{ matrix.new_arch_enabled }}

- name: Run Swift tests
- name: Run Swift tests (${{ matrix.arch }})
env:
RCT_NEW_ARCH_ENABLED: ${{ matrix.new_arch_enabled }}
run: |
yarn sample test:ios
11 changes: 11 additions & 0 deletions modules/@shopify/checkout-sheet-kit/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

// Note: this is where the module class is chosen, based on the RN architecture
sourceSets {
main.java.srcDirs += ["src/shared/java"]

if (isNewArchitectureEnabled()) {
main.java.srcDirs += ["src/newarch/java"]
} else {
main.java.srcDirs += ["src/legacy/java"]
}
}
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
MIT License
Copyright 2023 - Present, Shopify Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.shopify.reactnative.checkoutsheetkit;

import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;

import java.util.Map;

/**
* @note
*
* This is the legacy module class for the ShopifyCheckoutSheetKit module.
* It is used to support applications using React Native with the old
* legacy architecture.
*/

public class ShopifyCheckoutSheetKitModule extends ReactContextBaseJavaModule {
private final CheckoutKitModule common;
public static com.shopify.checkoutsheetkit.Configuration checkoutConfig;

public ShopifyCheckoutSheetKitModule(ReactApplicationContext reactContext) {
super(reactContext);
this.common = new CheckoutKitModule(reactContext);
ShopifyCheckoutSheetKitModule.checkoutConfig = CheckoutKitModule.checkoutConfig;
}

@Override
public String getName() {
return common.getName();
}

@Override
public Map<String, Object> getConstants() {
return common.getConstants();
}

@ReactMethod
public void addListener(String eventName) {
common.addListener(eventName);
}

@ReactMethod
public void configureAcceleratedCheckouts(
String storefrontDomain,
String storefrontAccessToken,
String customerEmail,
String customerPhoneNumber,
String customerAccessToken,
String applePayMerchantIdentifier,
ReadableArray applePayContactFields,
Promise promise) {
common.configureAcceleratedCheckouts(
storefrontDomain,
storefrontAccessToken,
customerEmail,
customerPhoneNumber,
customerAccessToken,
applePayMerchantIdentifier,
applePayContactFields,
promise);
}

@ReactMethod
public void dismiss() {
common.dismiss();
}

@ReactMethod
public void getConfig(Promise promise) {
common.getConfig(promise);
}

public String getVersion() {
return common.getVersion();
}

@ReactMethod
public void initiateGeolocationRequest(boolean allow) {
common.initiateGeolocationRequest(allow);
}

@ReactMethod
public void invalidateCache() {
common.invalidateCache();
}

@ReactMethod
public void isAcceleratedCheckoutAvailable(Promise promise) {
common.isAcceleratedCheckoutAvailable(promise);
}

@ReactMethod
public void isApplePayAvailable(Promise promise) {
common.isApplePayAvailable(promise);
}

@ReactMethod
public void preload(String checkoutURL) {
common.preload(checkoutURL);
}

@ReactMethod
public void present(String checkoutURL) {
common.present(checkoutURL);
}

@ReactMethod
public void removeListeners(double count) {
common.removeListeners(count);
}

@ReactMethod
public void setConfig(ReadableMap config) {
common.setConfig(config);
ShopifyCheckoutSheetKitModule.checkoutConfig = CheckoutKitModule.checkoutConfig;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
MIT License
Copyright 2023 - Present, Shopify Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.shopify.reactnative.checkoutsheetkit;

import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;

import java.util.Map;

/**
* @note
*
* This is the new architecture module class for the
* ShopifyCheckoutSheetKit module.
* It is used to support applications using React Native with the new
* new architecture.
*/

public class ShopifyCheckoutSheetKitModule extends NativeShopifyCheckoutSheetKitSpec {
private final CheckoutKitModule common;
public static com.shopify.checkoutsheetkit.Configuration checkoutConfig;

public ShopifyCheckoutSheetKitModule(ReactApplicationContext reactContext) {
super(reactContext);
this.common = new CheckoutKitModule(reactContext);
ShopifyCheckoutSheetKitModule.checkoutConfig = CheckoutKitModule.checkoutConfig;
}

@Override
public Map<String, Object> getConstants() {
return common.getConstants();
}

@Override
public void addListener(String eventName) {
common.addListener(eventName);
}

@Override
public void removeListeners(double count) {
common.removeListeners(count);
}

@Override
public void present(String checkoutURL) {
common.present(checkoutURL);
}

@Override
public void dismiss() {
common.dismiss();
}

@Override
public void preload(String checkoutURL) {
common.preload(checkoutURL);
}

@Override
public void invalidateCache() {
common.invalidateCache();
}

@Override
public void getConfig(Promise promise) {
common.getConfig(promise);
}

@Override
public void setConfig(ReadableMap config) {
common.setConfig(config);
ShopifyCheckoutSheetKitModule.checkoutConfig = CheckoutKitModule.checkoutConfig;
}

@Override
public void isApplePayAvailable(Promise promise) {
common.isApplePayAvailable(promise);
}

@Override
public void isAcceleratedCheckoutAvailable(Promise promise) {
common.isAcceleratedCheckoutAvailable(promise);
}

@Override
public void configureAcceleratedCheckouts(
String storefrontDomain,
String storefrontAccessToken,
String customerEmail,
String customerPhoneNumber,
String customerAccessToken,
String applePayMerchantIdentifier,
ReadableArray applePayContactFields,
Promise promise) {
common.configureAcceleratedCheckouts(
storefrontDomain,
storefrontAccessToken,
customerEmail,
customerPhoneNumber,
customerAccessToken,
applePayMerchantIdentifier,
applePayContactFields,
promise);
}

@Override
public void initiateGeolocationRequest(boolean allow) {
common.initiateGeolocationRequest(allow);
}

@Override
public String getVersion() {
return common.getVersion();
}
}
Loading
Loading