Skip to content

Commit

Permalink
Merge pull request #310 from capacitor-community/feat/5.3.0
Browse files Browse the repository at this point in the history
feat(to 5.3.0): update packages, and support usb/bluetooth connection to terminal
  • Loading branch information
rdlabo authored Oct 14, 2023
2 parents a86425c + 3671de9 commit 9373ef1
Show file tree
Hide file tree
Showing 57 changed files with 1,403 additions and 1,539 deletions.
6 changes: 4 additions & 2 deletions demo/angular/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@

<!-- Permissions -->

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package io.ionic.starter;

import android.os.Build;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.community.stripe.StripePlugin;
import com.getcapacitor.community.stripe.identity.StripeIdentityPlugin;
import com.getcapacitor.community.stripe.terminal.StripeTerminalPlugin;

public class MainActivity extends BridgeActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerPlugin(com.getcapacitor.community.stripe.StripePlugin.class);
registerPlugin(com.getcapacitor.community.stripe.identity.StripeIdentityPlugin.class);
registerPlugin(com.getcapacitor.community.stripe.terminal.StripeTerminalPlugin.class);
registerPlugin(StripePlugin.class);
registerPlugin(StripeIdentityPlugin.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
registerPlugin(StripeTerminalPlugin.class);
}
}
}
6 changes: 3 additions & 3 deletions demo/angular/android/variables.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext {
minSdkVersion = 22
compileSdkVersion = 33
minSdkVersion = 26
compileSdkVersion = 34
targetSdkVersion = 33
androidxActivityVersion = '1.7.0'
androidxAppCompatVersion = '1.6.1'
Expand All @@ -13,4 +13,4 @@ ext {
androidxJunitVersion = '1.1.5'
androidxEspressoCoreVersion = '3.5.1'
cordovaAndroidVersion = '10.1.1'
}
}
8 changes: 3 additions & 5 deletions demo/angular/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@capacitor/core": "5.0.0",
"@capacitor/ios": "5.0.0",
"@ionic/angular": "^7.3.0",
"stripe-pwa-elements": "^2.1.0",
"rxjs": "~7.5.0",
"stripe-pwa-elements": "^2.1.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.1"
},
Expand Down
12 changes: 9 additions & 3 deletions demo/angular/src/app/terminal/terminal.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@
<ion-content>
<ion-list>
<ion-list-header><ion-label>PROCESS</ion-label></ion-list-header>
<ion-item (click)="create('happyPath', 0)" button="true" detail="true"><ion-label>Expect Happy Path - Tap To Pay</ion-label></ion-item>
<ion-item (click)="create('happyPath', 1)" button="true" detail="true"><ion-label>Expect Happy Path - Internet</ion-label></ion-item>
<ion-item (click)="create('cancelPath', 1)" button="true" detail="true"><ion-label>Expect Cancel Path - Internet</ion-label></ion-item>
<ion-item-divider><ion-label>Happy Path</ion-label></ion-item-divider>
<ion-item (click)="create('happyPath', terminalConnectTypes.TapToPay)" button="true" detail="true"><ion-label>Expect Happy Path - Tap To Pay</ion-label></ion-item>
<ion-item (click)="create('happyPath', terminalConnectTypes.Internet)" button="true" detail="true"><ion-label>Expect Happy Path - Internet</ion-label></ion-item>
<ion-item (click)="create('happyPath', terminalConnectTypes.Bluetooth)" button="true" detail="true"><ion-label>Expect Happy Path - Bluetooth</ion-label></ion-item>
<ion-item (click)="create('happyPath', terminalConnectTypes.Usb)" button="true" detail="true" *ngIf="platform.is('android')"><ion-label>Expect Happy Path - Usb</ion-label></ion-item>
<ion-item-divider><ion-label>Cancel Path</ion-label></ion-item-divider>
<ion-item (click)="create('cancelPath', terminalConnectTypes.Internet)" button="true" detail="true"><ion-label>Expect Cancel Path - Internet</ion-label></ion-item>
<ion-item (click)="create('cancelPath', terminalConnectTypes.Bluetooth)" button="true" detail="true"><ion-label>Expect Cancel Path - Bluetooth</ion-label></ion-item>
<ion-item (click)="create('cancelPath', terminalConnectTypes.Usb)" button="true" detail="true" *ngIf="platform.is('android')"><ion-label>Expect Cancel Path - Usb</ion-label></ion-item>
<ion-item (click)="checkDiscoverMethod()" button="true" detail="true"><ion-label>checkDiscoverMethod</ion-label></ion-item>
</ion-list>

