From 63d9aae764682e08ee0f8f10bce1c251c5c60e59 Mon Sep 17 00:00:00 2001 From: Serena Zhang Date: Tue, 14 May 2024 09:36:03 +1000 Subject: [PATCH 1/3] update example app for new alpha.2 release --- ios/Podfile.lock | 6 +-- package-lock.json | 8 ++-- package.json | 2 +- src/App.tsx | 10 ++-- src/CheckoutPage.tsx | 13 ++++- src/PayButton.tsx | 48 +++++++++++++++++++ .../subflows/wallets/assert-gpay.yml | 2 +- 7 files changed, 72 insertions(+), 17 deletions(-) create mode 100644 src/PayButton.tsx diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 57c360d..86b8f7b 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -491,7 +491,7 @@ PODS: - RNSVG (14.1.0): - React-Core - SocketRocket (0.6.1) - - tyro-pay-api-react-native (0.0.1-alpha.1): + - tyro-pay-api-react-native (0.0.1-alpha.2): - RCT-Folly (= 2021.07.22.00) - React-Core - Yoga (1.14.0) @@ -724,10 +724,10 @@ SPEC CHECKSUMS: ReactCommon: 5f704096ccf7733b390f59043b6fa9cc180ee4f6 RNSVG: ba3e7232f45e34b7b47e74472386cf4e1a676d0a SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 - tyro-pay-api-react-native: 6300368a6f854e02059a4bf1c298150944c04aab + tyro-pay-api-react-native: e9ccad89ca70def21c2f3231af42701250dee86f Yoga: 4c3aa327e4a6a23eeacd71f61c81df1bcdf677d5 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a PODFILE CHECKSUM: 18fd48e808e852bd26c1f45356abe046e8173b89 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/package-lock.json b/package-lock.json index 6306dea..e66af4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "@tyro/tyro-pay-api-react-native-example-app", "version": "0.0.1", "dependencies": { - "@tyro/tyro-pay-api-react-native": "0.0.1-alpha.1", + "@tyro/tyro-pay-api-react-native": "^0.0.1-alpha.2", "react": "18.2.0", "react-native": "0.72.7", "react-native-svg": "^14.1.0", @@ -4780,9 +4780,9 @@ } }, "node_modules/@tyro/tyro-pay-api-react-native": { - "version": "0.0.1-alpha.1", - "resolved": "https://npm.pkg.github.com/download/@tyro/tyro-pay-api-react-native/0.0.1-alpha.1/6241a366472ee5d2aee22a816bbb0e1481d7c34f", - "integrity": "sha512-PX96OZ96xX7o2K+lfJwXOHEgPYDTHZLy5g/zuQJKLgCoAJyU1GXqRPS4qXkaEGTeIatZGQUUqk3qK2LHEaJXsA==", + "version": "0.0.1-alpha.2", + "resolved": "https://npm.pkg.github.com/download/@tyro/tyro-pay-api-react-native/0.0.1-alpha.2/9eab9ec03f2b9d3e62bb723166cd6c5850007779", + "integrity": "sha512-c+uSrKIB1426GzsregsAh+Mb8WGhkuRR/NuyzCWpGWi+CqFtyi+Mwpq2yYX2kont/xcw/QesUTVP283OdJZoBw==", "peerDependencies": { "react": "*", "react-native": "*", diff --git a/package.json b/package.json index 225a157..6e1175a 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "gradlew:build:sdk": "cd android && chmod +x ./gradlew && ./gradlew --no-daemon -S -Dorg.gradle.dependency.verification=off clean build" }, "dependencies": { - "@tyro/tyro-pay-api-react-native": "0.0.1-alpha.1", + "@tyro/tyro-pay-api-react-native": "^0.0.1-alpha.2", "react": "18.2.0", "react-native": "0.72.7", "react-native-svg": "^14.1.0", diff --git a/src/App.tsx b/src/App.tsx index fd6b6b9..d620e42 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -54,14 +54,10 @@ function App(): JSX.Element { googlePay: { enabled: true, merchantName: 'Example Merchant', - supportedNetworks: ['mastercard'], }, - }, - styleProps: { - googlePayButton: { - buttonColor: 'black', - buttonType: 'pay', - buttonBorderRadius: 4, + applePay: { + enabled: true, + merchantIdentifier: 'The merchant name', }, }, }} diff --git a/src/CheckoutPage.tsx b/src/CheckoutPage.tsx index eaaf07d..cf4b94c 100644 --- a/src/CheckoutPage.tsx +++ b/src/CheckoutPage.tsx @@ -6,6 +6,7 @@ import { useTyro, PaySheet } from '@tyro/tyro-pay-api-react-native'; import React, { useEffect } from 'react'; import { ActivityIndicator, Button, StyleSheet, Text, View } from 'react-native'; import ErrorHandler from 'Error'; +import PayButton from 'PayButton'; interface CheckoutPageProps { paySecret: string; @@ -13,7 +14,16 @@ interface CheckoutPageProps { } const CheckoutPage = ({ paySecret, resetPaySecret }: CheckoutPageProps): JSX.Element => { - const { initPaySheet, initialised, payRequest, isPayRequestReady, isPayRequestLoading, tyroError } = useTyro(); + const { + initPaySheet, + initialised, + payRequest, + isPayRequestReady, + isPayRequestLoading, + tyroError, + isSubmitting, + submitPayForm, + } = useTyro(); useEffect(() => { if (initialised === true && paySecret) { @@ -41,6 +51,7 @@ const CheckoutPage = ({ paySecret, resetPaySecret }: CheckoutPageProps): JSX.Ele <> {isPayRequestReady && } + {isPayRequestReady && } {isPayRequestLoading && } ); diff --git a/src/PayButton.tsx b/src/PayButton.tsx new file mode 100644 index 0000000..9fb8848 --- /dev/null +++ b/src/PayButton.tsx @@ -0,0 +1,48 @@ +import React from 'react'; +import { ActivityIndicator, TouchableOpacity, View, StyleSheet, Text } from 'react-native'; + +type PayButtonProps = { + onSubmit: () => Promise; + loading: boolean; + title: string; +}; + +const PayButton = ({ onSubmit, loading, title }: PayButtonProps): JSX.Element => { + return ( + + {loading ? ( + + ) : ( + + {title} + + )} + + ); +}; + +const styles = StyleSheet.create({ + container: { + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + marginVertical: 10, + }, + button: { + borderRadius: 5, + height: 40, + width: '100%', + backgroundColor: 'blue', + }, + buttonText: { + color: 'white', + }, +}); + +export default PayButton; diff --git a/src/tests/integration/subflows/wallets/assert-gpay.yml b/src/tests/integration/subflows/wallets/assert-gpay.yml index 0546d68..6372717 100644 --- a/src/tests/integration/subflows/wallets/assert-gpay.yml +++ b/src/tests/integration/subflows/wallets/assert-gpay.yml @@ -1,4 +1,4 @@ appId: com.exampleapp --- - assertVisible: - id: "com.exampleapp:id/pay_button_logo" \ No newline at end of file + id: "google-pay-button" \ No newline at end of file From e9bcd706995bd81a22a417412e67003b310d152a Mon Sep 17 00:00:00 2001 From: Serena Zhang Date: Tue, 14 May 2024 09:53:27 +1000 Subject: [PATCH 2/3] attemp to fix pipeline --- .github/workflows/codeql.yaml | 5 ----- .github/workflows/integration-tests.yml | 10 ---------- 2 files changed, 15 deletions(-) diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index a4aaeeb..3bfb3e9 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -45,11 +45,6 @@ jobs: steps: - - name: Install SSH Client 🔑 - uses: webfactory/ssh-agent@v0.8.0 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - name: Checkout code uses: actions/checkout@v3 diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index fbb605d..cedcca0 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -21,11 +21,6 @@ jobs: with: node-version: 18.0.0 - - name: Install SSH Client 🔑 - uses: webfactory/ssh-agent@v0.8.0 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - name: Checkout code uses: actions/checkout@v3 @@ -74,11 +69,6 @@ jobs: steps: - - name: Install SSH Client 🔑 - uses: webfactory/ssh-agent@v0.8.0 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - name: Checkout code uses: actions/checkout@v3 From 571ce71198be3534a23a7c5c74b1f6ca5b2a7f1d Mon Sep 17 00:00:00 2001 From: Serena Zhang Date: Tue, 14 May 2024 10:20:30 +1000 Subject: [PATCH 3/3] attemp to fix integration test pipeline --- .github/workflows/integration-tests.yml | 82 +++++++++++++++++++++---- 1 file changed, 69 insertions(+), 13 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index cedcca0..526e969 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -13,7 +13,10 @@ env: jobs: android-e2e: - runs-on: macos-latest + runs-on: ubuntu-latest + strategy: + matrix: + api-level: [33] steps: - name: Setup Node.js env @@ -32,14 +35,6 @@ jobs: with: distribution: 'corretto' java-version: '11' - - - name: Gradle cache - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }} - name: Install Maestro CLI run: curl -Ls "https://get.maestro.mobile.dev" | bash @@ -50,11 +45,41 @@ jobs: - name: Install Dependencies and build android run: | npm run install:no-pods + + - name: Enable KVM + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + - name: Gradle cache + uses: gradle/actions/setup-gradle@v3 + + - name: AVD cache + uses: actions/cache@v4 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ matrix.api-level }} + + - name: create AVD and generate snapshot for caching + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + arch: x86_64 + target: google_apis + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: false + script: echo "Generated AVD snapshot for caching." - name: Run Android Emulator and app uses: reactivecircus/android-emulator-runner@v2 with: - api-level: 29 + api-level: ${{ matrix.api-level }} arch: x86_64 target: google_apis force-avd-creation: false @@ -63,18 +88,47 @@ jobs: script: | npm run android:release npm run test:e2e:android + env: + MAESTRO_DRIVER_STARTUP_TIMEOUT: 30000 ios-e2e: runs-on: macos-14 steps: + - name: Setup Node.js env + uses: actions/setup-node@v2.1.5 + with: + node-version: 18.0.0 + + - name: setup-cocoapods + uses: maxim-lobanov/setup-cocoapods@v1 + with: + version: 1.14.3 + - name: Checkout code uses: actions/checkout@v3 - - name: Get package cache directory path - id: package-cache-dir-path - run: echo "::set-output name=dir::$(package cache dir)" + - name: Get npm cache directory + id: npm-cache-dir + shell: bash + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} + + - uses: actions/cache@v3 + id: npm-cache + with: + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - uses: actions/cache@v2 + with: + path: ios/Pods + key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods- + - name: Install React Native CLI run: npm install react-native-cli @@ -95,6 +149,8 @@ jobs: run: | npm run ios:release npm run test:e2e:ios + env: + MAESTRO_DRIVER_STARTUP_TIMEOUT: 30000 - name: Stop Emulator run: killall "Simulator"