├── .eslintignore
├── .eslintrc.js
├── .gitattributes
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── documentation.md
│ ├── feature_request.md
│ └── question.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ ├── main.yml
│ └── npm-publish-github-packages.yml
├── .gitignore
├── .npmignore
├── .npmrc
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── RNReaderSDK.podspec
├── android
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── squareup
│ └── sdk
│ └── reader
│ └── react
│ ├── AuthorizationModule.java
│ ├── CheckoutModule.java
│ ├── ReaderSdkPackage.java
│ ├── ReaderSettingsModule.java
│ ├── StoreCustomerCardModule.java
│ └── internal
│ ├── DateFormatUtils.java
│ ├── ErrorHandlerUtils.java
│ ├── ReaderSdkException.java
│ └── converter
│ ├── CardConverter.java
│ ├── CheckoutResultConverter.java
│ ├── LocationConverter.java
│ ├── MoneyConverter.java
│ ├── TenderCardDetailsConverter.java
│ ├── TenderCashDetailsConverter.java
│ └── TenderConverter.java
├── docs
├── get-started.md
├── reference.md
└── troubleshooting.md
├── index.d.ts
├── index.js
├── ios
├── Converters
│ ├── RNReaderSDKDateFormatter.h
│ ├── RNReaderSDKDateFormatter.m
│ ├── SQRDCard+RNReaderSDKAdditions.h
│ ├── SQRDCard+RNReaderSDKAdditions.m
│ ├── SQRDCheckoutResult+RNReaderSDKAdditions.h
│ ├── SQRDCheckoutResult+RNReaderSDKAdditions.m
│ ├── SQRDLocation+RNReaderSDKAdditions.h
│ ├── SQRDLocation+RNReaderSDKAdditions.m
│ ├── SQRDMoney+RNReaderSDKAdditions.h
│ ├── SQRDMoney+RNReaderSDKAdditions.m
│ ├── SQRDTender+RNReaderSDKAdditions.h
│ ├── SQRDTender+RNReaderSDKAdditions.m
│ ├── SQRDTenderCardDetails+RNReaderSDKAdditions.h
│ ├── SQRDTenderCardDetails+RNReaderSDKAdditions.m
│ ├── SQRDTenderCashDetails+RNReaderSDKAdditions.h
│ └── SQRDTenderCashDetails+RNReaderSDKAdditions.m
├── RNReaderSDK.xcworkspace
│ └── contents.xcworkspacedata
├── RNReaderSDKAuthorization.h
├── RNReaderSDKAuthorization.m
├── RNReaderSDKCheckout.h
├── RNReaderSDKCheckout.m
├── RNReaderSDKErrorUtilities.h
├── RNReaderSDKErrorUtilities.m
├── RNReaderSDKReaderSettings.h
├── RNReaderSDKReaderSettings.m
├── RNReaderSDKStoreCustomerCard.h
├── RNReaderSDKStoreCustomerCard.m
└── RNReaderSdk.xcodeproj
│ └── project.pbxproj
├── package-lock.json
├── package.json
├── reader-sdk-react-native-quickstart
├── .buckconfig
├── .bundle
│ └── config
├── .eslintrc.js
├── .gitignore
├── .prettierrc.js
├── .ruby-version
├── .watchmanconfig
├── App.tsx
├── Gemfile
├── Gemfile.lock
├── LICENSE.txt
├── README.md
├── SquareReaderSDK.xcframework
│ └── Info.plist
├── __tests__
│ └── App-test.tsx
├── android
│ ├── app
│ │ ├── _BUCK
│ │ ├── build.gradle
│ │ ├── build_defs.bzl
│ │ ├── debug.keystore
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── debug
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── rnreadersdksample
│ │ │ │ └── ReactNativeFlipper.java
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── rnreadersdksample
│ │ │ │ ├── MainActivity.kt
│ │ │ │ └── MainApplication.kt
│ │ │ └── res
│ │ │ ├── drawable-hdpi
│ │ │ └── ic_jewel.png
│ │ │ ├── drawable-mdpi
│ │ │ └── ic_jewel.png
│ │ │ ├── drawable-xhdpi
│ │ │ └── ic_jewel.png
│ │ │ ├── drawable-xxhdpi
│ │ │ └── ic_jewel.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ └── ic_jewel.png
│ │ │ ├── drawable
│ │ │ └── rn_edit_text_material.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── app.json
├── app
│ ├── assets
│ │ └── images
│ │ │ ├── ic_jewel.png
│ │ │ └── setting.png
│ ├── components
│ │ ├── CustomButton.tsx
│ │ ├── ProgressView.tsx
│ │ └── SquareLogo.tsx
│ ├── screens
│ │ ├── AuthorizingScreen.tsx
│ │ ├── CheckoutScreen.tsx
│ │ ├── ChooseAuthorizeScreen.tsx
│ │ ├── DeauthorizingScreen.tsx
│ │ ├── ManualAuthorizeScreen.tsx
│ │ ├── PermissionScreenIOS.tsx
│ │ ├── QRAuthorizationScreen.tsx
│ │ ├── SettingScreen.tsx
│ │ └── SplashScreen.tsx
│ └── styles
│ │ └── common.tsx
├── babel.config.js
├── index.js
├── ios
│ ├── AppDelegate.swift
│ ├── File.swift
│ ├── Podfile
│ ├── RNReaderSDKSample-Bridging-Header.h
│ ├── RNReaderSDKSample.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── RNReaderSDKSample.xcscheme
│ ├── RNReaderSDKSample.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ ├── RNReaderSDKSample
│ │ ├── Base.lproj
│ │ │ └── LaunchScreen.xib
│ │ ├── Images.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Icon-20@2x-1.png
│ │ │ │ ├── Icon-20@2x.png
│ │ │ │ ├── Icon-20@3x-1.png
│ │ │ │ ├── Icon-20@3x.png
│ │ │ │ ├── Icon-29@2x-1.png
│ │ │ │ ├── Icon-29@2x.png
│ │ │ │ ├── Icon-29@3x-1.png
│ │ │ │ ├── Icon-29@3x.png
│ │ │ │ ├── Icon-40@2x-1.png
│ │ │ │ ├── Icon-40@2x.png
│ │ │ │ ├── Icon-40@3x-1.png
│ │ │ │ ├── Icon-40@3x.png
│ │ │ │ ├── Icon-60@2x-1.png
│ │ │ │ ├── Icon-60@2x.png
│ │ │ │ ├── Icon-60@3x-1.png
│ │ │ │ ├── Icon-60@3x.png
│ │ │ │ ├── iTunesArtwork@2x-1.png
│ │ │ │ └── iTunesArtwork@2x.png
│ │ │ ├── Contents.json
│ │ │ └── Logo.imageset
│ │ │ │ └── Logo.pdf
│ │ ├── Info.plist
│ │ ├── LaunchScreen.storyboard
│ │ └── PrivacyInfo.xcprivacy
│ ├── RNReaderSDKSampleTests
│ │ └── Info.plist
│ └── temp_file
├── metro.config.js
├── package.json
├── patches
│ └── react-native+0.67.2.patch
├── sampleapp-example.png
├── tsconfig.json
└── yarn.lock
├── src
├── __tests__
│ └── utils.test.js
└── utils.js
└── yarn.lock
/.eslintignore:
--------------------------------------------------------------------------------
1 | reader-sdk-react-native-quickstart
2 | /**/*.d.ts
3 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parser: 'babel-eslint',
3 | root: true,
4 | extends: [
5 | 'airbnb',
6 | 'plugin:react-native/all',
7 | ],
8 | settings: {
9 | 'import/resolver': {
10 | node: {
11 | extensions: ['.js', '.jsx'],
12 | },
13 | },
14 | },
15 | plugins: [
16 | 'react',
17 | 'react-native',
18 | ],
19 | env: {
20 | 'react-native/react-native': true,
21 | jest: true,
22 | },
23 | rules: {
24 | 'react-native/no-unused-styles': 2,
25 | 'react-native/split-platform-components': 2,
26 | 'react-native/no-inline-styles': 2,
27 | 'react-native/no-color-literals': 0,
28 | 'no-use-before-define': 0,
29 | 'react/jsx-filename-extension': 0,
30 | 'react/destructuring-assignment': 0,
31 | 'no-console': 0,
32 | 'react/forbid-prop-types': 0,
33 | 'class-methods-use-this': 0,
34 | },
35 | };
36 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Windows files should use crlf line endings
2 | # https://help.github.com/articles/dealing-with-line-endings/
3 | *.bat text eol=crlf
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "\U0001F41B Issue report"
3 | about: I hit an error when I tried to use this plugin.
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | ### Describe the issue
11 |
23 |
24 | ### To Reproduce
25 |
48 |
49 | ### Expected behavior
50 |
55 |
56 |
57 | **Environment (please complete the following information):**
58 |
66 |
67 | ### Screenshots
68 |
69 |
70 | ### Additional context
71 |
72 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/documentation.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "\U0001F4C3 Documentation Feedback"
3 | about: You want to suggest improvements or report something that is wrong or missing
4 | from the documentation.
5 | title: ''
6 | labels: documentation
7 | assignees: ''
8 |
9 | ---
10 |
11 | ### Describe the change you would like to see
12 |
14 |
15 | ### How would the suggested change make the documentation more useful?
16 |
18 |
19 | ### Additional context
20 |
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "\U0001F680 Feature request"
3 | about: You have an idea that could make this plugin better
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | ### Describe the functionality you would like to see
11 |
13 |
14 | ### How would this feature make the plugin more useful?
15 |
17 |
18 | ### Additional context
19 |
20 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "\U0001F914 Questions and Help"
3 | about: You have a quetion or need help using this plugin.
4 | title: ''
5 | labels: question
6 | assignees: ''
7 |
8 | ---
9 |
10 | ### Describe your question
11 |
13 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
8 |
9 | ## Summary
10 |
11 |
12 |
13 | ## Related issues
14 |
15 | Fix #
16 |
17 | ## Changelog
18 |
19 |
20 |
21 | * message
22 |
23 | ## Test Plan
24 |
25 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: react-native-square-reader-SDK
2 | on: [push]
3 | jobs:
4 | install-and-test:
5 | runs-on: ubuntu-latest
6 | steps:
7 | - uses: actions/checkout@v3
8 | - uses: actions/setup-node@v3
9 | with:
10 | node-version: 20.x
11 | - run: |
12 | yarn && yarn lint && yarn test &&
13 | cd reader-sdk-react-native-quickstart && yarn
14 | yarn lint && cd ..
15 | build-android:
16 | runs-on: ubuntu-latest
17 | steps:
18 | - name: Cache Gradle Wrapper
19 | uses: actions/cache@v3
20 | with:
21 | path: ~/.gradle/wrapper
22 | key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
23 | - name: Use Node.js
24 | uses: actions/setup-node@v1
25 | with:
26 | node-version: 20.x
27 |
28 | - name: Set up JDK 17
29 | uses: actions/setup-java@v3
30 | with:
31 | java-version: '17'
32 | distribution: 'temurin'
33 |
34 | - name: Verify Java version
35 | run: java -version
36 |
37 | - name: Cache Gradle Dependencies
38 | uses: actions/cache@v3
39 | with:
40 | path: ~/.gradle/caches
41 | key: ${{ runner.os }}-gradle-caches-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
42 | restore-keys: |
43 | ${{ runner.os }}-gradle-caches-
44 | - name: Checkout the current repo
45 | uses: actions/checkout@v3
46 | - name: Install npm dependencies
47 | working-directory: ./reader-sdk-react-native-quickstart
48 | run: yarn
49 | - name: Build
50 | working-directory: ./reader-sdk-react-native-quickstart/android
51 | env:
52 | SQUARE_READER_SDK_APPLICATION_ID: ${{secrets.SQUARE_READER_SDK_APPLICATION_ID}}
53 | SQUARE_READER_SDK_REPOSITORY_PASSWORD: ${{secrets.SQUARE_READER_SDK_REPOSITORY_PASSWORD}}
54 | run: |
55 | ./gradlew clean build -PSQUARE_READER_SDK_APPLICATION_ID=$SQUARE_READER_SDK_APPLICATION_ID -PSQUARE_READER_SDK_REPOSITORY_PASSWORD=$SQUARE_READER_SDK_REPOSITORY_PASSWORD -x lint -x lintVitalRelease
56 | build-ios:
57 | runs-on: macos-latest
58 | steps:
59 | - uses: maxim-lobanov/setup-xcode@v1.5.1
60 | with:
61 | xcode-version: latest-stable
62 | - name: Use Node.js
63 | uses: actions/setup-node@v1
64 | with:
65 | node-version: 20.x
66 | - uses: actions/checkout@v3
67 | - name: Install Dependencies
68 | working-directory: ./reader-sdk-react-native-quickstart
69 | run: yarn
70 | - name: Install Pod Dependencies
71 | working-directory: ./reader-sdk-react-native-quickstart/ios
72 | run: pod install
73 | - name: Install Reader SDK
74 | working-directory: ./reader-sdk-react-native-quickstart/ios
75 | run: ruby <(curl https://connect.squareup.com/readersdk-installer) install --app-id ${{secrets.SQUARE_READER_SDK_APPLICATION_ID}} --repo-password ${{secrets.SQUARE_READER_SDK_REPOSITORY_PASSWORD}} --version 1.6.1 > /dev/null
76 | - name: Build iOS (debug)
77 | working-directory: ./reader-sdk-react-native-quickstart/ios
78 | run: xcodebuild -workspace RNReaderSDKSample.xcworkspace -configuration Debug -scheme RNReaderSDKSample -destination generic/platform=iOS
79 |
--------------------------------------------------------------------------------
/.github/workflows/npm-publish-github-packages.yml:
--------------------------------------------------------------------------------
1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2 | # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3 |
4 | name: react-native-square-reader-sdk
5 |
6 | on:
7 | push:
8 | tags:
9 | # matches 'v{{version}}', e.g. v1.4.3
10 | - 'v[0-9]+.[0-9]+.[0-9]+'
11 |
12 | jobs:
13 | build:
14 | runs-on: ubuntu-latest
15 | permissions:
16 | contents: read
17 | id-token: write
18 | steps:
19 | - uses: actions/checkout@v4
20 | # Setup .npmrc file to publish to npm
21 | - uses: actions/setup-node@v4
22 | with:
23 | node-version: '20.x'
24 | registry-url: 'https://registry.npmjs.org'
25 | - run: npm i
26 | - run: npm pack
27 | - run: npm publish --provenance --access public
28 | env:
29 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # OSX
3 | #
4 | .DS_Store
5 |
6 | # node.js
7 | #
8 | node_modules/
9 | npm-debug.log
10 | yarn-error.log
11 |
12 |
13 | # Xcode
14 | #
15 | build/
16 | SquareReaderSDK.framework/
17 | *.pbxuser
18 | !default.pbxuser
19 | *.mode1v3
20 | !default.mode1v3
21 | *.mode2v3
22 | !default.mode2v3
23 | *.perspectivev3
24 | !default.perspectivev3
25 | xcuserdata
26 | *.xccheckout
27 | *.moved-aside
28 | DerivedData
29 | *.hmap
30 | *.ipa
31 | *.xcuserstate
32 | project.xcworkspace
33 |
34 |
35 | # Android/IntelliJ
36 | #
37 | build/
38 | .idea
39 | .gradle
40 | local.properties
41 | *.iml
42 |
43 | # BUCK
44 | buck-out/
45 | \.buckd/
46 | android/.classpath
47 | android/.project
48 | android/.settings/org.eclipse.buildship.core.prefs
49 | android/.classpath
50 | .clang-format
51 | android/bin/
52 | android/gradlew
53 | android/gradlew.bat
54 | android/gradle/wrapper/gradle-wrapper.jar
55 | android/gradle/wrapper/gradle-wrapper.properties
56 | .yarn
57 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Ignore sample code
2 | reader-sdk-react-native-quickstart/
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | registry = "https://registry.npmjs.org/"
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## Changelog
2 |
3 | ### v1.4.5 Apr 25, 2024
4 |
5 | * Upgrade Reader SDK version support to 1.7.2 for iOS
6 |
7 | ### v1.4.4 Aug 16, 2023
8 |
9 | * Upgrade Reader SDK version support to 1.7.5 for Android
10 | * Support CompileSDK and targetSDK 33 on Android
11 |
12 | ### v1.4.3 Jan 20, 2023
13 |
14 | * Add Typescript support with `index.d.ts`.
15 |
16 | ### v1.4.2 Nov 02, 2022
17 |
18 | * Fix the crach issue when tipSetting is undefined
19 | * Fix the AmountMoney required/optional fields
20 |
21 | ### v1.4.1 Sept 06, 2022
22 |
23 | * Bump the minimum Reader SDK version support to 1.6.1 for iOS and 1.6.1 for Android
24 | * Update react-native-quickstart UI
25 | * Support CompileSDK and targetSDK 30+ on Android
26 |
27 | ### v1.4.0 July 13, 2021
28 |
29 | * Upgrade React Native version to 64.1
30 | * Bump the minimum Reader SDK version support to 1.4.9 for iOS and 1.4.4 for Android
31 |
32 | ### v1.3.1 January 8, 2020
33 |
34 | * Bumped Nested handlebars dependency from 4.2.0 to 4.5.3
35 | * Removed last mention of android.support syntax
36 |
37 | ### v1.3.0 Oct 22, 2019
38 |
39 | * Update Square Reader SDK minimum supported version to 1.3.3 in order to support iOS 13
40 | * Now requires Xcode 10.2+
41 |
42 | ### v1.2.3 September 12, 2019
43 |
44 | * Add delay capture support
45 |
46 | ### v1.2.2 September 10, 2019
47 |
48 | * Update to be compatible with Android Reader SDK 1.3.1, and now supports AndroidX
49 | but the new feature "delay capture" hasn't been supported yet.
50 |
51 | ### v1.2.1 May 29, 2019
52 |
53 | * Update to be compatible with Android Reader SDK 1.3.0,
54 | but the new feature "delay capture" hasn't been supported yet.
55 |
56 | ### v1.2.0 Mar 28, 2019
57 |
58 | * Support Android Reader SDK 1.2.1.
59 |
60 | ### v1.1.4 Mar 22, 2019
61 |
62 | * Add podspec to support cocoapods ios project.
63 |
64 | ### v1.1.3 Mar 21, 2019
65 |
66 | * fix "tipPercentages" setting doesn't work with react-native 0.58.0+ on iOS.
67 |
68 | ### v1.1.2 Mar 13, 2019
69 |
70 | * add **store customer card** suport.
71 |
72 | ### v1.1.1 Mar 5, 2019
73 |
74 | * fix missing `collectSignature` for android checkout parameter.
75 |
76 | ### v1.1.0 Mar 3, 2019
77 |
78 | * remove `alwaysRequireSignature` and add `collectSignature` to checkout configuration.
79 | * bump the minimum dependency to Reader SDK 1.1.1(iOS)/1.1.3(Android).
80 | * this change **does NOT** include all new features introduced in Reader SDK 1.1.* such as **Store customer card**, see reader SDK [Change Log](https://docs.connect.squareup.com/changelog/mobile-logs/2019-02-13) for details.
81 |
82 | ### v1.0.3 Oct 9, 2018
83 |
84 | * fixed iOS threading issue.
85 |
86 | ### v1.0.2 Oct 4, 2018
87 |
88 | * fixed Android plugin compile regression.
89 |
90 | ### v1.0.1 Oct 4, 2018
91 |
92 | * fixed iOS `location.currencyCode` conversion bug, change int to string (ISOCurrencyCode)
93 | * fixed Android checkout parameter currencyCode validation
94 |
95 | ### v1.0.0 Sep 27, 2018
96 |
97 | * Initial release.
98 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing
2 | ============
3 |
4 | If you would like to contribute code to this project you must sign the
5 | [Individual Contributor License Agreement (CLA)]. Your code cannot be accepted
6 | into the project until you sign the agreement.
7 |
8 | **DO NOT SUBMIT CHANGES THAT BREAK THE QUICK START SAMPLE APP**. If you are
9 | adding new features, confirm the functionality is compatible with the sample app
10 | (at minimum) or consider adding to the sample code to demonstrate the new
11 | feature (recommended).
12 |
13 | To contribute:
14 |
15 | 1. Fork this repository.
16 | 1. Follow existing coding conventions and styles to keep the code as readable
17 | as possible.
18 | 1. Comment your code so others can understand it easily.
19 | 1. Update the associated docs (README, reference, etc.) to reflect your changes
20 | as needed. If appropriate, you can add a new markdown page to the `docs`
21 | folder to document your changes.
22 | 1. Submit a pull request with your changes.
23 |
24 |
25 | [//]: # "Link anchor definitions"
26 | [Individual Contributor License Agreement (CLA)]: https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React Native plugin for Reader SDK
2 |
3 | [](https://travis-ci.com/square/react-native-square-reader-sdk)
4 | [](https://badge.fury.io/js/react-native-square-reader-sdk)
5 |
6 | This repo contains a React Native plugin for Square [Reader SDK]. Reader SDK for
7 | React Native supports the following native Reader SDK versions:
8 |
9 | * iOS: 1.7.2 and above
10 | * Android: 1.7.5 and above
11 |
12 | >This plugin loads latest version of native Reader SDK by default according to [update policy for Reader SDK].
13 |
14 | ## In this repo
15 |
16 | In addition to the standard React Native directories, this repo includes:
17 |
18 | * `docs` - Documentation for the React Native plugin, including a
19 | [getting started guide], [technical reference], and [troubleshooting guide].
20 | * [`reader-sdk-react-native-quickstart`] - A React Native sample app with
21 | walkthrough.
22 |
23 |
24 | ## Build requirements
25 |
26 | ### Android
27 |
28 | * minSdkVersion is API 24 or higher.
29 | * Android SDK platform: API 30.
30 | * Android SDK build tools: 28.0.3
31 | * Android Gradle Plugin: 3.0.0 or greater.
32 | * Support library: 28.0.0
33 | * Google Play Services: 16.0.1
34 | * Google APIs Intel x86 Atom_64 System Image
35 |
36 | ### iOS
37 |
38 | * Xcode version: 10.2 or greater.
39 | * iOS Base SDK: 11.1 or greater.
40 | * Deployment target: iOS 11.0 or greater.
41 |
42 |
43 | ## Reader SDK requirements and limitations
44 |
45 | * Reader SDK is **only** available for accounts based in the **United States**.
46 | Authorization requests for accounts based outside the United States return an
47 | error.
48 | * Reader SDK may not be used for unattended terminals. Using Reader SDK to
49 | implement payment solutions in unattended terminals or kiosks (for example,
50 | vending machines) is strictly prohibited.
51 | * Reader SDK requires an authorization token from the [Mobile Authorization API]
52 | to connect Square Readers and accept payments.
53 | * Reader SDK only supports on-screen tipping. Digital receipts and tips can be
54 | configured in Reader SDK. Tipping on printed receipts is not supported at this
55 | time.
56 | * Reader SDK cannot issue refunds. Refunds can be issued programmatically using
57 | the Refunds API or manually in the [Square Dashboard].
58 | * Reader SDK is not supported in the Square sandbox. See [Testing Mobile Apps]
59 | for testing recommendations.
60 | * Your version of Reader SDK must adhere to the Square SDK update policy. To
61 | limit risk to developers and their users, Square enforces an
62 | [update policy for Reader SDK] that requires developers to keep their version
63 | of Reader SDK current.
64 |
65 |
66 | ## License
67 |
68 | ```
69 | Copyright 2019 Square Inc.
70 |
71 | Licensed under the Apache License, Version 2.0 (the "License");
72 | you may not use this file except in compliance with the License.
73 | You may obtain a copy of the License at
74 |
75 | http://www.apache.org/licenses/LICENSE-2.0
76 |
77 | Unless required by applicable law or agreed to in writing, software
78 | distributed under the License is distributed on an "AS IS" BASIS,
79 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
80 | See the License for the specific language governing permissions and
81 | limitations under the License.
82 | ```
83 |
84 |
85 | [//]: # "Link anchor definitions"
86 | [Mobile Authorization API]: https://developer.squareup.com/docs/mobile-authz/build-with-mobile-authz
87 | [Reader SDK]: https://developer.squareup.com/docs/reader-sdk/what-it-does
88 | [Square Dashboard]: https://squareup.com/dashboard/
89 | [update policy for Reader SDK]: https://developer.squareup.com/docs/reader-sdk/what-it-does#readersdkupdatepolicy
90 | [Testing Mobile Apps]: https://developer.squareup.com/docs/testing/mobile
91 | [getting started guide]: https://github.com/square/react-native-square-reader-sdk/tree/master/docs/get-started.md
92 | [technical reference]: https://github.com/square/react-native-square-reader-sdk/tree/master/docs/reference.md
93 | [troubleshooting guide]: https://github.com/square/react-native-square-reader-sdk/tree/master/docs/troubleshooting.md
94 | [`reader-sdk-react-native-quickstart`]: https://github.com/square/react-native-square-reader-sdk/tree/master/reader-sdk-react-native-quickstart
95 |
--------------------------------------------------------------------------------
/RNReaderSDK.podspec:
--------------------------------------------------------------------------------
1 |
2 | Pod::Spec.new do |s|
3 | s.name = "RNReaderSDK"
4 | s.version = "1.7.2"
5 | s.summary = "A React Native plugin for Square Reader SDK"
6 | s.description = <<-DESC
7 | A React Native plugin for Square Reader SDK
8 | DESC
9 | s.homepage = "https://github.com/square/react-native-square-reader-sdk"
10 | s.license = { :file => 'LICENSE' }
11 | s.author = { "Square, Inc." => "xiao@squareup.com" }
12 | s.platform = :ios, "11.1"
13 | s.source = { :path => 'ios' }
14 | s.source_files = "ios/**/*.{h,m}"
15 | s.public_header_files = 'ios/**/*.h'
16 | s.requires_arc = true
17 | s.frameworks = 'SquareReaderSDK'
18 | s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '$(PROJECT_DIR)/../**' }
19 |
20 | s.dependency "React"
21 | end
22 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | buildscript {
18 | repositories {
19 | google()
20 | mavenCentral()
21 | }
22 |
23 | dependencies {
24 | classpath("com.android.tools.build:gradle:4.2.2")
25 | }
26 | }
27 |
28 | apply plugin: 'com.android.library'
29 |
30 | def DEFAULT_PLAY_SERVICES_BASE_VERSION = '16.0.1'
31 | def READER_SDK_VERSION = '1.7.4'
32 |
33 | android {
34 | compileSdkVersion 33
35 |
36 | compileOptions {
37 | sourceCompatibility JavaVersion.VERSION_1_8
38 | targetCompatibility JavaVersion.VERSION_1_8
39 | }
40 |
41 | defaultConfig {
42 | minSdkVersion 24
43 | targetSdkVersion 33
44 | versionCode 1
45 | versionName "1.0"
46 | multiDexEnabled true
47 | }
48 | lintOptions {
49 | checkReleaseBuilds false
50 | abortOnError false
51 | }
52 | dexOptions {
53 | preDexLibraries true
54 | jumboMode true
55 | keepRuntimeAnnotatedClasses false
56 | }
57 | }
58 |
59 | repositories {
60 | mavenCentral()
61 | maven {
62 | url "https://sdk.squareup.com/android"
63 | credentials {
64 | username SQUARE_READER_SDK_APPLICATION_ID
65 | password SQUARE_READER_SDK_REPOSITORY_PASSWORD
66 | }
67 | }
68 | google()
69 | }
70 |
71 | dependencies {
72 | def readerSdkVersion = rootProject.hasProperty('readerSdkVersion') ? rootProject.readerSdkVersion : READER_SDK_VERSION
73 | def playServicesBaseVersion = rootProject.hasProperty('googlePlayServiceVersion') ? rootProject.googlePlayServiceVersion : DEFAULT_PLAY_SERVICES_BASE_VERSION
74 | implementation 'com.facebook.react:react-native:+'
75 | implementation "com.google.android.gms:play-services-base:$playServicesBaseVersion"
76 | implementation "com.squareup.sdk.reader:reader-sdk-$SQUARE_READER_SDK_APPLICATION_ID:$readerSdkVersion"
77 | runtimeOnly "com.squareup.sdk.reader:reader-sdk-internals:$readerSdkVersion"
78 | }
79 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
19 |
20 |
23 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/ReaderSdkPackage.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Collections;
20 | import java.util.List;
21 |
22 | import com.facebook.react.ReactPackage;
23 | import com.facebook.react.bridge.NativeModule;
24 | import com.facebook.react.bridge.ReactApplicationContext;
25 | import com.facebook.react.uimanager.ViewManager;
26 |
27 | public class ReaderSdkPackage implements ReactPackage {
28 | @Override
29 | public List createNativeModules(ReactApplicationContext reactContext) {
30 | List modules = new ArrayList<>();
31 | modules.add(new AuthorizationModule(reactContext));
32 | modules.add(new CheckoutModule(reactContext));
33 | modules.add(new ReaderSettingsModule(reactContext));
34 | modules.add(new StoreCustomerCardModule(reactContext));
35 | return modules;
36 | }
37 |
38 | @Override
39 | public List createViewManagers(ReactApplicationContext reactContext) {
40 | return Collections.emptyList();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/ReaderSettingsModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react;
17 |
18 | import android.app.Activity;
19 | import android.os.Handler;
20 | import android.os.Looper;
21 |
22 | import com.facebook.react.bridge.Promise;
23 | import com.facebook.react.bridge.ReactApplicationContext;
24 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
25 | import com.facebook.react.bridge.ReactMethod;
26 | import com.squareup.sdk.reader.ReaderSdk;
27 | import com.squareup.sdk.reader.core.CallbackReference;
28 | import com.squareup.sdk.reader.core.Result;
29 | import com.squareup.sdk.reader.core.ResultError;
30 | import com.squareup.sdk.reader.hardware.ReaderSettingsActivityCallback;
31 | import com.squareup.sdk.reader.hardware.ReaderSettingsErrorCode;
32 | import com.squareup.sdk.reader.react.internal.ErrorHandlerUtils;
33 | import com.squareup.sdk.reader.react.internal.ReaderSdkException;
34 |
35 | class ReaderSettingsModule extends ReactContextBaseJavaModule {
36 | // Define all the reader settings debug codes and messages below
37 | // These error codes and messages **MUST** align with iOS error codes and javascript error codes
38 | // Search KEEP_IN_SYNC_READER_SETTINGS_ERROR to update all places
39 |
40 | // react native module debug error codes
41 | private static final String RN_READER_SETTINGS_ALREADY_IN_PROGRESS = "rn_reader_settings_already_in_progress";
42 |
43 | // react native module debug messages
44 | private static final String RN_MESSAGE_READER_SETTINGS_ALREADY_IN_PROGRESS = "A reader settings operation is already in progress. Ensure that the in-progress reader settings is completed before calling startReaderSettingsAsync again.";
45 |
46 | private volatile CallbackReference readerSettingCallbackRef;
47 | private final Handler mainLooperHandler;
48 |
49 | public ReaderSettingsModule(ReactApplicationContext reactContext) {
50 | super(reactContext);
51 | mainLooperHandler = new Handler(Looper.getMainLooper());
52 | }
53 |
54 | @Override
55 | public String getName() {
56 | return "RNReaderSDKReaderSettings";
57 | }
58 |
59 | @ReactMethod
60 | public void startReaderSettings(final Promise promise) {
61 | if (readerSettingCallbackRef != null) {
62 | String errorJsonMessage = ErrorHandlerUtils.createNativeModuleError(RN_READER_SETTINGS_ALREADY_IN_PROGRESS, RN_MESSAGE_READER_SETTINGS_ALREADY_IN_PROGRESS);
63 | promise.reject(ErrorHandlerUtils.USAGE_ERROR, new ReaderSdkException(errorJsonMessage));
64 | return;
65 | }
66 | ReaderSettingsActivityCallback readerSettingsCallback = new ReaderSettingsActivityCallback() {
67 | @Override
68 | public void onResult(Result> result) {
69 | readerSettingCallbackRef.clear();
70 | readerSettingCallbackRef = null;
71 | if (result.isError()) {
72 | ResultError error = result.getError();
73 | String errorJsonMessage = ErrorHandlerUtils.serializeErrorToJson(error.getDebugCode(), error.getMessage(), error.getDebugMessage());
74 | promise.reject(ErrorHandlerUtils.getErrorCode(error.getCode()), new ReaderSdkException(errorJsonMessage));
75 | return;
76 | }
77 | promise.resolve(null);
78 | }
79 | };
80 | readerSettingCallbackRef = ReaderSdk.readerManager()
81 | .addReaderSettingsActivityCallback(readerSettingsCallback);
82 |
83 | final Activity currentActivity = getCurrentActivity();
84 | mainLooperHandler.post(new Runnable() {
85 | @Override
86 | public void run() {
87 | ReaderSdk.readerManager().startReaderSettingsActivity(currentActivity);
88 | }
89 | });
90 | }
91 |
92 | @Override
93 | public void onCatalystInstanceDestroy() {
94 | super.onCatalystInstanceDestroy();
95 | // clear the callback to avoid memory leaks when react native module is destroyed
96 | if (readerSettingCallbackRef != null) {
97 | readerSettingCallbackRef.clear();
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/internal/DateFormatUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react.internal;
17 |
18 | import java.text.DateFormat;
19 | import java.text.SimpleDateFormat;
20 | import java.util.Date;
21 |
22 | public class DateFormatUtils {
23 |
24 | private static final ThreadLocal ISO_8601 = new ThreadLocal() {
25 | @Override protected DateFormat initialValue() {
26 | return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
27 | }
28 | };
29 |
30 | public static String formatISO8601UTC(Date date) {
31 | return ISO_8601.get().format(date);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/internal/ReaderSdkException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react.internal;
17 |
18 | public class ReaderSdkException extends Exception {
19 | public ReaderSdkException(String message) {
20 | super(message);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/internal/converter/CardConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react.internal.converter;
17 |
18 | import com.facebook.react.bridge.WritableMap;
19 | import com.facebook.react.bridge.WritableNativeMap;
20 | import com.squareup.sdk.reader.checkout.Card;
21 | import java.util.HashMap;
22 | import java.util.Map;
23 |
24 | public class CardConverter {
25 | private static final Map brandStringMap;
26 |
27 | static {
28 | brandStringMap = new HashMap<>();
29 | for (Card.Brand brand : Card.Brand.values()) {
30 | switch(brand) {
31 | case VISA:
32 | brandStringMap.put(brand, "VISA");
33 | break;
34 | case MASTERCARD:
35 | brandStringMap.put(brand, "MASTERCARD");
36 | break;
37 | case AMERICAN_EXPRESS:
38 | brandStringMap.put(brand, "AMERICAN_EXPRESS");
39 | break;
40 | case DISCOVER:
41 | brandStringMap.put(brand, "DISCOVER");
42 | break;
43 | case DISCOVER_DINERS:
44 | brandStringMap.put(brand, "DISCOVER_DINERS");
45 | break;
46 | case INTERAC:
47 | brandStringMap.put(brand, "INTERAC");
48 | break;
49 | case JCB:
50 | brandStringMap.put(brand, "JCB");
51 | break;
52 | case CHINA_UNIONPAY:
53 | brandStringMap.put(brand, "CHINA_UNIONPAY");
54 | break;
55 | case SQUARE_GIFT_CARD:
56 | brandStringMap.put(brand, "SQUARE_GIFT_CARD");
57 | break;
58 | case EFTPOS:
59 | brandStringMap.put(brand, "EFTPOS");
60 | break;
61 | case FELICA:
62 | brandStringMap.put(brand, "FELICA");
63 | break;
64 | case OTHER_BRAND:
65 | brandStringMap.put(brand, "OTHER_BRAND");
66 | break;
67 | default:
68 | // UNKNOWN should never happen if the right Reader SDK version is loaded with plugin
69 | // But we choose not break plugin if the type isn't important
70 | brandStringMap.put(brand, "UNKNOWN");
71 | }
72 | }
73 | }
74 |
75 | public WritableMap toJSObject(Card card) {
76 | // We use this "Ignore if null" principle for all returned dictionary
77 | WritableMap mapToReturn = new WritableNativeMap();
78 | mapToReturn.putString("brand", brandStringMap.get(card.getBrand()));
79 | mapToReturn.putString("lastFourDigits", card.getLastFourDigits());
80 | if (card.getExpirationMonth() != null) {
81 | mapToReturn.putInt("expirationMonth", card.getExpirationMonth());
82 | }
83 | if (card.getExpirationYear() != null) {
84 | mapToReturn.putInt("expirationYear", card.getExpirationYear());
85 | }
86 | if (card.getId() != null) {
87 | mapToReturn.putString("id", card.getId());
88 | }
89 | if (card.getCardholderName() != null) {
90 | mapToReturn.putString("cardholderName", card.getCardholderName());
91 | }
92 | return mapToReturn;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/internal/converter/CheckoutResultConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react.internal.converter;
17 |
18 | import com.facebook.react.bridge.WritableArray;
19 | import com.facebook.react.bridge.WritableMap;
20 | import com.facebook.react.bridge.WritableNativeArray;
21 | import com.facebook.react.bridge.WritableNativeMap;
22 | import com.squareup.sdk.reader.checkout.CheckoutResult;
23 | import com.squareup.sdk.reader.checkout.Money;
24 | import com.squareup.sdk.reader.checkout.Tender;
25 | import com.squareup.sdk.reader.react.internal.DateFormatUtils;
26 |
27 | public class CheckoutResultConverter {
28 | private final MoneyConverter moneyConverter;
29 | private final TenderConverter tenderConverter;
30 |
31 | public CheckoutResultConverter() {
32 | moneyConverter = new MoneyConverter();
33 | tenderConverter = new TenderConverter();
34 | }
35 |
36 | public WritableMap toJSObject(CheckoutResult result) {
37 | // We use this "Ignore if null" principle for all returned dictionary
38 | WritableMap mapToReturn = new WritableNativeMap();
39 | if (result.getTransactionId() != null) {
40 | mapToReturn.putString("transactionId", result.getTransactionId());
41 | }
42 | mapToReturn.putString("transactionClientId", result.getTransactionClientId());
43 | mapToReturn.putString("locationId", result.getLocationId());
44 | mapToReturn.putString("createdAt", DateFormatUtils.formatISO8601UTC(result.getCreatedAt()));
45 | Money totalMoney = result.getTotalMoney();
46 | mapToReturn.putMap("totalMoney", moneyConverter.toJSObject(totalMoney));
47 | Money totalTipMoney = result.getTotalTipMoney();
48 | mapToReturn.putMap("totalTipMoney", moneyConverter.toJSObject(totalTipMoney));
49 |
50 | WritableArray jsTenders = new WritableNativeArray();
51 | for (Tender tender : result.getTenders()) {
52 | jsTenders.pushMap(tenderConverter.toJSObject(tender));
53 | }
54 | mapToReturn.putArray("tenders", jsTenders);
55 |
56 | return mapToReturn;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/internal/converter/LocationConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react.internal.converter;
17 |
18 | import com.facebook.react.bridge.WritableMap;
19 | import com.facebook.react.bridge.WritableNativeMap;
20 | import com.squareup.sdk.reader.authorization.Location;
21 |
22 | public final class LocationConverter {
23 | private final MoneyConverter moneyConverter;
24 |
25 | public LocationConverter() {
26 | moneyConverter = new MoneyConverter();
27 | }
28 |
29 | public WritableMap toJSObject(Location location) {
30 | WritableMap mapToReturn = new WritableNativeMap();
31 | mapToReturn.putString("locationId", location.getLocationId());
32 | mapToReturn.putString("name", location.getName());
33 | mapToReturn.putString("businessName", location.getBusinessName());
34 | mapToReturn.putBoolean("isCardProcessingActivated", location.isCardProcessingActivated());
35 | mapToReturn.putMap("minimumCardPaymentAmountMoney", moneyConverter.toJSObject(location.getMinimumCardPaymentAmountMoney()));
36 | mapToReturn.putMap("maximumCardPaymentAmountMoney", moneyConverter.toJSObject(location.getMaximumCardPaymentAmountMoney()));
37 | mapToReturn.putString("currencyCode", location.getCurrencyCode().name());
38 |
39 | return mapToReturn;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/internal/converter/MoneyConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react.internal.converter;
17 |
18 | import com.facebook.react.bridge.WritableMap;
19 | import com.facebook.react.bridge.WritableNativeMap;
20 | import com.squareup.sdk.reader.checkout.Money;
21 |
22 | class MoneyConverter {
23 | public WritableMap toJSObject(Money money) {
24 | WritableMap mapToReturn = new WritableNativeMap();
25 | // WritalbeMap doesn't provide a long type but the money amount is a long type,
26 | // So convert the long to double
27 | mapToReturn.putDouble("amount", money.getAmount());
28 | mapToReturn.putString("currencyCode", money.getCurrencyCode().name());
29 |
30 | return mapToReturn;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/internal/converter/TenderCardDetailsConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react.internal.converter;
17 |
18 | import com.facebook.react.bridge.WritableMap;
19 | import com.facebook.react.bridge.WritableNativeMap;
20 | import com.squareup.sdk.reader.checkout.TenderCardDetails;
21 | import java.util.HashMap;
22 | import java.util.Map;
23 |
24 | class TenderCardDetailsConverter {
25 | private static final Map entryMethodStringMap;
26 |
27 | static {
28 | entryMethodStringMap = new HashMap<>();
29 | for (TenderCardDetails.EntryMethod method : TenderCardDetails.EntryMethod.values()) {
30 | switch (method) {
31 | case MANUALLY_ENTERED:
32 | entryMethodStringMap.put(method, "MANUALLY_ENTERED");
33 | break;
34 | case SWIPE:
35 | entryMethodStringMap.put(method, "SWIPE");
36 | break;
37 | case CHIP:
38 | entryMethodStringMap.put(method, "CHIP");
39 | break;
40 | case CONTACTLESS:
41 | entryMethodStringMap.put(method, "CONTACTLESS");
42 | break;
43 | default:
44 | // UNKNOWN should never happen if the right Reader SDK version is loaded with plugin
45 | // But we choose not break plugin if the type isn't important
46 | entryMethodStringMap.put(method, "UNKNOWN");
47 | }
48 | }
49 |
50 | }
51 | private final CardConverter cardConverter;
52 |
53 | public TenderCardDetailsConverter(){
54 | cardConverter = new CardConverter();
55 | }
56 |
57 | public WritableMap toJSObject(TenderCardDetails tenderCardDetails) {
58 | WritableMap mapToReturn = new WritableNativeMap();
59 | mapToReturn.putString("entryMethod", entryMethodStringMap.get(tenderCardDetails.getEntryMethod()));
60 | mapToReturn.putMap("card", cardConverter.toJSObject(tenderCardDetails.getCard()));
61 | return mapToReturn;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/internal/converter/TenderCashDetailsConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react.internal.converter;
17 |
18 | import com.facebook.react.bridge.WritableMap;
19 | import com.facebook.react.bridge.WritableNativeMap;
20 | import com.squareup.sdk.reader.checkout.TenderCashDetails;
21 |
22 | class TenderCashDetailsConverter {
23 | private final MoneyConverter moneyConverter;
24 |
25 | public TenderCashDetailsConverter(){
26 | moneyConverter = new MoneyConverter();
27 | }
28 |
29 | public WritableMap toJSObject(TenderCashDetails tenderCashDetails) {
30 | WritableMap mapToReturn = new WritableNativeMap();
31 | mapToReturn.putMap("buyerTenderedMoney", moneyConverter.toJSObject(tenderCashDetails.getBuyerTenderedMoney()));
32 | mapToReturn.putMap("changeBackMoney", moneyConverter.toJSObject(tenderCashDetails.getChangeBackMoney()));
33 | return mapToReturn;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/android/src/main/java/com/squareup/sdk/reader/react/internal/converter/TenderConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.squareup.sdk.reader.react.internal.converter;
17 |
18 | import com.facebook.react.bridge.WritableMap;
19 | import com.facebook.react.bridge.WritableNativeMap;
20 | import com.squareup.sdk.reader.checkout.Tender;
21 | import com.squareup.sdk.reader.react.internal.DateFormatUtils;
22 | import java.util.HashMap;
23 | import java.util.Map;
24 |
25 | class TenderConverter {
26 | private static final Map tenderTypeMap;
27 |
28 | static {
29 | tenderTypeMap = new HashMap<>();
30 | for (Tender.Type type : Tender.Type.values()) {
31 | switch (type) {
32 | case CARD:
33 | tenderTypeMap.put(type, "card");
34 | break;
35 | case CASH:
36 | tenderTypeMap.put(type, "cash");
37 | break;
38 | case OTHER:
39 | tenderTypeMap.put(type, "other");
40 | break;
41 | default:
42 | // unknown should never happen if the right Reader SDK version is loaded with plugin
43 | // But we choose not break plugin if the type isn't important
44 | tenderTypeMap.put(type, "unknown");
45 | }
46 | }
47 |
48 | }
49 |
50 | private final MoneyConverter moneyConverter;
51 | private final TenderCardDetailsConverter tenderCardDetailsConverter;
52 | private final TenderCashDetailsConverter tenderCashDetailsConverter;
53 |
54 | public TenderConverter(){
55 | moneyConverter = new MoneyConverter();
56 | tenderCardDetailsConverter = new TenderCardDetailsConverter();
57 | tenderCashDetailsConverter = new TenderCashDetailsConverter();
58 | }
59 |
60 | public WritableMap toJSObject(Tender tender) {
61 | WritableMap mapToReturn = new WritableNativeMap();
62 | mapToReturn.putString("createdAt", DateFormatUtils.formatISO8601UTC(tender.getCreatedAt()));
63 | mapToReturn.putMap("tipMoney", moneyConverter.toJSObject(tender.getTipMoney()));
64 | mapToReturn.putMap("totalMoney", moneyConverter.toJSObject(tender.getTotalMoney()));
65 | Tender.Type tenderType = tender.getType();
66 | mapToReturn.putString("type", tenderTypeMap.get(tenderType));
67 |
68 | if (tenderType == Tender.Type.CARD) {
69 | mapToReturn.putString("tenderId", tender.getTenderId());
70 | mapToReturn.putMap("cardDetails", tenderCardDetailsConverter.toJSObject(tender.getCardDetails()));
71 | } else if (tenderType == Tender.Type.CASH) {
72 | mapToReturn.putMap("cashDetails", tenderCashDetailsConverter.toJSObject(tender.getCashDetails()));
73 | }
74 |
75 | return mapToReturn;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/docs/troubleshooting.md:
--------------------------------------------------------------------------------
1 | # Troubleshooting the Reader SDK React Native plugin
2 |
3 | Likely causes and solutions for common problems.
4 |
5 | ## I get XCode compile errors when building Reader SDK
6 |
7 | ### The problem
8 |
9 | Xcode 10 builds projects differently than earlier versions and is not compatible
10 | with the React Native build system.
11 |
12 | ### Likely cause
13 |
14 | You recently downloaded or updated XCode.
15 |
16 | ### Solution
17 |
18 | 1. Open `File > Project Settings... > Per-User Project Settings`
19 | 2. Choose `Legacy Build System`
20 | 3. Remove `node_modules/react-native/third-party` and
21 | `node_modules/react-native/third-party-podspecs`
22 |
23 | ## On iOS, authorizeAsync throws error "RNReaderSDKAuthorization is undefined"
24 |
25 | ### The problem
26 |
27 | libRNReaderSDK.a is not added to your project's `Build Phases > Link Binary With Libraries`.
28 |
29 | ### Likely cause
30 |
31 | You failed to run `react-native link react-native-square-reader-sdk` or you are using CocoaPods to link libraries.
32 |
33 | ### Solution
34 |
35 | 1. In Xcode, click your project and go to `Build Phases > Link Binary With Libraries`
36 | 2. In project navigator, expand `[project root] > Libraries > RNReaderSDK.xcodeproj > Products` and drag `libRNReaderSDK.a` into `Link Binary With Libraries`
37 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import { NativeModules } from 'react-native'; // eslint-disable-line import/no-unresolved
18 | import ValidateCheckoutParameters from './src/utils';
19 |
20 | const {
21 | RNReaderSDKAuthorization,
22 | RNReaderSDKCheckout,
23 | RNReaderSDKReaderSettings,
24 | RNReaderSDKStoreCustomerCard,
25 | } = NativeModules;
26 |
27 | export async function authorizeAsync(authCode) {
28 | try {
29 | return await RNReaderSDKAuthorization.authorize(authCode);
30 | } catch (ex) {
31 | throw createReaderSDKError(ex);
32 | }
33 | }
34 |
35 | export async function deauthorizeAsync() {
36 | try {
37 | await RNReaderSDKAuthorization.deauthorize();
38 | } catch (ex) {
39 | throw createReaderSDKError(ex);
40 | }
41 | }
42 |
43 | export async function isAuthorizedAsync() {
44 | try {
45 | return await RNReaderSDKAuthorization.isAuthorized();
46 | } catch (ex) {
47 | throw createReaderSDKError(ex);
48 | }
49 | }
50 |
51 | export async function isAuthorizationInProgressAsync() {
52 | try {
53 | return await RNReaderSDKAuthorization.isAuthorizationInProgress();
54 | } catch (ex) {
55 | throw createReaderSDKError(ex);
56 | }
57 | }
58 |
59 | export async function canDeauthorizeAsync() {
60 | try {
61 | return await RNReaderSDKAuthorization.canDeauthorize();
62 | } catch (ex) {
63 | throw createReaderSDKError(ex);
64 | }
65 | }
66 |
67 | export async function getAuthorizedLocationAsync() {
68 | try {
69 | return await RNReaderSDKAuthorization.authorizedLocation();
70 | } catch (ex) {
71 | throw createReaderSDKError(ex);
72 | }
73 | }
74 |
75 | export async function startCheckoutAsync(checkoutParams) {
76 | try {
77 | ValidateCheckoutParameters(checkoutParams);
78 | return await RNReaderSDKCheckout.startCheckout(checkoutParams);
79 | } catch (ex) {
80 | throw createReaderSDKError(ex);
81 | }
82 | }
83 |
84 | export async function startReaderSettingsAsync() {
85 | try {
86 | await RNReaderSDKReaderSettings.startReaderSettings();
87 | } catch (ex) {
88 | throw createReaderSDKError(ex);
89 | }
90 | }
91 |
92 | export async function startStoreCardAsync(customerId) {
93 | try {
94 | return await RNReaderSDKStoreCustomerCard.startStoreCard(customerId);
95 | } catch (ex) {
96 | throw createReaderSDKError(ex);
97 | }
98 | }
99 |
100 | // error codes are defined below, both iOS and Android *MUST* return same error for these errors:
101 | // Usage error
102 | export const UsageError = 'USAGE_ERROR';
103 |
104 | // Expected errors:
105 | // Search KEEP_IN_SYNC_AUTHORIZE_ERROR to update all places
106 | export const AuthorizeErrorNoNetwork = 'AUTHORIZE_NO_NETWORK';
107 | // Search KEEP_IN_SYNC_CHECKOUT_ERROR to update all places
108 | export const CheckoutErrorCanceled = 'CHECKOUT_CANCELED';
109 | export const CheckoutErrorSdkNotAuthorized = 'CHECKOUT_SDK_NOT_AUTHORIZED';
110 | // Search KEEP_IN_SYNC_READER_SETTINGS_ERROR to update all places
111 | export const ReaderSettingsErrorSdkNotAuthorized = 'READER_SETTINGS_SDK_NOT_AUTHORIZED';
112 | // Search KEEP_IN_SYNC_STORE_CUSTOMER_CARD_ERROR to update all places
113 | export const StoreCustomerCardCancelled = 'STORE_CUSTOMER_CARD_CANCELED';
114 | export const StoreCustomerCardInvalidCustomerId = 'STORE_CUSTOMER_CARD_INVALID_CUSTOMER_ID';
115 | export const StoreCustomerCardSdkNotAuthorized = 'STORE_CUSTOMER_CARD_SDK_NOT_AUTHORIZED';
116 | export const StoreCustomerCardNoNetwork = 'STORE_CUSTOMER_CARD_NO_NETWORK';
117 |
118 | function createReaderSDKError(ex) {
119 | try {
120 | const errorDetails = JSON.parse(ex.message);
121 | ex.message = errorDetails.message; // eslint-disable-line no-param-reassign
122 | ex.debugCode = errorDetails.debugCode; // eslint-disable-line no-param-reassign
123 | ex.debugMessage = errorDetails.debugMessage; // eslint-disable-line no-param-reassign
124 | } catch (parseEx) {
125 | ex.parseEx = parseEx; // eslint-disable-line no-param-reassign
126 | }
127 |
128 | return ex;
129 | }
130 |
--------------------------------------------------------------------------------
/ios/Converters/RNReaderSDKDateFormatter.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import
18 |
19 |
20 | @interface RNReaderSDKDateFormatter : NSObject
21 |
22 | + (NSString *)iso8601StringFromDate:(NSDate *)date;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/Converters/RNReaderSDKDateFormatter.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import "RNReaderSDKDateFormatter.h"
18 |
19 |
20 | @implementation RNReaderSDKDateFormatter
21 |
22 | + (NSString *)iso8601StringFromDate:(NSDate *)date
23 | {
24 | return [self.dateFormatter stringFromDate:date];
25 | }
26 |
27 | + (NSISO8601DateFormatter *)dateFormatter;
28 | {
29 | static NSISO8601DateFormatter *dateFormatter = nil;
30 | static dispatch_once_t onceToken = 0;
31 |
32 | dispatch_once(&onceToken, ^{
33 | dateFormatter = [[NSISO8601DateFormatter alloc] init];
34 | });
35 |
36 | return dateFormatter;
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDCard+RNReaderSDKAdditions.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | @import SquareReaderSDK;
18 |
19 |
20 | @interface SQRDCard (RNReaderSDKAdditions)
21 |
22 | - (NSDictionary *)jsonDictionary;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDCard+RNReaderSDKAdditions.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import "SQRDCard+RNReaderSDKAdditions.h"
18 | #import "SQRDTender+RNReaderSDKAdditions.h"
19 | #import "SQRDMoney+RNReaderSDKAdditions.h"
20 | #import "RNReaderSDKDateFormatter.h"
21 |
22 |
23 | @implementation SQRDCard (RNReaderSDKAdditions)
24 |
25 | - (NSDictionary *)jsonDictionary
26 | {
27 | // We use this "Ignore if null" principle for all returned dictionary
28 | NSMutableDictionary *jsTransactionResult = [[NSMutableDictionary alloc] init];
29 | jsTransactionResult[@"brand"] = [self _stringFromBrand:self.brand];
30 | jsTransactionResult[@"lastFourDigits"] = self.lastFourDigits;
31 | if (self.expirationMonth) {
32 | jsTransactionResult[@"expirationMonth"] = self.expirationMonth;
33 | }
34 | if (self.self.expirationYear) {
35 | jsTransactionResult[@"expirationYear"] = self.expirationYear;
36 | }
37 | if (self.cardID) {
38 | jsTransactionResult[@"id"] = self.cardID;
39 | }
40 | if (self.cardholderName) {
41 | jsTransactionResult[@"cardholderName"] = self.cardholderName;
42 | }
43 | return [jsTransactionResult copy];
44 | }
45 |
46 | - (NSString *)_stringFromBrand:(SQRDCardBrand)brand
47 | {
48 | NSString *result = nil;
49 | switch (brand) {
50 | case SQRDCardBrandVisa:
51 | result = @"VISA";
52 | break;
53 | case SQRDCardBrandMastercard:
54 | result = @"MASTERCARD";
55 | break;
56 | case SQRDCardBrandAmericanExpress:
57 | result = @"AMERICAN_EXPRESS";
58 | break;
59 | case SQRDCardBrandDiscover:
60 | result = @"DISCOVER";
61 | break;
62 | case SQRDCardBrandDiscoverDiners:
63 | result = @"DISCOVER_DINERS";
64 | break;
65 | case SQRDCardBrandInterac:
66 | result = @"INTERAC";
67 | break;
68 | case SQRDCardBrandJCB:
69 | result = @"JCB";
70 | break;
71 | case SQRDCardBrandChinaUnionPay:
72 | result = @"CHINA_UNIONPAY";
73 | break;
74 | case SQRDCardBrandSquareGiftCard:
75 | result = @"SQUARE_GIFT_CARD";
76 | break;
77 | case SQRDCardBrandEftpos:
78 | result = @"EFTPOS";
79 | break;
80 | case SQRDCardBrandOtherBrand:
81 | result = @"OTHER_BRAND";
82 | break;
83 | }
84 | return result;
85 | }
86 |
87 | @end
88 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDCheckoutResult+RNReaderSDKAdditions.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | @import SquareReaderSDK;
18 |
19 |
20 | @interface SQRDCheckoutResult (RNReaderSDKAdditions)
21 |
22 | - (NSDictionary *)jsonDictionary;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDCheckoutResult+RNReaderSDKAdditions.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import "SQRDCheckoutResult+RNReaderSDKAdditions.h"
18 | #import "SQRDTender+RNReaderSDKAdditions.h"
19 | #import "SQRDMoney+RNReaderSDKAdditions.h"
20 | #import "RNReaderSDKDateFormatter.h"
21 |
22 |
23 | @implementation SQRDCheckoutResult (RNReaderSDKAdditions)
24 |
25 | - (NSDictionary *)jsonDictionary
26 | {
27 | // We use this "Ignore if null" principle for all returned dictionary
28 | NSMutableDictionary *jsTransactionResult = [[NSMutableDictionary alloc] init];
29 |
30 | if (self.transactionID) {
31 | jsTransactionResult[@"transactionId"] = self.transactionID;
32 | }
33 | jsTransactionResult[@"transactionClientId"] = self.transactionClientID;
34 | jsTransactionResult[@"locationId"] = self.locationID;
35 | jsTransactionResult[@"createdAt"] = [RNReaderSDKDateFormatter iso8601StringFromDate:self.createdAt];
36 | jsTransactionResult[@"totalMoney"] = [self.totalMoney jsonDictionary];
37 | jsTransactionResult[@"totalTipMoney"] = [self.totalTipMoney jsonDictionary];
38 |
39 | NSMutableArray *jsTenders = [[NSMutableArray alloc] init];
40 | for (SQRDTender *tender in self.tenders) {
41 | [jsTenders addObject:[tender jsonDictionary]];
42 | }
43 | jsTransactionResult[@"tenders"] = jsTenders;
44 |
45 | return [jsTransactionResult copy];
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDLocation+RNReaderSDKAdditions.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | @import SquareReaderSDK;
18 |
19 |
20 | @interface SQRDLocation (RNReaderSDKAdditions)
21 |
22 | - (NSDictionary *)jsonDictionary;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDLocation+RNReaderSDKAdditions.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import "SQRDLocation+RNReaderSDKAdditions.h"
18 | #import "SQRDMoney+RNReaderSDKAdditions.h"
19 |
20 |
21 | @implementation SQRDLocation (RNReaderSDKAdditions)
22 |
23 | - (NSDictionary *)jsonDictionary
24 | {
25 | return @{
26 | @"locationId" : self.locationID,
27 | @"name" : self.name,
28 | @"businessName" : self.businessName,
29 | @"isCardProcessingActivated" : @(self.isCardProcessingActivated),
30 | @"minimumCardPaymentAmountMoney" : [self.minimumCardPaymentAmountMoney jsonDictionary],
31 | @"maximumCardPaymentAmountMoney" : [self.maximumCardPaymentAmountMoney jsonDictionary],
32 | @"currencyCode" : SQRDCurrencyCodeGetISOCurrencyCode(self.currencyCode),
33 | };
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDMoney+RNReaderSDKAdditions.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | @import SquareReaderSDK;
18 |
19 |
20 | @interface SQRDMoney (RNReaderSDKAdditions)
21 |
22 | - (NSDictionary *)jsonDictionary;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDMoney+RNReaderSDKAdditions.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import "SQRDMoney+RNReaderSDKAdditions.h"
18 |
19 |
20 | @implementation SQRDMoney (RNReaderSDKAdditions)
21 |
22 | - (NSDictionary *)jsonDictionary
23 | {
24 | return @{
25 | @"amount" : @(self.amount),
26 | @"currencyCode" : SQRDCurrencyCodeGetISOCurrencyCode(self.currencyCode),
27 | };
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDTender+RNReaderSDKAdditions.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | @import SquareReaderSDK;
18 |
19 |
20 | @interface SQRDTender (RNReaderSDKAdditions)
21 |
22 | - (NSDictionary *)jsonDictionary;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDTender+RNReaderSDKAdditions.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import "SQRDTender+RNReaderSDKAdditions.h"
18 | #import "SQRDMoney+RNReaderSDKAdditions.h"
19 | #import "SQRDTenderCardDetails+RNReaderSDKAdditions.h"
20 | #import "SQRDTenderCashDetails+RNReaderSDKAdditions.h"
21 | #import "RNReaderSDKDateFormatter.h"
22 |
23 |
24 | @implementation SQRDTender (RNReaderSDKAdditions)
25 |
26 | - (NSDictionary *)jsonDictionary;
27 | {
28 | // We use this "Ignore if null" principle for all returned dictionary
29 | NSMutableDictionary *jsTenderResult = [[NSMutableDictionary alloc] init];
30 | jsTenderResult[@"createdAt"] = [RNReaderSDKDateFormatter iso8601StringFromDate:self.createdAt];
31 | jsTenderResult[@"tipMoney"] = [self.tipMoney jsonDictionary];
32 | jsTenderResult[@"totalMoney"] = [self.totalMoney jsonDictionary];
33 |
34 | NSString *jsTenderType = nil;
35 | switch (self.type) {
36 | case SQRDTenderTypeCard:
37 | jsTenderType = @"card";
38 | jsTenderResult[@"tenderId"] = self.tenderID;
39 | jsTenderResult[@"cardDetails"] = [self.cardDetails jsonDictionary];
40 | break;
41 | case SQRDTenderTypeCash:
42 | jsTenderType = @"cash";
43 | jsTenderResult[@"cashDetails"] = [self.cashDetails jsonDictionary];
44 | break;
45 | case SQRDTenderTypeOther:
46 | jsTenderType = @"other";
47 | break;
48 | }
49 | jsTenderResult[@"type"] = jsTenderType;
50 | return [jsTenderResult copy];
51 | }
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDTenderCardDetails+RNReaderSDKAdditions.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | @import SquareReaderSDK;
18 |
19 |
20 | @interface SQRDTenderCardDetails (RNReaderSDKAdditions)
21 |
22 | - (NSDictionary *)jsonDictionary;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDTenderCardDetails+RNReaderSDKAdditions.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import "SQRDTenderCardDetails+RNReaderSDKAdditions.h"
18 | #import "SQRDCard+RNReaderSDKAdditions.h"
19 |
20 |
21 | @implementation SQRDTenderCardDetails (RNReaderSDKAdditions)
22 |
23 | - (NSDictionary *)jsonDictionary
24 | {
25 | return @{
26 | @"entryMethod" : [self _stringFromTenderCardDetailsEntryMethod:self.entryMethod],
27 | @"card" : [self.card jsonDictionary],
28 | };
29 | }
30 |
31 | - (NSString *)_stringFromTenderCardDetailsEntryMethod:(SQRDTenderCardDetailsEntryMethod)method
32 | {
33 | NSString *result = nil;
34 | switch (method) {
35 | case SQRDTenderCardDetailsEntryMethodManuallyEntered:
36 | result = @"MANUALLY_ENTERED";
37 | break;
38 | case SQRDTenderCardDetailsEntryMethodSwipe:
39 | result = @"SWIPE";
40 | break;
41 | case SQRDTenderCardDetailsEntryMethodChip:
42 | result = @"CHIP";
43 | break;
44 | case SQRDTenderCardDetailsEntryMethodContactless:
45 | result = @"CONTACTLESS";
46 | break;
47 | case SQRDTenderCardDetailsEntryMethodUnknown:
48 | result = @"UNKNOWN";
49 | break;
50 | }
51 | return result;
52 | }
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDTenderCashDetails+RNReaderSDKAdditions.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | @import SquareReaderSDK;
18 |
19 |
20 | @interface SQRDTenderCashDetails (RNReaderSDKAdditions)
21 |
22 | - (NSDictionary *)jsonDictionary;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/Converters/SQRDTenderCashDetails+RNReaderSDKAdditions.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import "SQRDTenderCashDetails+RNReaderSDKAdditions.h"
18 | #import "SQRDMoney+RNReaderSDKAdditions.h"
19 |
20 |
21 | @implementation SQRDTenderCashDetails (RNReaderSDKAdditions)
22 |
23 | - (NSDictionary *)jsonDictionary
24 | {
25 | return @{
26 | @"buyerTenderedMoney" : [self.buyerTenderedMoney jsonDictionary],
27 | @"changeBackMoney" : [self.changeBackMoney jsonDictionary],
28 | };
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/ios/RNReaderSDK.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 |
3 |
5 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/RNReaderSDKAuthorization.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #if __has_include("RCTBridgeModule.h")
18 | #import "RCTBridgeModule.h"
19 | #else
20 | #import
21 | #endif
22 |
23 | @import SquareReaderSDK;
24 |
25 |
26 | @interface RNReaderSDKAuthorization : NSObject
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ios/RNReaderSDKCheckout.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #if __has_include("RCTBridgeModule.h")
18 | #import "RCTBridgeModule.h"
19 | #else
20 | #import
21 | #endif
22 |
23 | @import SquareReaderSDK;
24 |
25 |
26 | @interface RNReaderSDKCheckout : NSObject
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ios/RNReaderSDKErrorUtilities.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import
18 |
19 | extern NSString *const RNReaderSDKUsageError;
20 |
21 |
22 | @interface RNReaderSDKErrorUtilities : NSObject
23 |
24 | + (NSString *)createNativeModuleError:(NSString *)nativeModuleErrorCode debugMessage:(NSString *)debugMessage;
25 |
26 | + (NSString *)serializeErrorToJson:(NSString *)debugCode message:(NSString *)message debugMessage:(NSString *)debugMessage;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ios/RNReaderSDKErrorUtilities.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import "RNReaderSDKErrorUtilities.h"
18 | @import SquareReaderSDK;
19 |
20 | // Usage error
21 | NSString *const RNReaderSDKUsageError = @"USAGE_ERROR";
22 |
23 |
24 | @implementation RNReaderSDKErrorUtilities
25 |
26 | + (NSString *)createNativeModuleError:(NSString *)nativeModuleErrorCode debugMessage:(NSString *)debugMessage
27 | {
28 | return [self serializeErrorToJson:nativeModuleErrorCode
29 | message:[NSString stringWithFormat:@"Something went wrong. Please contact the developer of this application and provide them with this error code: %@", nativeModuleErrorCode]
30 | debugMessage:debugMessage];
31 | }
32 |
33 | + (NSString *)serializeErrorToJson:(NSString *)debugCode message:(NSString *)message debugMessage:(NSString *)debugMessage
34 | {
35 | NSMutableDictionary *errObject = [[NSMutableDictionary alloc] init];
36 | errObject[@"debugCode"] = debugCode;
37 | errObject[@"message"] = message;
38 | errObject[@"debugMessage"] = debugMessage;
39 | NSError *writeError = nil;
40 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:errObject options:NSJSONWritingPrettyPrinted error:&writeError];
41 | if (jsonData) {
42 | return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
43 | } else {
44 | return [NSString stringWithFormat:@"{'message': '%@'}",
45 | @"failed to serialize error"];
46 | }
47 | }
48 | @end
49 |
--------------------------------------------------------------------------------
/ios/RNReaderSDKReaderSettings.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #if __has_include("RCTBridgeModule.h")
18 | #import "RCTBridgeModule.h"
19 | #else
20 | #import
21 | #endif
22 |
23 | @import SquareReaderSDK;
24 |
25 |
26 | @interface RNReaderSDKReaderSettings : NSObject
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ios/RNReaderSDKReaderSettings.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #import "RNReaderSDKReaderSettings.h"
18 | #import "RNReaderSDKErrorUtilities.h"
19 |
20 |
21 | @interface RNReaderSDKReaderSettings ()
22 |
23 | @property (strong, readwrite) RCTPromiseResolveBlock readerSettingResolver;
24 | @property (strong, readwrite) RCTPromiseRejectBlock readerSettingRejecter;
25 |
26 | @end
27 |
28 | // Define all the error codes and messages below
29 | // These error codes and messages **MUST** align with iOS error codes and javascript error codes
30 | // Search KEEP_IN_SYNC_READER_SETTINGS_ERROR to update all places
31 |
32 | // Expected errors:
33 | static NSString *const RNReaderSDKReaderSettingsSdkNotAuthorized = @"READER_SETTINGS_SDK_NOT_AUTHORIZED";
34 |
35 | // React native module debug error codes
36 | static NSString *const RNReaderSDKRNReaderSettingsAlreadyInProgress = @"rn_reader_settings_already_in_progress";
37 |
38 | // react native module debug messages
39 | static NSString *const RNReaderSDKRNMessageReaderSettingsAlreadyInProgress = @"A reader settings operation is already in progress. Ensure that the in-progress reader settings is completed before calling startReaderSettingsAsync again.";
40 |
41 |
42 | @implementation RNReaderSDKReaderSettings
43 |
44 | RCT_EXPORT_MODULE();
45 |
46 | RCT_REMAP_METHOD(startReaderSettings,
47 | startReaderSettingsWithResolver
48 | : (RCTPromiseResolveBlock)resolve
49 | rejecter
50 | : (RCTPromiseRejectBlock)reject)
51 | {
52 | dispatch_async(dispatch_get_main_queue(), ^{
53 | if (self.readerSettingResolver != nil) {
54 | reject(RNReaderSDKUsageError, [RNReaderSDKErrorUtilities createNativeModuleError:RNReaderSDKRNReaderSettingsAlreadyInProgress debugMessage:RNReaderSDKRNMessageReaderSettingsAlreadyInProgress], nil);
55 | return;
56 | }
57 | SQRDReaderSettingsController *readerSettingsController = [[SQRDReaderSettingsController alloc] initWithDelegate:self];
58 | self.readerSettingResolver = resolve;
59 | self.readerSettingRejecter = reject;
60 | UIViewController *rootViewController = UIApplication.sharedApplication.delegate.window.rootViewController;
61 | [readerSettingsController presentFromViewController:rootViewController];
62 | });
63 | }
64 |
65 | - (void)readerSettingsControllerDidPresent:(SQRDReaderSettingsController *)readerSettingsController
66 | {
67 | self.readerSettingResolver([NSNull null]);
68 | [self clearReaderSettingHooks];
69 | }
70 |
71 | - (void)readerSettingsController:(SQRDReaderSettingsController *)readerSettingsController didFailToPresentWithError:(NSError *)error
72 | {
73 | NSString *message = error.localizedDescription;
74 | NSString *debugCode = error.userInfo[SQRDErrorDebugCodeKey];
75 | NSString *debugMessage = error.userInfo[SQRDErrorDebugMessageKey];
76 | self.readerSettingRejecter([self _readerSettingsErrorCodeFromNativeErrorCode:error.code],
77 | [RNReaderSDKErrorUtilities serializeErrorToJson:debugCode message:message debugMessage:debugMessage],
78 | error);
79 | [self clearReaderSettingHooks];
80 | }
81 |
82 | - (void)clearReaderSettingHooks
83 | {
84 | self.readerSettingResolver = nil;
85 | self.readerSettingRejecter = nil;
86 | }
87 |
88 | - (NSString *)_readerSettingsErrorCodeFromNativeErrorCode:(NSInteger)nativeErrorCode
89 | {
90 | NSString *errorCode = @"UNKNOWN";
91 | if (nativeErrorCode == SQRDReaderSettingsControllerErrorUsageError) {
92 | errorCode = RNReaderSDKUsageError;
93 | } else {
94 | switch (nativeErrorCode) {
95 | case SQRDReaderSettingsControllerErrorSDKNotAuthorized:
96 | errorCode = RNReaderSDKReaderSettingsSdkNotAuthorized;
97 | break;
98 | }
99 | }
100 | return errorCode;
101 | }
102 |
103 | @end
104 |
--------------------------------------------------------------------------------
/ios/RNReaderSDKStoreCustomerCard.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | #if __has_include("RCTBridgeModule.h")
18 | #import "RCTBridgeModule.h"
19 | #else
20 | #import
21 | #endif
22 |
23 | @import SquareReaderSDK;
24 |
25 |
26 | @interface RNReaderSDKStoreCustomerCard : NSObject
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-square-reader-sdk",
3 | "version": "1.7.2",
4 | "description": "A React Native plugin for Square Reader SDK",
5 | "homepage": "https://github.com/square/react-native-square-reader-sdk",
6 | "repository": {
7 | "type": "git",
8 | "url": "https://github.com/square/react-native-square-reader-sdk.git"
9 | },
10 | "main": "index.js",
11 | "types": "index.d.ts",
12 | "scripts": {
13 | "lint": "eslint ./ --ext .js",
14 | "test": "jest"
15 | },
16 | "keywords": [
17 | "react-native",
18 | "reader-sdk",
19 | "square",
20 | "payments"
21 | ],
22 | "author": "Square, Inc.",
23 | "license": "Apache-2.0",
24 | "peerDependencies": {
25 | "react-native": ">= 0.55.4"
26 | },
27 | "devDependencies": {
28 | "babel-eslint": "^10.1.0",
29 | "eslint": "7.28.0",
30 | "eslint-config-airbnb": "^18.2.1",
31 | "eslint-config-airbnb-base": "^14.2.1",
32 | "eslint-plugin-import": "^2.23.4",
33 | "eslint-plugin-jsx-a11y": "^6.4.1",
34 | "eslint-plugin-react": "^7.24.0",
35 | "eslint-plugin-react-native": "^3.11.0",
36 | "jest": "^27.0.6",
37 | "react": "17.0.1",
38 | "react-native": "0.64.1"
39 | },
40 | "jest": {
41 | "preset": "react-native",
42 | "transform": {
43 | "^.+\\.js$": "/node_modules/react-native/jest/preprocessor.js"
44 | },
45 | "modulePathIgnorePatterns": [
46 | "reader-sdk-react-native-quickstart"
47 | ]
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/.buckconfig:
--------------------------------------------------------------------------------
1 |
2 | [android]
3 | target = Google Inc.:Google APIs:24
4 |
5 | [maven_repositories]
6 | central = https://repo1.maven.org/maven2
7 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/.bundle/config:
--------------------------------------------------------------------------------
1 | BUNDLE_PATH: "vendor/bundle"
2 | BUNDLE_FORCE_RUBY_PLATFORM: 1
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: '@react-native-community',
4 | parser: '@typescript-eslint/parser',
5 | plugins: ['@typescript-eslint'],
6 | overrides: [
7 | {
8 | files: ['*.ts', '*.tsx'],
9 | rules: {
10 | '@typescript-eslint/no-shadow': ['error'],
11 | 'no-shadow': 'off',
12 | 'no-undef': 'off',
13 | },
14 | },
15 | ],
16 | };
17 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 |
24 | # Android/IntelliJ
25 | #
26 | build/
27 | .idea
28 | .gradle
29 | local.properties
30 | *.iml
31 | *.hprof
32 |
33 | # node.js
34 | #
35 | node_modules/
36 | npm-debug.log
37 | yarn-error.log
38 |
39 | # BUCK
40 | buck-out/
41 | \.buckd/
42 | *.keystore
43 | !debug.keystore
44 |
45 | # fastlane
46 | #
47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48 | # screenshots whenever they are needed.
49 | # For more information about the recommended setup visit:
50 | # https://docs.fastlane.tools/best-practices/source-control/
51 |
52 | */fastlane/report.xml
53 | */fastlane/Preview.html
54 | */fastlane/screenshots
55 |
56 | # Bundle artifact
57 | *.jsbundle
58 | .yarn
59 | /.yarn
60 | # CocoaPods
61 | /ios/Pods/
62 |
63 |
64 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | bracketSpacing: false,
3 | jsxBracketSameLine: true,
4 | singleQuote: true,
5 | trailingComma: 'all',
6 | arrowParens: 'avoid',
7 | };
8 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/.ruby-version:
--------------------------------------------------------------------------------
1 | 2.7.4
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/App.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import 'react-native-gesture-handler';
18 | import React, {FC} from 'react';
19 | import {GlobalizeProvider, loadCldr} from 'react-native-globalize';
20 | import {NavigationContainer} from '@react-navigation/native';
21 | import {createStackNavigator} from '@react-navigation/stack';
22 | import {ChooseAuthorizeScreen} from './app/screens/ChooseAuthorizeScreen';
23 | import {ManualAuthorizeScreen} from './app/screens/ManualAuthorizeScreen';
24 | import CheckoutScreen from './app/screens/CheckoutScreen';
25 | import {SettingScreen} from './app/screens/SettingScreen';
26 | import SplashScreen from './app/screens/SplashScreen';
27 | import {PermissionScreenIOS} from './app/screens/PermissionScreenIOS';
28 | import {QRAuthorizationScreen} from './app/screens/QRAuthorizationScreen';
29 | import AuthorizingScreen from './app/screens/AuthorizingScreen';
30 | import DeauthorizingScreen from './app/screens/DeauthorizingScreen';
31 |
32 | loadCldr(
33 | // Load the locales you actually need
34 | require('react-native-globalize/locale-data/en'),
35 | );
36 |
37 | const App: FC = () => {
38 | const Stack = createStackNavigator();
39 | const AuthStack = () => {
40 | return (
41 |
42 |
43 |
44 |
48 |
49 |
50 | );
51 | };
52 |
53 | const PaymentStack = () => {
54 | return (
55 |
56 |
57 |
58 |
59 |
60 | );
61 | };
62 |
63 | return (
64 |
65 |
66 |
69 |
70 |
74 |
75 |
76 |
77 |
78 |
79 | );
80 | };
81 |
82 | export default App;
83 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
3 | ruby '2.7.4'
4 | gem 'cocoapods', '~> 1.11', '>= 1.11.2'
5 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (3.0.5)
5 | rexml
6 | activesupport (6.1.4.4)
7 | concurrent-ruby (~> 1.0, >= 1.0.2)
8 | i18n (>= 1.6, < 2)
9 | minitest (>= 5.1)
10 | tzinfo (~> 2.0)
11 | zeitwerk (~> 2.3)
12 | addressable (2.8.0)
13 | public_suffix (>= 2.0.2, < 5.0)
14 | algoliasearch (1.27.5)
15 | httpclient (~> 2.8, >= 2.8.3)
16 | json (>= 1.5.1)
17 | atomos (0.1.3)
18 | claide (1.1.0)
19 | cocoapods (1.11.2)
20 | addressable (~> 2.8)
21 | claide (>= 1.0.2, < 2.0)
22 | cocoapods-core (= 1.11.2)
23 | cocoapods-deintegrate (>= 1.0.3, < 2.0)
24 | cocoapods-downloader (>= 1.4.0, < 2.0)
25 | cocoapods-plugins (>= 1.0.0, < 2.0)
26 | cocoapods-search (>= 1.0.0, < 2.0)
27 | cocoapods-trunk (>= 1.4.0, < 2.0)
28 | cocoapods-try (>= 1.1.0, < 2.0)
29 | colored2 (~> 3.1)
30 | escape (~> 0.0.4)
31 | fourflusher (>= 2.3.0, < 3.0)
32 | gh_inspector (~> 1.0)
33 | molinillo (~> 0.8.0)
34 | nap (~> 1.0)
35 | ruby-macho (>= 1.0, < 3.0)
36 | xcodeproj (>= 1.21.0, < 2.0)
37 | cocoapods-core (1.11.2)
38 | activesupport (>= 5.0, < 7)
39 | addressable (~> 2.8)
40 | algoliasearch (~> 1.0)
41 | concurrent-ruby (~> 1.1)
42 | fuzzy_match (~> 2.0.4)
43 | nap (~> 1.0)
44 | netrc (~> 0.11)
45 | public_suffix (~> 4.0)
46 | typhoeus (~> 1.0)
47 | cocoapods-deintegrate (1.0.5)
48 | cocoapods-downloader (1.5.1)
49 | cocoapods-plugins (1.0.0)
50 | nap
51 | cocoapods-search (1.0.1)
52 | cocoapods-trunk (1.6.0)
53 | nap (>= 0.8, < 2.0)
54 | netrc (~> 0.11)
55 | cocoapods-try (1.2.0)
56 | colored2 (3.1.2)
57 | concurrent-ruby (1.1.9)
58 | escape (0.0.4)
59 | ethon (0.15.0)
60 | ffi (>= 1.15.0)
61 | ffi (1.15.5)
62 | fourflusher (2.3.1)
63 | fuzzy_match (2.0.4)
64 | gh_inspector (1.1.3)
65 | httpclient (2.8.3)
66 | i18n (1.9.1)
67 | concurrent-ruby (~> 1.0)
68 | json (2.6.1)
69 | minitest (5.15.0)
70 | molinillo (0.8.0)
71 | nanaimo (0.3.0)
72 | nap (1.1.0)
73 | netrc (0.11.0)
74 | public_suffix (4.0.6)
75 | rexml (3.2.5)
76 | ruby-macho (2.5.1)
77 | typhoeus (1.4.0)
78 | ethon (>= 0.9.0)
79 | tzinfo (2.0.4)
80 | concurrent-ruby (~> 1.0)
81 | xcodeproj (1.21.0)
82 | CFPropertyList (>= 2.3.3, < 4.0)
83 | atomos (~> 0.1.3)
84 | claide (>= 1.0.2, < 2.0)
85 | colored2 (~> 3.1)
86 | nanaimo (~> 0.3.0)
87 | rexml (~> 3.2.4)
88 | zeitwerk (2.5.4)
89 | PLATFORMS
90 | ruby
91 | DEPENDENCIES
92 | cocoapods (~> 1.11, >= 1.11.2)
93 | RUBY VERSION
94 | ruby 2.7.4p191
95 | BUNDLED WITH
96 | 2.2.27
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/SquareReaderSDK.xcframework/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AvailableLibraries
6 |
7 |
8 | LibraryIdentifier
9 | ios-arm64
10 | LibraryPath
11 | SquareReaderSDK.framework
12 | SupportedArchitectures
13 |
14 | arm64
15 |
16 | SupportedPlatform
17 | ios
18 |
19 |
20 | LibraryIdentifier
21 | ios-arm64_x86_64-simulator
22 | LibraryPath
23 | SquareReaderSDK.framework
24 | SupportedArchitectures
25 |
26 | arm64
27 | x86_64
28 |
29 | SupportedPlatform
30 | ios
31 | SupportedPlatformVariant
32 | simulator
33 |
34 |
35 | CFBundlePackageType
36 | XFWK
37 | XCFrameworkFormatVersion
38 | 1.0
39 |
40 |
41 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/__tests__/App-test.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import 'react-native';
6 | import React from 'react';
7 | import App from '../App';
8 |
9 | // Note: test renderer must be required after react-native.
10 | import renderer from 'react-test-renderer';
11 |
12 | it('renders correctly', () => {
13 | renderer.create();
14 | });
15 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/_BUCK:
--------------------------------------------------------------------------------
1 | # To learn about Buck see [Docs](https://buckbuild.com/).
2 | # To run your application with Buck:
3 | # - install Buck
4 | # - `npm start` - to start the packager
5 | # - `cd android`
6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8 | # - `buck install -r android/app` - compile, install and run application
9 | #
10 |
11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12 |
13 | lib_deps = []
14 |
15 | create_aar_targets(glob(["libs/*.aar"]))
16 |
17 | create_jar_targets(glob(["libs/*.jar"]))
18 |
19 | android_library(
20 | name = "all-libs",
21 | exported_deps = lib_deps,
22 | )
23 |
24 | android_library(
25 | name = "app-code",
26 | srcs = glob([
27 | "src/main/java/**/*.java",
28 | ]),
29 | deps = [
30 | ":all-libs",
31 | ":build_config",
32 | ":res",
33 | ],
34 | )
35 |
36 | android_build_config(
37 | name = "build_config",
38 | package = "com.rnreadersdksample",
39 | )
40 |
41 | android_resource(
42 | name = "res",
43 | package = "com.rnreadersdksample",
44 | res = "src/main/res",
45 | )
46 |
47 | android_binary(
48 | name = "app",
49 | keystore = "//android/keystores:debug",
50 | manifest = "src/main/AndroidManifest.xml",
51 | package_type = "debug",
52 | deps = [
53 | ":app-code",
54 | ],
55 | )
56 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/build_defs.bzl:
--------------------------------------------------------------------------------
1 | """Helper definitions to glob .aar and .jar targets"""
2 |
3 | def create_aar_targets(aarfiles):
4 | for aarfile in aarfiles:
5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6 | lib_deps.append(":" + name)
7 | android_prebuilt_aar(
8 | name = name,
9 | aar = aarfile,
10 | )
11 |
12 | def create_jar_targets(jarfiles):
13 | for jarfile in jarfiles:
14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15 | lib_deps.append(":" + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/debug.keystore
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Copyright 2022 Square Inc.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # Add project specific ProGuard rules here.
16 | # By default, the flags in this file are appended to flags specified
17 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
18 | # You can edit the include path and order by changing the proguardFiles
19 | # directive in build.gradle.
20 | #
21 | # For more details, see
22 | # http://developer.android.com/guide/developing/tools/proguard.html
23 |
24 | # Add any project specific keep options here:
25 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/debug/java/com/rnreadersdksample/ReactNativeFlipper.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.rnreadersdksample;
17 |
18 | import android.content.Context;
19 | import com.facebook.flipper.android.AndroidFlipperClient;
20 | import com.facebook.flipper.android.utils.FlipperUtils;
21 | import com.facebook.flipper.core.FlipperClient;
22 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
23 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
24 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
25 | import com.facebook.flipper.plugins.inspector.DescriptorMapping;
26 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
27 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
28 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
29 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
30 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
31 | import com.facebook.react.ReactInstanceManager;
32 | import com.facebook.react.bridge.ReactContext;
33 | import com.facebook.react.modules.network.NetworkingModule;
34 | import okhttp3.OkHttpClient;
35 |
36 | public class ReactNativeFlipper {
37 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
38 | if (FlipperUtils.shouldEnableFlipper(context)) {
39 | final FlipperClient client = AndroidFlipperClient.getInstance(context);
40 |
41 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
42 | client.addPlugin(new ReactFlipperPlugin());
43 | client.addPlugin(new DatabasesFlipperPlugin(context));
44 | client.addPlugin(new SharedPreferencesFlipperPlugin(context));
45 | client.addPlugin(CrashReporterPlugin.getInstance());
46 |
47 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
48 | NetworkingModule.setCustomClientBuilder(
49 | new NetworkingModule.CustomClientBuilder() {
50 | @Override
51 | public void apply(OkHttpClient.Builder builder) {
52 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
53 | }
54 | });
55 | client.addPlugin(networkFlipperPlugin);
56 | client.start();
57 |
58 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
59 | // Hence we run if after all native modules have been initialized
60 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
61 | if (reactContext == null) {
62 | reactInstanceManager.addReactInstanceEventListener(
63 | new ReactInstanceManager.ReactInstanceEventListener() {
64 | @Override
65 | public void onReactContextInitialized(ReactContext reactContext) {
66 | reactInstanceManager.removeReactInstanceEventListener(this);
67 | reactContext.runOnNativeModulesQueueThread(
68 | new Runnable() {
69 | @Override
70 | public void run() {
71 | client.addPlugin(new FrescoFlipperPlugin());
72 | }
73 | });
74 | }
75 | });
76 | } else {
77 | client.addPlugin(new FrescoFlipperPlugin());
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
30 |
33 |
34 |
42 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/java/com/rnreadersdksample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 | http://www.apache.org/licenses/LICENSE-2.0
7 | Unless required by applicable law or agreed to in writing, software
8 | distributed under the License is distributed on an "AS IS" BASIS,
9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | See the License for the specific language governing permissions and
11 | limitations under the License.
12 | */
13 | package com.rnreadersdksample
14 |
15 | import com.facebook.react.ReactActivity
16 | import android.os.Bundle
17 |
18 | class MainActivity : ReactActivity() {
19 | /**
20 | * Returns the name of the main component registered from JavaScript. This is used to schedule
21 | * rendering of the component.
22 | */
23 | override fun getMainComponentName(): String? {
24 | return "RNReaderSDKSample"
25 | }
26 |
27 | override fun onCreate(savedInstanceState: Bundle?) {
28 | super.onCreate(null)
29 | }
30 | }
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/java/com/rnreadersdksample/MainApplication.kt:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 | http://www.apache.org/licenses/LICENSE-2.0
7 | Unless required by applicable law or agreed to in writing, software
8 | distributed under the License is distributed on an "AS IS" BASIS,
9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | See the License for the specific language governing permissions and
11 | limitations under the License.
12 | */
13 | package com.rnreadersdksample
14 |
15 | import android.app.Application
16 | import com.facebook.react.ReactApplication
17 | import com.facebook.react.ReactNativeHost
18 | import com.facebook.react.ReactPackage
19 | import com.facebook.react.PackageList
20 | import com.facebook.soloader.SoLoader
21 | import com.squareup.sdk.reader.ReaderSdk
22 | import com.rnreadersdksample.MainApplication
23 | import android.content.Context
24 | import com.facebook.react.ReactInstanceManager
25 | import java.lang.ClassNotFoundException
26 | import java.lang.NoSuchMethodException
27 | import java.lang.IllegalAccessException
28 | import java.lang.reflect.InvocationTargetException
29 |
30 | class MainApplication : Application(), ReactApplication {
31 | override val reactNativeHost: ReactNativeHost = object : ReactNativeHost(this) {
32 | override fun getUseDeveloperSupport(): Boolean {
33 | return BuildConfig.DEBUG
34 | }
35 |
36 | override fun getPackages(): List {
37 | // Packages that cannot be autolinked yet can be added manually here, for example:
38 | // packages.add(new MyReactNativePackage());
39 | return PackageList(this).packages
40 | }
41 |
42 | override fun getJSMainModuleName(): String {
43 | return "index"
44 | }
45 | }
46 |
47 | override fun onCreate() {
48 | super.onCreate()
49 | SoLoader.init(this, /* native exopackage */false)
50 | ReaderSdk.initialize(this)
51 | initializeFlipper(this, reactNativeHost.reactInstanceManager)
52 | }
53 |
54 | companion object {
55 | /**
56 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like
57 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
58 | *
59 | * @param context
60 | * @param reactInstanceManager
61 | */
62 | private fun initializeFlipper(
63 | context: Context, reactInstanceManager: ReactInstanceManager
64 | ) {
65 | if (BuildConfig.DEBUG) {
66 | try {
67 | /*
68 | We use reflection here to pick up the class that initializes Flipper,
69 | since Flipper library is not available in release mode
70 | */
71 | val aClass = Class.forName("com.rnreadersdksample.ReactNativeFlipper")
72 | aClass.getMethod(
73 | "initializeFlipper",
74 | Context::class.java,
75 | ReactInstanceManager::class.java
76 | )
77 | .invoke(null, context, reactInstanceManager)
78 | } catch (e: ClassNotFoundException) {
79 | e.printStackTrace()
80 | } catch (e: NoSuchMethodException) {
81 | e.printStackTrace()
82 | } catch (e: IllegalAccessException) {
83 | e.printStackTrace()
84 | } catch (e: InvocationTargetException) {
85 | e.printStackTrace()
86 | }
87 | }
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable-hdpi/ic_jewel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable-hdpi/ic_jewel.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable-mdpi/ic_jewel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable-mdpi/ic_jewel.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable-xhdpi/ic_jewel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable-xhdpi/ic_jewel.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable-xxhdpi/ic_jewel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable-xxhdpi/ic_jewel.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable-xxxhdpi/ic_jewel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable-xxxhdpi/ic_jewel.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/drawable/rn_edit_text_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
18 |
19 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | @color/blue
19 | @color/dark_blue
20 | @color/white
21 | #4087E1
22 |
23 | #b34A90E2
24 | #FFFFFF
25 |
26 | #b3FFFFFF
27 |
28 | #80FFFFFF
29 | #3A71B0
30 |
31 | #803A71B0
32 | #757575
33 | #FF3B30
34 |
35 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | RNReaderSDKSample
19 |
20 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
26 |
27 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 | http://www.apache.org/licenses/LICENSE-2.0
7 | Unless required by applicable law or agreed to in writing, software
8 | distributed under the License is distributed on an "AS IS" BASIS,
9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | See the License for the specific language governing permissions and
11 | limitations under the License.
12 | */
13 |
14 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
15 | buildscript {
16 | subprojects {
17 | afterEvaluate {project ->
18 | if (project.hasProperty("android")) {
19 | android {
20 | compileSdkVersion 34
21 | buildToolsVersion "34.0.0"
22 |
23 | }
24 | }
25 | }
26 | }
27 | ext {
28 | buildToolsVersion = "33.0.0"
29 | minSdkVersion = 24
30 | compileSdkVersion = 34
31 | targetSdkVersion = 33
32 | readerSdkVersion = "1.7.4"
33 | ndkVersion = "21.4.7075529"
34 | kotlin_version ='1.8.21'
35 | }
36 | repositories {
37 | google()
38 | mavenCentral()
39 | maven {
40 | url "https://maven.google.com"
41 | }
42 | }
43 | dependencies {
44 |
45 | classpath('com.android.tools.build:gradle:8.5.1')
46 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21")
47 | classpath("com.facebook.react:react-native-gradle-plugin")
48 |
49 | // NOTE: Do not place your application dependencies here; they belong
50 | // in the individual module build.gradle files
51 | }
52 | }
53 |
54 | allprojects {
55 | repositories {
56 |
57 | maven {
58 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
59 | url("$rootDir/../node_modules/react-native/android")
60 | }
61 | maven {
62 | // Android JSC is installed from npm
63 | url("$rootDir/../node_modules/jsc-android/dist")
64 | }
65 | maven {
66 | url "https://sdk.squareup.com/android"
67 | credentials {
68 | username SQUARE_READER_SDK_APPLICATION_ID
69 | password SQUARE_READER_SDK_REPOSITORY_PASSWORD
70 | }
71 | }
72 | google()
73 | mavenCentral()
74 | maven { url 'https://www.jitpack.io' }
75 | maven {
76 | url "https://maven.google.com"
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Copyright 2022 Square Inc.
2 |
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 |
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # Project-wide Gradle settings.
16 |
17 | # IDE (e.g. Android Studio) users:
18 | # Gradle settings configured through the IDE *will override*
19 | # any settings specified in this file.
20 |
21 | # For more details on how to configure your build environment visit
22 | # http://www.gradle.org/docs/current/userguide/build_environment.html
23 |
24 | # Specifies the JVM arguments used for the daemon process.
25 | # The setting is particularly useful for tweaking memory settings.
26 | # Default value: -Xmx1024m -XX:MaxPermSize=256m
27 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
28 |
29 | # When configured, Gradle will run in incubating parallel mode.
30 | # This option should only be used with decoupled projects. More details, visit
31 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
32 | # org.gradle.parallel=true
33 |
34 | # AndroidX package structure to make it clearer which packages are bundled with the
35 | # Android operating system, and which are packaged with your app's APK
36 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
37 | android.useAndroidX=true
38 | org.gradle.jvmargs=-Xmx4g
39 | # Automatically convert third-party libraries to use AndroidX
40 | android.enableJetifier=false
41 | # Version of flipper SDK to use with React Native
42 | FLIPPER_VERSION=0.99.0
43 |
44 | ## The Application ID displayed on the Credentials tab in the Square Application Control Panel.
45 | SQUARE_READER_SDK_APPLICATION_ID=SQUARE_READER_SDK_APPLICATION_ID
46 |
47 | ## The Application Secret from the OAuth tab in the Square Application Control Panel.
48 | SQUARE_READER_SDK_REPOSITORY_PASSWORD=SQUARE_READER_SDK_REPOSITORY_PASSWORD
49 |
50 | hermesEnabled=false
51 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Aug 01 16:15:50 IST 2024
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/android/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | include ':react-native-square-reader-sdk'
3 | project(':react-native-square-reader-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-square-reader-sdk/android')
4 | include ':react-native-reanimated'
5 | project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
6 | include ':react-native-gesture-handler'
7 | project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
8 | include ':react-native-gesture-handler'
9 | project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
10 | Copyright 2022 Square Inc.
11 |
12 | Licensed under the Apache License, Version 2.0 (the "License");
13 | you may not use this file except in compliance with the License.
14 | You may obtain a copy of the License at
15 |
16 | http://www.apache.org/licenses/LICENSE-2.0
17 |
18 | Unless required by applicable law or agreed to in writing, software
19 | distributed under the License is distributed on an "AS IS" BASIS,
20 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | See the License for the specific language governing permissions and
22 | limitations under the License.
23 | */
24 |
25 | rootProject.name = 'RNReaderSDKSample'
26 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
27 | include ':app'
28 | includeBuild('../node_modules/@react-native/gradle-plugin')
29 |
30 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "RNReaderSDKSample",
3 | "displayName": "RNReaderSDKSample"
4 | }
5 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/assets/images/ic_jewel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/app/assets/images/ic_jewel.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/assets/images/setting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/app/assets/images/setting.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/components/CustomButton.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import React, {FC} from 'react';
18 | import {StyleSheet, TouchableOpacity, Text} from 'react-native';
19 |
20 | class Props {
21 | title: string;
22 | onPress() {}
23 | disabled?: boolean = false;
24 | primary?: boolean = false;
25 | }
26 |
27 | const CustomButton: FC = props => {
28 | return (
29 |
44 |
50 | {props.title}
51 |
52 |
53 | );
54 | };
55 |
56 | const styles = StyleSheet.create({
57 | button: {
58 | alignItems: 'center',
59 | borderRadius: 8,
60 | height: 64,
61 | justifyContent: 'center',
62 | marginTop: 15,
63 | },
64 | buttonText: {
65 | color: 'white',
66 | fontSize: 20,
67 | fontWeight: '600',
68 | },
69 | disabledButton: {
70 | borderColor: 'rgba(255, 255, 255, 0.6)',
71 | },
72 | disabledButtonText: {
73 | color: 'rgba(255, 255, 255, 0.6)',
74 | },
75 | primaryButton: {
76 | backgroundColor: '#3972B2',
77 | },
78 | secondaryButton: {
79 | borderColor: 'white',
80 | borderWidth: 1,
81 | },
82 | });
83 |
84 | export default CustomButton;
85 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/components/ProgressView.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import React, {FC} from 'react';
18 | import {StyleSheet, View, ActivityIndicator} from 'react-native';
19 | import {defaultStyles} from '../styles/common';
20 |
21 | const ProgressView: FC = () => {
22 | return (
23 |
24 |
25 |
30 |
31 |
32 | );
33 | };
34 |
35 | const styles = StyleSheet.create({
36 | activityIndicator: {
37 | alignItems: 'center',
38 | flex: 1,
39 | },
40 | indicatorContainer: {
41 | flex: 1,
42 | },
43 | });
44 |
45 | export default ProgressView;
46 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/components/SquareLogo.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import React, {FC} from 'react';
18 | import {Animated} from 'react-native';
19 |
20 | const SquareLogo: FC = props => {
21 | return (
22 |
26 | );
27 | };
28 |
29 | class Props {
30 | width?: number = 48;
31 | height?: number = 48;
32 | style?: any = null;
33 | }
34 |
35 | export default SquareLogo;
36 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/screens/AuthorizingScreen.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | import React, {useEffect} from 'react';
17 | import {Alert} from 'react-native';
18 | import {
19 | authorizeAsync,
20 | AuthorizeErrorNoNetwork,
21 | UsageError,
22 | } from 'react-native-square-reader-sdk';
23 | import ProgressView from '../components/ProgressView';
24 |
25 | export default function AuthorizingScreen({navigation, route}) {
26 | // GET AUTHORIZE CODE
27 | useEffect(() => {
28 | authorize();
29 | });
30 |
31 | // CHECK AUTHENTICATION CODE
32 | const authorize = async () => {
33 | const authCode = route.params.authCode;
34 | if (!authCode) {
35 | Alert.alert('Error: empty auth code');
36 | navigation.goBack();
37 | return;
38 | }
39 | try {
40 | await authorizeAsync(authCode);
41 | navigation.navigate('Checkout');
42 | } catch (ex: any) {
43 | let errorMessage = ex.message;
44 | // SWITCHCASE FOR ERROR CONDITIONS
45 | switch (ex.code) {
46 | case AuthorizeErrorNoNetwork:
47 | // Remind connecting to network and retry
48 | Alert.alert('Network error', ex.message, [
49 | {text: 'Retry', onPress: () => authorize()},
50 | {
51 | text: 'Cancel',
52 | onPress: () => navigation.navigate('Authorize'),
53 | style: 'cancel',
54 | },
55 | ]);
56 | break;
57 | case UsageError:
58 | if (__DEV__) {
59 | errorMessage += `\n\nDebug Message: ${ex.debugMessage}`;
60 | console.log(`${ex.code}:${ex.debugCode}:${ex.debugMessage}`);
61 | }
62 | Alert.alert('Error', errorMessage);
63 | navigation.navigate('Authorize');
64 | break;
65 | default:
66 | Alert.alert('Error', errorMessage);
67 | navigation.navigate('Authorize');
68 | break;
69 | }
70 | }
71 | };
72 |
73 | // MAIN VIEW DESIGN
74 | return ;
75 | }
76 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/screens/ChooseAuthorizeScreen.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | import React from 'react';
17 | import {View, Text, Alert, Platform} from 'react-native';
18 | import RNPermissions, {
19 | openSettings,
20 | PERMISSIONS,
21 | RESULTS,
22 | } from 'react-native-permissions';
23 | import CustomButton from '../components/CustomButton';
24 | import SquareLogo from '../components/SquareLogo';
25 | import {defaultStyles} from '../styles/common';
26 |
27 | export function ChooseAuthorizeScreen({navigation}) {
28 | // CHECK PERMISSION AND SCAN QRCODE
29 | const goToQRAuthorize = async () => {
30 | try {
31 | let cameraPermission;
32 | if (Platform.OS === 'ios') {
33 | cameraPermission = await RNPermissions.check(PERMISSIONS.IOS.CAMERA);
34 | } else {
35 | cameraPermission = await RNPermissions.check(
36 | PERMISSIONS.ANDROID.CAMERA,
37 | );
38 | }
39 |
40 | console.log(cameraPermission);
41 |
42 | if (cameraPermission === RESULTS.GRANTED) {
43 | navigation.navigate('QRAuthorize');
44 | } else if (cameraPermission === RESULTS.DENIED) {
45 | let userResponse;
46 | if (Platform.OS === 'ios') {
47 | userResponse = await RNPermissions.request(PERMISSIONS.IOS.CAMERA);
48 | } else {
49 | userResponse = await RNPermissions.request(
50 | PERMISSIONS.ANDROID.CAMERA,
51 | );
52 | }
53 | if (userResponse === RESULTS.GRANTED) {
54 | navigation.navigate('QRAuthorize');
55 | }
56 | } else if (cameraPermission === RESULTS.UNAVAILABLE) {
57 | let userResponse;
58 | if (Platform.OS === 'ios') {
59 | userResponse = await RNPermissions.request(
60 | PERMISSIONS.IOS.MICROPHONE,
61 | );
62 | } else {
63 | userResponse = await RNPermissions.request(
64 | PERMISSIONS.ANDROID.CAMERA,
65 | );
66 | }
67 | if (userResponse === RESULTS.GRANTED) {
68 | navigation.navigate('QRAuthorize');
69 | }
70 | } else if (cameraPermission === RESULTS.BLOCKED) {
71 | let userResponse;
72 | if (Platform.OS === 'ios') {
73 | userResponse = await openSettings();
74 | } else {
75 | userResponse = await RNPermissions.request(
76 | PERMISSIONS.ANDROID.CAMERA,
77 | );
78 | }
79 | if (userResponse === RESULTS.GRANTED) {
80 | navigation.navigate('QRAuthorize');
81 | }
82 | } else {
83 | Alert.alert('Please enable camera permission in settings.');
84 | }
85 | } catch (ex: any) {
86 | Alert.alert('Permission Error', ex.message);
87 | }
88 | };
89 |
90 | return (
91 |
92 |
93 |
94 |
95 |
96 | Authorize Reader SDK.
97 |
98 | Generate an authorization code
99 | {'\n'}
100 | in the Reader SDK tab
101 | {'\n'}
102 | of the Developer Portal.
103 |
104 |
105 |
106 | goToQRAuthorize()}
109 | primary
110 | />
111 | navigation.navigate('ManualAuthorize')}
114 | />
115 |
116 |
117 | );
118 | }
119 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/screens/DeauthorizingScreen.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | import React, {useEffect} from 'react';
17 | import {Alert} from 'react-native';
18 | import {
19 | deauthorizeAsync,
20 | canDeauthorizeAsync,
21 | } from 'react-native-square-reader-sdk';
22 | import ProgressView from '../components/ProgressView';
23 |
24 | export default function DeauthorizingScreen({navigation}) {
25 | // USEEFFECT ACTION
26 | useEffect(() => {
27 | window.setTimeout(async () => {
28 | if (await canDeauthorizeAsync()) {
29 | try {
30 | await deauthorizeAsync();
31 | navigation.navigate('Authorize');
32 | } catch (ex: any) {
33 | let errorMessage = ex.message;
34 | if (__DEV__) {
35 | errorMessage += `\n\nDebug Message: ${ex.debugMessage}`;
36 | console.log(`${ex.code}:${ex.debugCode}:${ex.debugMessage}`);
37 | }
38 | Alert.alert('Error', errorMessage);
39 | }
40 | } else {
41 | Alert.alert(
42 | 'Unable to deauthorize',
43 | 'You cannot deauthorize right now.',
44 | );
45 | navigation.goBack();
46 | }
47 | }, 1000);
48 | });
49 |
50 | return ;
51 | }
52 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/screens/ManualAuthorizeScreen.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | import React, {useState} from 'react';
17 | import {StyleSheet, View, TextInput, Text} from 'react-native';
18 | import CustomButton from '../components/CustomButton';
19 | import {defaultStyles} from '../styles/common';
20 |
21 | export function ManualAuthorizeScreen({navigation}) {
22 | const [authCode, setAuthCode] = useState('');
23 |
24 | // ONLOGIN CLICK
25 | const onLogin = async () => {
26 | navigation.navigate('Authorizing', {authCode: authCode});
27 | };
28 |
29 | const {goBack} = navigation;
30 | return (
31 |
32 |
33 | Enter an authorization code.
34 |
35 |
36 | setAuthCode(value)}
39 | value={authCode}
40 | autoFocus
41 | placeholder="Authorization code"
42 | placeholderTextColor="rgba(255, 255, 255, 0.85)"
43 | selectionColor="white"
44 | underlineColorAndroid="transparent"
45 | />
46 | onLogin()}
49 | primary
50 | disabled={!authCode}
51 | />
52 | goBack()} />
53 |
54 |
55 | );
56 | }
57 |
58 | const styles = StyleSheet.create({
59 | buttonContainer: {
60 | flex: 1,
61 | },
62 | textContainer: {
63 | alignItems: 'center',
64 | height: '20%',
65 | justifyContent: 'center',
66 | },
67 | textInput: {
68 | backgroundColor: '#53A6FF',
69 | borderRadius: 8,
70 | color: 'white',
71 | fontSize: 20,
72 | padding: 15,
73 | },
74 | titleLabel: {
75 | color: 'white',
76 | fontSize: 24,
77 | fontWeight: 'bold',
78 | },
79 | });
80 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/screens/QRAuthorizationScreen.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | import React, {useState} from 'react';
17 | import {CameraScreen} from 'react-native-camera-kit';
18 | import {backgroundColor} from '../styles/common';
19 |
20 | export function QRAuthorizationScreen({navigation}) {
21 | const [receivedCode, setReceivedCode] = useState(false);
22 |
23 | // ONSUCCES OF QRSCANNER
24 | const onSuccess = async (e: any) => {
25 | if (receivedCode) {
26 | return;
27 | }
28 | setReceivedCode(true);
29 | navigation.navigate('Authorizing', {
30 | authCode: e.nativeEvent.codeStringValue,
31 | });
32 | };
33 |
34 | return (
35 | navigation.goBack()}
38 | showFrame
39 | colorForScannerFrame={backgroundColor}
40 | scanBarcode
41 | onReadCode={e => onSuccess(e)}
42 | hideControls={false}
43 | heightForScannerFrame={300}
44 | cameraOptions={{
45 | flashMode: 'auto',
46 | focusMode: 'on',
47 | zoomMode: 'off',
48 | }}
49 | />
50 | );
51 | }
52 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/screens/SettingScreen.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | import React from 'react';
17 | import {View, Text, Alert} from 'react-native';
18 | import {
19 | startReaderSettingsAsync,
20 | ReaderSettingsErrorSdkNotAuthorized,
21 | UsageError,
22 | } from 'react-native-square-reader-sdk';
23 | import CustomButton from '../components/CustomButton';
24 | import {defaultStyles} from '../styles/common';
25 |
26 | export function SettingScreen({navigation, route}) {
27 | const {goBack} = navigation;
28 | const locationName = route.params.locationName;
29 |
30 | // ONSTART READER SETTING
31 | const onStartReaderSettings = async () => {
32 | const {navigate} = navigation.navigate;
33 | try {
34 | await startReaderSettingsAsync();
35 | } catch (ex: any) {
36 | let errorMessage = ex.message;
37 | switch (ex.code) {
38 | case ReaderSettingsErrorSdkNotAuthorized:
39 | // Handle reader settings not authorized
40 | navigate('Deauthorizing');
41 | break;
42 | case UsageError:
43 | default:
44 | if (__DEV__) {
45 | errorMessage += `\n\nDebug Message: ${ex.debugMessage}`;
46 | console.log(`${ex.code}:${ex.debugCode}:${ex.debugMessage}`);
47 | }
48 | Alert.alert('Error', errorMessage);
49 | break;
50 | }
51 | }
52 | };
53 |
54 | const showConfirmDialog = () => {
55 | return Alert.alert('Alert', 'Are you sure you want to Deauthorize Token?', [
56 | // The "Yes" button
57 | {
58 | text: 'Yes',
59 | onPress: () => {
60 | onDeauthorize();
61 | },
62 | },
63 | // The "No" button
64 | // Does nothing but dismiss the dialog when tapped
65 | {
66 | text: 'No',
67 | },
68 | ]);
69 | };
70 |
71 | // NAVIGATION TO DEAUTHORIZING SCREEN
72 | const onDeauthorize = async () => {
73 | navigation.navigate('Deauthorizing');
74 | };
75 |
76 | return (
77 |
78 |
79 |
80 | Location:
81 | {locationName}
82 |
83 |
84 |
85 | onStartReaderSettings()}
88 | primary
89 | />
90 | showConfirmDialog()} />
91 | goBack()} />
92 |
93 |
94 | );
95 | }
96 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/screens/SplashScreen.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | import React, {useState, useEffect} from 'react';
17 | import {
18 | StyleSheet,
19 | View,
20 | Platform,
21 | Alert,
22 | Animated,
23 | Easing,
24 | Dimensions,
25 | } from 'react-native';
26 | import Permissions, {PERMISSIONS, RESULTS} from 'react-native-permissions';
27 | import {isAuthorizedAsync} from 'react-native-square-reader-sdk';
28 | import SquareLogo from '../components/SquareLogo';
29 | import {backgroundColor} from '../styles/common';
30 |
31 | export default function SplashScreen({navigation}) {
32 | const [logoTranslateY] = useState(new Animated.Value(0));
33 |
34 | // USEFFECT METHOD
35 | useEffect(() => {
36 | Animated.timing(logoTranslateY, {
37 | toValue: -(Dimensions.get('window').height / 2 - 120), // Calculate the position of icon after tanslate
38 | easing: Easing.bezier(0.25, 0.1, 0.25, 1),
39 | duration: 1500,
40 | useNativeDriver: true,
41 | }).start();
42 |
43 | window.setTimeout(async () => {
44 | try {
45 | const permissions = await Permissions.checkMultiple([
46 | PERMISSIONS.IOS.MICROPHONE,
47 | PERMISSIONS.IOS.LOCATION_WHEN_IN_USE,
48 | ]);
49 | if (
50 | Platform.OS === 'ios' && // Android doesn't need to handle permission explicitly
51 | (permissions['ios.permission.MICROPHONE'] !== RESULTS.GRANTED ||
52 | permissions['ios.permission.LOCATION_WHEN_IN_USE'] !==
53 | RESULTS.GRANTED)
54 | ) {
55 | navigation.navigate('PermissionSettings');
56 | return;
57 | }
58 | const isAuthorized = await isAuthorizedAsync();
59 | if (!isAuthorized) {
60 | navigation.navigate('Auth');
61 | return;
62 | }
63 | // Permission has been granted (for iOS only) and readerSDK has been authorized
64 | navigation.navigate('Checkout');
65 | } catch (ex: any) {
66 | Alert.alert('Navigation Error', ex.message);
67 | }
68 | }, 1600);
69 | });
70 |
71 | return (
72 |
73 |
74 |
75 | );
76 | }
77 |
78 | const styles = StyleSheet.create({
79 | container: {
80 | alignItems: 'center',
81 | backgroundColor,
82 | flex: 1,
83 | justifyContent: 'center',
84 | },
85 | });
86 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/app/styles/common.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import { StyleSheet } from 'react-native';
18 |
19 | export const backgroundColor = '#4087E1';
20 |
21 | export const defaultStyles = StyleSheet.create({
22 | buttonContainer: {
23 | justifyContent: 'flex-end',
24 | },
25 | descriptionContainer: {
26 | alignItems: 'center',
27 | flex: 1,
28 | justifyContent: 'flex-start',
29 | },
30 | logo: {
31 | height: 48,
32 | width: 48,
33 | },
34 | logoContainer: {
35 | alignItems: 'center',
36 | flex: 1,
37 | justifyContent: 'flex-start',
38 | paddingTop: 64,
39 | },
40 | pageContainer: {
41 | backgroundColor,
42 | flex: 1,
43 | justifyContent: 'flex-end',
44 | padding: 20,
45 | },
46 | subtitle: {
47 | color: 'rgba(255, 255, 255, 0.85)',
48 | fontSize: 18,
49 | textAlign: 'center',
50 | },
51 | title: {
52 | color: 'white',
53 | fontSize: 24,
54 | fontWeight: 'bold',
55 | },
56 | logoStyle: {
57 | width: 100, height: 100
58 | },
59 | settingIconStyle: {
60 | width: 24, height: 24, alignSelf: 'flex-end', tintColor: 'white'
61 | }
62 | });
63 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:@react-native/babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import {AppRegistry} from 'react-native';
18 | import App from './App';
19 | import {name as appName} from './app.json';
20 |
21 | AppRegistry.registerComponent(appName, () => App);
22 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // RNReaderSDKSample
4 |
5 | import Foundation
6 | import SquareReaderSDK
7 |
8 | @UIApplicationMain
9 | class AppDelegate: UIResponder, UIApplicationDelegate {
10 | var window: UIWindow?
11 | var bridge: RCTBridge!
12 |
13 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
14 | let jsCodeLocation: URL
15 |
16 | jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource:nil)
17 | let rootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "RNReaderSDKSample", initialProperties: nil, launchOptions: launchOptions)
18 | let rootViewController = UIViewController()
19 | rootViewController.view = rootView
20 |
21 | self.window = UIWindow(frame: UIScreen.main.bounds)
22 | self.window?.rootViewController = rootViewController
23 | self.window?.makeKeyAndVisible()
24 | SQRDReaderSDK.initialize(applicationLaunchOptions: launchOptions)
25 |
26 | return true
27 | }
28 | }
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/File.swift:
--------------------------------------------------------------------------------
1 |
2 | import Foundation
3 | import SquareReaderSDK
4 |
5 | @UIApplicationMain
6 | class AppDelegate: UIResponder, UIApplicationDelegate {
7 | var window: UIWindow?
8 | var bridge: RCTBridge!
9 |
10 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
11 | let jsCodeLocation: URL
12 |
13 | jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackExtension:nil)!
14 | let rootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "RNReaderSDKSample", initialProperties: nil, launchOptions: launchOptions)
15 | let rootViewController = UIViewController()
16 | rootViewController.view = rootView
17 |
18 | self.window = UIWindow(frame: UIScreen.main.bounds)
19 | self.window?.rootViewController = rootViewController
20 | self.window?.makeKeyAndVisible()
21 | SQRDReaderSDK.initialize(applicationLaunchOptions: launchOptions)
22 |
23 | return true
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/Podfile:
--------------------------------------------------------------------------------
1 | require_relative '../node_modules/react-native/scripts/react_native_pods'
2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
3 |
4 | platform :ios, '14.2'
5 |
6 | target 'RNReaderSDKSample' do
7 | # Pods for RNReaderSDKSample
8 | config = use_native_modules!
9 | use_react_native!(
10 | :path => config[:reactNativePath],
11 | # to enable hermes on iOS, change `false` to `true` and then install pods
12 | :hermes_enabled => false
13 | )
14 |
15 | permissions_path = '../node_modules/react-native-permissions/ios'
16 | pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
17 | pod 'Permission-LocationAccuracy', :path => "#{permissions_path}/LocationAccuracy"
18 | pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways"
19 | pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
20 | pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"
21 |
22 | # Enables Flipper.
23 | #
24 | # Note that if you have use_frameworks! enabled, Flipper will not work and
25 | # you should disable the next line.
26 | # use_flipper!()
27 |
28 |
29 | # pod 'RNReaderSDK', :path => '../node_modules/react-native-square-reader-sdk'
30 |
31 | # use_flipper!({
32 | # "Flipper" => "0.99.0",
33 | # 'Flipper-Folly' => '2.6'
34 | # })
35 | post_install do |installer|
36 | # flipper_post_install(installer)
37 | react_native_post_install(installer)
38 |
39 | # Apple Silicon builds require a library path tweak for Swift library discovery or "symbol not found" for swift things
40 | installer.aggregate_targets.each do |aggregate_target|
41 | aggregate_target.user_project.native_targets.each do |target|
42 | target.build_configurations.each do |config|
43 | config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
44 | config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
45 | config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.2'
46 | config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ''
47 | config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
48 | config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO'
49 | end
50 | end
51 | aggregate_target.user_project.save
52 | end
53 | # Flipper requires a crude patch to bump up iOS deployment target, or "error: thread-local storage is not supported for the current target"
54 | # I'm not aware of any other way to fix this one other than bumping iOS deployment target to match react-native (iOS 11 now)
55 | installer.pods_project.targets.each do |target|
56 | target.build_configurations.each do |config|
57 | config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
58 | # config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "i386"
59 | config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.2'
60 | config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ''
61 | config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
62 | config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO'
63 | end
64 | end
65 | # ...but if you bump iOS deployment target, Flipper barfs again "Time.h:52:17: error: typedef redefinition with different types"
66 | # We need to make one crude patch to RCT-Folly - set `__IPHONE_10_0` to our iOS target + 1
67 | # https://github.com/facebook/flipper/issues/834 - 84 comments and still going...
68 | # __apply_Xcode_12_5_M1_post_install_workaround(installer)
69 | `sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
70 | end
71 | end
72 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 | #import
6 | #import
7 | #import
8 | #import
9 | #import
10 | #import
11 | #import
12 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample.xcodeproj/xcshareddata/xcschemes/RNReaderSDKSample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "Icon-20@2x-1.png",
5 | "idiom" : "iphone",
6 | "scale" : "2x",
7 | "size" : "20x20"
8 | },
9 | {
10 | "filename" : "Icon-20@3x-1.png",
11 | "idiom" : "iphone",
12 | "scale" : "3x",
13 | "size" : "20x20"
14 | },
15 | {
16 | "filename" : "Icon-29@2x-1.png",
17 | "idiom" : "iphone",
18 | "scale" : "2x",
19 | "size" : "29x29"
20 | },
21 | {
22 | "filename" : "Icon-29@3x-1.png",
23 | "idiom" : "iphone",
24 | "scale" : "3x",
25 | "size" : "29x29"
26 | },
27 | {
28 | "filename" : "Icon-40@2x-1.png",
29 | "idiom" : "iphone",
30 | "scale" : "2x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "filename" : "Icon-40@3x-1.png",
35 | "idiom" : "iphone",
36 | "scale" : "3x",
37 | "size" : "40x40"
38 | },
39 | {
40 | "filename" : "Icon-60@2x-1.png",
41 | "idiom" : "iphone",
42 | "scale" : "2x",
43 | "size" : "60x60"
44 | },
45 | {
46 | "filename" : "Icon-60@3x-1.png",
47 | "idiom" : "iphone",
48 | "scale" : "3x",
49 | "size" : "60x60"
50 | },
51 | {
52 | "filename" : "iTunesArtwork@2x-1.png",
53 | "idiom" : "ios-marketing",
54 | "scale" : "1x",
55 | "size" : "1024x1024"
56 | }
57 | ],
58 | "info" : {
59 | "author" : "xcode",
60 | "version" : 1
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-20@2x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-20@2x-1.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-20@2x.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-20@3x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-20@3x-1.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-20@3x.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-29@2x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-29@2x-1.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-29@2x.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-29@3x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-29@3x-1.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-29@3x.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-40@2x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-40@2x-1.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-40@3x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-40@3x-1.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-60@2x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-60@2x-1.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-60@3x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-60@3x-1.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/iTunesArtwork@2x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/iTunesArtwork@2x-1.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/Logo.imageset/Logo.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Images.xcassets/Logo.imageset/Logo.pdf
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | RNReaderSDKSample
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSRequiresIPhoneOS
26 |
27 | NSAppTransportSecurity
28 |
29 | NSExceptionDomains
30 |
31 | localhost
32 |
33 | NSExceptionAllowsInsecureHTTPLoads
34 |
35 |
36 |
37 |
38 | NSBluetoothAlwaysUsageDescription
39 | This application integrates with Square for card processing. Square uses Bluetooth to connect your device to compatible hardware.
40 | NSBluetoothPeripheralUsageDescription
41 | This app integrates with Square for card processing. Square uses Bluetooth to connect your device to compatible hardware.
42 |
43 | NSCameraUsageDescription
44 | This app integrates with Square for card processing. Upload your account logo, feature photo and product images with the photos stored on your mobile device.
45 |
46 | NSLocationWhenInUseUsageDescription
47 | This app integrates with Square for card processing. To protect buyers and sellers, Square requires your location to process payments.
48 | NSMainNibFile
49 | LaunchScreen
50 | NSMicrophoneUsageDescription
51 | This app integrates with Square for card processing. To swipe magnetic cards via the headphone jack, Square requires access to the microphone.
52 | NSPhotoLibraryUsageDescription
53 | This app integrates with Square for card processing. Upload your account logo, feature photo and product images with the photos stored on your mobile device.
54 | UILaunchStoryboardName
55 | LaunchScreen
56 | UIRequiredDeviceCapabilities
57 |
58 | armv7
59 |
60 | UISupportedExternalAccessoryProtocols
61 |
62 | com.squareup.s020
63 | com.squareup.s025
64 | com.squareup.s089
65 | com.squareup.protocol.stand
66 |
67 | UISupportedInterfaceOrientations
68 |
69 | UIInterfaceOrientationPortrait
70 | UIInterfaceOrientationLandscapeLeft
71 | UIInterfaceOrientationLandscapeRight
72 |
73 | UIViewControllerBasedStatusBarAppearance
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
24 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSample/PrivacyInfo.xcprivacy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSPrivacyAccessedAPITypes
6 |
7 |
8 | NSPrivacyAccessedAPIType
9 | NSPrivacyAccessedAPICategoryFileTimestamp
10 | NSPrivacyAccessedAPITypeReasons
11 |
12 | C617.1
13 |
14 |
15 |
16 | NSPrivacyAccessedAPIType
17 | NSPrivacyAccessedAPICategoryUserDefaults
18 | NSPrivacyAccessedAPITypeReasons
19 |
20 | CA92.1
21 |
22 |
23 |
24 | NSPrivacyAccessedAPIType
25 | NSPrivacyAccessedAPICategorySystemBootTime
26 | NSPrivacyAccessedAPITypeReasons
27 |
28 | 35F9.1
29 |
30 |
31 |
32 | NSPrivacyCollectedDataTypes
33 |
34 | NSPrivacyTracking
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/RNReaderSDKSampleTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/ios/temp_file:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/ios/temp_file
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/metro.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Metro configuration for React Native
3 | * https://github.com/facebook/react-native
4 | *
5 | * @format
6 | */
7 |
8 | // module.exports = {
9 | // transformer: {
10 | // getTransformOptions: async () => ({
11 | // transform: {
12 | // experimentalImportSupport: false,
13 | // inlineRequires: true,
14 | // },
15 | // }),
16 | // },
17 | // };
18 |
19 | // const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
20 |
21 | // const defaultConfig = getDefaultConfig(__dirname);
22 |
23 | // const {
24 | // resolver: { sourceExts, assetExts },
25 | // } = getDefaultConfig(__dirname);
26 |
27 | // const config = {
28 | // transformer: {
29 | // getTransformOptions: async () => ({
30 | // transform: {
31 | // experimentalImportSupport: false,
32 | // inlineRequires: true,
33 | // },
34 | // }),
35 | // // babelTransformerPath: require.resolve('react-native-svg-transformer'),
36 | // },
37 | // resolver: {
38 | // assetExts: assetExts.filter(ext => ext !== 'svg'),
39 | // sourceExts: [...sourceExts, 'svg'],
40 | // },
41 | // overrides: [
42 | // {
43 | // test: './node_modules/ethers',
44 | // plugins: [
45 | // '@babel/plugin-proposal-private-property-in-object',
46 | // '@babel/plugin-proposal-class-properties',
47 | // '@babel/plugin-proposal-private-methods'
48 | // ]
49 | // }
50 | // ]
51 | // };
52 |
53 | // module.exports = mergeConfig(defaultConfig, config);
54 |
55 | // module.exports = {
56 | // transformer: {
57 | // getTransformOptions: async () => ({
58 | // transform: {
59 | // experimentalImportSupport: false,
60 | // inlineRequires: true,
61 | // },
62 | // }),
63 | // },
64 | // plugins: ['react-native-reanimated/plugin'],
65 | // presets: ['module:metro-react-native-babel-preset'],
66 | // overrides: [
67 | // {
68 | // test: './node_modules/ethers',
69 | // plugins: [
70 | // '@babel/plugin-proposal-private-property-in-object',
71 | // '@babel/plugin-proposal-class-properties',
72 | // '@babel/plugin-proposal-private-methods'
73 | // ]
74 | // }
75 | // ]
76 | // };
77 |
78 | // const { getDefaultConfig } = require("metro-config")
79 |
80 | // metroConfig = (async () => {
81 | // const {
82 | // resolver: { sourceExts, assetExts },
83 | // } = await getDefaultConfig()
84 | // return {
85 | // transformer: {
86 | // babelTransformerPath: require.resolve("react-native-svg-transformer"),
87 | // getTransformOptions: async () => ({
88 | // transform: {
89 | // experimentalImportSupport: false,
90 | // inlineRequires: false,
91 | // },
92 | // }),
93 | // },
94 | // resolver: {
95 | // assetExts: assetExts.filter((ext) => ext !== "svg"),
96 | // sourceExts: [...sourceExts, "svg"],
97 | // },
98 | // }
99 | // })()
100 |
101 | const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
102 |
103 | const defaultConfig = getDefaultConfig(__dirname);
104 |
105 | const {
106 | resolver: { sourceExts, assetExts },
107 | } = getDefaultConfig(__dirname);
108 |
109 | const config = {
110 | transformer: {
111 | getTransformOptions: async () => ({
112 | transform: {
113 | experimentalImportSupport: false,
114 | inlineRequires: true,
115 | },
116 | }),
117 | babelTransformerPath: require.resolve('react-native-svg-transformer'),
118 | },
119 | resolver: {
120 | assetExts: assetExts.filter(ext => ext !== 'svg'),
121 | sourceExts: [...sourceExts, 'svg'],
122 | },
123 | presets: ['module:@react-native/babel-preset'],
124 | // plugins: ['react-native-paper/babel', '@babel/plugin-transform-private-methods', '@babel/plugin-proposal-class-properties'],
125 |
126 |
127 | // presets: ['module:metro-react-native-babel-preset'],
128 | // overrides: [{
129 | // "plugins": [
130 | // ["@babel/plugin-transform-private-methods", {
131 | // "loose": true
132 | // }]
133 | // ]
134 | // }]
135 | };
136 |
137 | module.exports = mergeConfig(defaultConfig, config);
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "reader-sdk-react-native-quickstart",
3 | "version": "2.0.0",
4 | "private": true,
5 | "scripts": {
6 | "android": "react-native run-android",
7 | "ios": "react-native run-ios",
8 | "start": "react-native start",
9 | "test": "jest",
10 | "jetify": "npx jetify",
11 | "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
12 | },
13 | "dependencies": {
14 | "@react-native-community/cli-platform-android": "^10.2.0",
15 | "@react-navigation/native": "^6.1.7",
16 | "@react-navigation/native-stack": "^6.5.0",
17 | "@react-navigation/stack": "^6.1.1",
18 | "patch-package": "^8.0.0",
19 | "postinstall-postinstall": "^2.1.0",
20 | "react": "^18.2.0",
21 | "react-native": "^0.74.3",
22 | "react-native-camera-kit": "https://github.com/coreyphillips/react-native-camera-kit#v13-patch",
23 | "react-native-gesture-handler": "^2.12.1",
24 | "react-native-globalize": "^4.5.1",
25 | "react-native-permissions": "^3.6.1",
26 | "react-native-safe-area-context": "^3.4.1",
27 | "react-native-square-reader-sdk": "^1.4.3",
28 | "react-native-svg-transformer": "^1.5.0"
29 | },
30 | "devDependencies": {
31 | "@babel/core": "^7.24.9",
32 | "@babel/plugin-transform-private-methods": "^7.24.7",
33 | "@babel/runtime": "^7.12.5",
34 | "@react-native-community/eslint-config": "^2.0.0",
35 | "@react-native/metro-config": "^0.74.85",
36 | "@types/jest": "^26.0.23",
37 | "@types/react-native": "^0.66.15",
38 | "@types/react-test-renderer": "^17.0.1",
39 | "@typescript-eslint/eslint-plugin": "^5.7.0",
40 | "@typescript-eslint/parser": "^5.7.0",
41 | "babel-jest": "^29.7.0",
42 | "eslint": "^7.14.0",
43 | "jest": "^29.7.0",
44 | "jetifier": "^2.0.0",
45 | "metro-config": "^0.80.9",
46 | "metro-react-native-babel-preset": "^0.66.2",
47 | "react-test-renderer": "17.0.2",
48 | "typescript": "^4.4.4"
49 | },
50 | "resolutions": {
51 | "@types/react": "^17",
52 | "react-native-gesture-handler": "^2.12.1"
53 | },
54 | "jest": {
55 | "preset": "react-native",
56 | "moduleFileExtensions": [
57 | "ts",
58 | "tsx",
59 | "js",
60 | "jsx",
61 | "json",
62 | "node"
63 | ]
64 | },
65 | "nohoist": [
66 | "**/*/**"
67 | ]
68 | }
69 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/patches/react-native+0.67.2.patch:
--------------------------------------------------------------------------------
1 | diff --git a/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp b/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp
2 | index 2c68674..ea95e40 100644
3 | --- a/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp
4 | +++ b/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp
5 | @@ -2229,7 +2229,7 @@ static float YGDistributeFreeSpaceSecondPass(
6 | depth,
7 | generationCount);
8 | node->setLayoutHadOverflow(
9 | - node->getLayout().hadOverflow() |
10 | + node->getLayout().hadOverflow() ||
11 | currentRelativeChild->getLayout().hadOverflow());
12 | }
13 | return deltaFreeSpace;
14 |
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/sampleapp-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/square/react-native-square-reader-sdk/53e7a0ef59c264e0659e22d20d83063aeda91624/reader-sdk-react-native-quickstart/sampleapp-example.png
--------------------------------------------------------------------------------
/reader-sdk-react-native-quickstart/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": true,
4 | "allowSyntheticDefaultImports": true,
5 | "esModuleInterop": true,
6 | "isolatedModules": true,
7 | "jsx": "react",
8 | "lib": ["ES2019","dom"],
9 | "module": "commonjs",
10 | "target": "ES2019",
11 | "moduleResolution": "node",
12 | "noEmit": true,
13 | "strict": true,
14 | "skipLibCheck": true,
15 | "types": ["jest","node"],
16 | "noImplicitAny": false,
17 | "strictNullChecks": false
18 | },
19 | "include": ["app/**/*"],
20 | "exclude": [
21 | "node_modules",
22 | "babel.config.js",
23 | "metro.config.js",
24 | "jest.config.js"
25 | ]
26 | }
--------------------------------------------------------------------------------
/src/utils.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Square Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | function hasNonNullProperty(obj, property) {
18 | if (Object.prototype.hasOwnProperty.call(obj, property) && typeof obj[property] !== 'undefined' && obj[property] !== null) {
19 | return true;
20 | }
21 | return false;
22 | }
23 |
24 | export default function ValidateCheckoutParameters(checkoutParams) {
25 | const paramError = {};
26 | paramError.debugCode = 'rn_checkout_invalid_parameter';
27 | paramError.message = 'Something went wrong. Please contact the developer of this application and provide them with this error code: rn_checkout_invalid_parameter';
28 | paramError.debugMessage = 'Invalid parameter found in checkout parameters. ';
29 | if (!checkoutParams) {
30 | paramError.debugMessage += "'checkoutParams' is undefined or null";
31 | throw new Error(JSON.stringify(paramError));
32 | }
33 | if (!hasNonNullProperty(checkoutParams, 'amountMoney') || typeof checkoutParams.amountMoney !== 'object') {
34 | paramError.debugMessage += "'amountMoney' is missing or not an object";
35 | throw new Error(JSON.stringify(paramError));
36 | } else if (hasNonNullProperty(checkoutParams, 'skipReceipt') && typeof checkoutParams.skipReceipt !== 'boolean') {
37 | paramError.debugMessage += "'skipReceipt' is not a boolean";
38 | throw new Error(JSON.stringify(paramError));
39 | } else if (hasNonNullProperty(checkoutParams, 'collectSignature') && typeof checkoutParams.collectSignature !== 'boolean') {
40 | paramError.debugMessage += "'collectSignature' is not a boolean";
41 | throw new Error(JSON.stringify(paramError));
42 | } else if (hasNonNullProperty(checkoutParams, 'allowSplitTender') && typeof checkoutParams.allowSplitTender !== 'boolean') {
43 | paramError.debugMessage += "'allowSplitTender' is not a boolean";
44 | throw new Error(JSON.stringify(paramError));
45 | } else if (hasNonNullProperty(checkoutParams, 'delayCapture') && typeof checkoutParams.delayCapture !== 'boolean') {
46 | paramError.debugMessage += "'delayCapture' is not a boolean";
47 | throw new Error(JSON.stringify(paramError));
48 | } else if (hasNonNullProperty(checkoutParams, 'note') && typeof checkoutParams.note !== 'string') {
49 | paramError.debugMessage += "'note' is not a string";
50 | throw new Error(JSON.stringify(paramError));
51 | } else if (hasNonNullProperty(checkoutParams, 'tipSettings') && typeof checkoutParams.tipSettings !== 'object') {
52 | paramError.debugMessage += "'tipSettings' is not an object";
53 | throw new Error(JSON.stringify(paramError));
54 | } else if (hasNonNullProperty(checkoutParams, 'additionalPaymentTypes') && !Array.isArray(checkoutParams.additionalPaymentTypes)) {
55 | paramError.debugMessage += "'additionalPaymentTypes' is not an array";
56 | throw new Error(JSON.stringify(paramError));
57 | }
58 |
59 | // check amountMoney
60 | const { amountMoney } = checkoutParams;
61 | if (!hasNonNullProperty(amountMoney, 'amount') || typeof amountMoney.amount !== 'number') {
62 | paramError.debugMessage += "'amount' is not an integer";
63 | throw new Error(JSON.stringify(paramError));
64 | }
65 | if (hasNonNullProperty(amountMoney, 'currencyCode') && typeof amountMoney.currencyCode !== 'string') {
66 | paramError.debugMessage += "'currencyCode' is not a String";
67 | throw new Error(JSON.stringify(paramError));
68 | }
69 |
70 | if (hasNonNullProperty(checkoutParams, 'tipSettings')) {
71 | // check tipSettings
72 | const { tipSettings } = checkoutParams;
73 | if (hasNonNullProperty(tipSettings, 'showCustomTipField') && typeof tipSettings.showCustomTipField !== 'boolean') {
74 | paramError.debugMessage += "'showCustomTipField' is not a boolean";
75 | throw new Error(JSON.stringify(paramError));
76 | } else if (hasNonNullProperty(tipSettings, 'showSeparateTipScreen') && typeof tipSettings.showSeparateTipScreen !== 'boolean') {
77 | paramError.debugMessage += "'showSeparateTipScreen' is not a boolean";
78 | throw new Error(JSON.stringify(paramError));
79 | } else if (hasNonNullProperty(tipSettings, 'tipPercentages') && !Array.isArray(tipSettings.tipPercentages)) {
80 | paramError.debugMessage += "'tipPercentages' is not an array";
81 | throw new Error(JSON.stringify(paramError));
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------