Expand Down
28 changes: 15 additions & 13 deletions demo/angular/src/app/terminal/terminal.page.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { HttpClient } from '@angular/common/http';
import { HelperService } from '../shared/helper.service';
import { StripeTerminal, TerminalConnectTypes, TerminalEventsEnum } from '@capacitor-community/stripe-terminal';
import { environment } from '../../environments/environment';
import { firstValueFrom } from 'rxjs';
import {Component} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {IonicModule, Platform} from '@ionic/angular';
import {HttpClient} from '@angular/common/http';
import {HelperService} from '../shared/helper.service';
import {StripeTerminal, TerminalConnectTypes, TerminalEventsEnum} from '@capacitor-community/stripe-terminal';
import {environment} from '../../environments/environment';
import {firstValueFrom} from 'rxjs';
import {ITestItems} from '../shared/interfaces';
import {PluginListenerHandle} from '@capacitor/core';

Expand Down Expand Up @@ -141,13 +141,15 @@ const checkDiscoverMethodItems: ITestItems [] = [
})
export class TerminalPage {
public eventItems: ITestItems [] = [];
public terminalConnectTypes = TerminalConnectTypes;
private readonly listenerHandlers: PluginListenerHandle[] = [];
constructor(
public platform: Platform,
private http: HttpClient,
private helper: HelperService,
) { }

async create(type: 'happyPath' | 'cancelPath', readerType: number) {
async create(type: 'happyPath' | 'cancelPath', readerType: TerminalConnectTypes) {
const eventKeys = Object.keys(TerminalEventsEnum);
eventKeys.forEach(key => {
const handler = StripeTerminal.addListener(TerminalEventsEnum[key], () => {
Expand All @@ -162,12 +164,12 @@ export class TerminalPage {
this.eventItems = JSON.parse(JSON.stringify(cancelPathItems));
}

await StripeTerminal.initialize({ tokenProviderEndpoint: environment.api + 'connection/token', isTest: readerType === 0 })
await StripeTerminal.initialize({ tokenProviderEndpoint: environment.api + 'connection/token', isTest: readerType === TerminalConnectTypes.TapToPay })
.then(() => this.helper.updateItem(this.eventItems,'initialize', true))
.catch(() => this.helper.updateItem(this.eventItems,'initialize', false));

const result = await StripeTerminal.discoverReaders({
type: readerType === 0 ? TerminalConnectTypes.TapToPay : TerminalConnectTypes.Internet,
type: readerType,
locationId: "tml_FOUOdQVIxvVdvN",
})
.catch((e) => {
Expand Down Expand Up @@ -195,7 +197,7 @@ export class TerminalPage {
});
await this.helper.updateItem(this.eventItems,'HttpClientPaymentIntent', true);

StripeTerminal.collect({ paymentIntent })
await StripeTerminal.collect({ paymentIntent })
.then(() => this.helper.updateItem(this.eventItems,'collect', true))
.catch(async (e) => {
await this.helper.updateItem(this.eventItems,'collect', false);
Expand Down
8 changes: 4 additions & 4 deletions demo/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"@capacitor/status-bar": "5.0.0",
"@ionic/react": "^6.0.0",
"@ionic/react-router": "^6.0.0",
"stripe-pwa-elements": "^2.0.2",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^12.6.3",
Expand All @@ -29,6 +28,7 @@
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "5.0.0",
"stripe-pwa-elements": "^2.1.0",
"typescript": "^4.1.3",
"web-vitals": "^0.2.4",
"workbox-background-sync": "^5.1.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/identity/CapacitorCommunityStripeIdentity.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ Pod::Spec.new do |s|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '13.0'
s.dependency 'Capacitor'
s.dependency 'StripeIdentity', '23.4.0'
s.dependency 'StripeIdentity', '~> 23.17.1'
s.swift_version = '5.1'
end
10 changes: 8 additions & 2 deletions packages/identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ change base application theme to `Theme.MaterialComponents.DayNight` at `res/val
```

parent can be any MaterialComponents. [See here for other options](https://m2.material.io/develop/android/theming/dark/).
All process is here: https://github.com/capacitor-community/stripe/commit/f514d893e9193bed2edbaf52c0d3ed1d534c7890asU
see more details on Stripe's native Android SDK page [here](https://stripe.com/docs/identity/verify-identity-documents?platform=android&type=new-integration#set-up-material-theme).


### Initialize iOS

set up camera authorization by adding `NSCameraUsageDescription` in `Info.plist` and add a string value that explains the usage.
see more details on Stripe's native iOS SDK page [here](https://stripe.com/docs/identity/verify-identity-documents?platform=ios&type=new-integration#set-up-camera-authorization).

## Usage

Expand All @@ -32,7 +38,7 @@ await StripeIdentity.create({
ephemeralKeySecret,
verificationId,
});
const result = await Stripe.present();
const result = await StripeIdentity.present();
```

## API
Expand Down
8 changes: 6 additions & 2 deletions packages/identity/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ ext {
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'

playServicesWalletVersion = project.hasProperty('playServicesWalletVersion') ? rootProject.ext.playServicesWalletVersion : '19.2.+'
identityVersion = project.hasProperty('identityVersion') ? rootProject.ext.identityVersion : '20.32.+'
}

buildscript {
Expand Down Expand Up @@ -62,7 +65,8 @@ dependencies {
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"

implementation 'com.stripe:identity:20.28.2'
implementation 'com.google.android.gms:play-services-wallet:19.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

implementation "com.stripe:identity:$identityVersion"
implementation "com.google.android.gms:play-services-wallet:$playServicesWalletVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@

import androidx.core.util.Supplier;

import com.getcapacitor.Bridge;
import com.getcapacitor.JSObject;
import com.getcapacitor.Logger;
import com.getcapacitor.PluginCall;
import com.stripe.android.identity.IdentityVerificationSheet;


import android.app.Activity;
import android.content.Context;
import androidx.core.util.Supplier;
import com.getcapacitor.Bridge;
import com.getcapacitor.JSObject;
import com.getcapacitor.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.res.Resources;
import android.net.Uri;

import com.getcapacitor.JSObject;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import android.app.Activity;
import android.content.Context;

import androidx.core.util.Supplier;

import com.getcapacitor.JSObject;
import com.getcapacitor.Plugin;
import com.google.android.gms.common.util.BiConsumer;

public abstract class Executor {
Expand Down
8 changes: 8 additions & 0 deletions packages/identity/ios/Plugin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,19 @@
"${PODS_ROOT}/Target Support Files/Pods-PluginTests/Pods-PluginTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Capacitor/Capacitor.framework",
"${BUILT_PRODUCTS_DIR}/CapacitorCordova/Cordova.framework",
"${BUILT_PRODUCTS_DIR}/StripeCameraCore/StripeCameraCore.framework",
"${BUILT_PRODUCTS_DIR}/StripeCore/StripeCore.framework",
"${BUILT_PRODUCTS_DIR}/StripeIdentity/StripeIdentity.framework",
"${BUILT_PRODUCTS_DIR}/StripeUICore/StripeUICore.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Capacitor.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cordova.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/StripeCameraCore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/StripeCore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/StripeIdentity.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/StripeUICore.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
2 changes: 1 addition & 1 deletion packages/identity/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def capacitor_pods
use_frameworks!
pod 'Capacitor', :path => '../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../node_modules/@capacitor/ios'
pod 'StripeIdentity', '23.4.0'
pod 'StripeIdentity', '~> 23.17.1'
end

target 'Plugin' do
Expand Down
Loading

0 comments on commit 9373ef1

Please sign in to comment.