Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stripe-terminal v3, capacitor v5 and bugfixes #129

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CapacitorStripeTerminal.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '13.0'
s.dependency 'Capacitor'
s.dependency 'StripeTerminal', '2.17.1'
end
s.dependency 'StripeTerminal', '~> 3.0'
end
31 changes: 18 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
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'
}

buildscript {
Expand All @@ -11,17 +11,18 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:8.0.0'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
namespace "io.event1.capacitorstripeterminal.capacitorstripeterminal"
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 26
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -36,8 +37,8 @@ android {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

Expand All @@ -54,7 +55,11 @@ dependencies {
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation "com.stripe:stripeterminal:2.17.1"
implementation("com.squareup.moshi:moshi:1.14.0")
implementation "com.google.code.gson:gson:2.8.8"
}
implementation "com.stripe:stripeterminal-localmobile:3.2.1"
implementation "com.stripe:stripeterminal-core:3.2.1"
implementation("com.google.android.material:material") {
version {strictly "1.9.0"}
}
implementation("com.squareup.moshi:moshi:1.15.0")
implementation "com.google.code.gson:gson:2.10.1"
}
4 changes: 1 addition & 3 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Project-wide Gradle settings.
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
Expand All @@ -20,5 +20,3 @@ org.gradle.jvmargs=-Xmx1536m
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
6 changes: 3 additions & 3 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.event1.capacitorstripeterminal.capacitorstripeterminal">

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import com.getcapacitor.annotation.Permission;
import com.getcapacitor.annotation.PermissionCallback;
import com.stripe.stripeterminal.Terminal;
import com.stripe.stripeterminal.external.callable.BluetoothReaderListener;
import com.stripe.stripeterminal.external.callable.BluetoothReaderReconnectionListener;
import com.stripe.stripeterminal.external.callable.Callback;
import com.stripe.stripeterminal.external.callable.Cancelable;
import com.stripe.stripeterminal.external.callable.ConnectionTokenCallback;
Expand All @@ -25,8 +23,9 @@
import com.stripe.stripeterminal.external.callable.LocationListCallback;
import com.stripe.stripeterminal.external.callable.PaymentIntentCallback;
import com.stripe.stripeterminal.external.callable.ReaderCallback;
import com.stripe.stripeterminal.external.callable.ReaderListener;
import com.stripe.stripeterminal.external.callable.ReaderReconnectionListener;
import com.stripe.stripeterminal.external.callable.TerminalListener;
import com.stripe.stripeterminal.external.callable.UsbReaderListener;
import com.stripe.stripeterminal.external.models.BatteryStatus;
import com.stripe.stripeterminal.external.models.Cart;
import com.stripe.stripeterminal.external.models.CartLineItem;
Expand All @@ -39,7 +38,6 @@
import com.stripe.stripeterminal.external.models.ConnectionStatus;
import com.stripe.stripeterminal.external.models.ConnectionTokenException;
import com.stripe.stripeterminal.external.models.DiscoveryConfiguration;
import com.stripe.stripeterminal.external.models.DiscoveryMethod;
import com.stripe.stripeterminal.external.models.ListLocationsParameters;
import com.stripe.stripeterminal.external.models.Location;
import com.stripe.stripeterminal.external.models.PaymentIntent;
Expand Down Expand Up @@ -82,10 +80,9 @@ public class StripeTerminal
ConnectionTokenProvider,
TerminalListener,
DiscoveryListener,
UsbReaderListener,
HandoffReaderListener,
BluetoothReaderListener,
BluetoothReaderReconnectionListener {
ReaderListener,
ReaderReconnectionListener,
HandoffReaderListener {

Cancelable pendingDiscoverReaders = null;
Cancelable pendingCollectPaymentMethod = null;
Expand Down Expand Up @@ -225,16 +222,13 @@ public void setConnectionToken(PluginCall call) {
@PluginMethod
public void discoverReaders(final PluginCall call) {
try {
Boolean simulated = call.getBoolean("simulated", true);
DiscoveryMethod discoveryMethod = TerminalUtils.translateDiscoveryMethod(
call.getInt("discoveryMethod", 0)
DiscoveryConfiguration discoveryConfiguration = TerminalUtils.translateDiscoveryConfiguration(
call.getInt("discoveryMethod", 0),
call.getBoolean("simulated", true),
call.getInt("timeout", 0),
call.getString("locationId", null)
);

DiscoveryConfiguration discoveryConfiguration = new DiscoveryConfiguration(
0,
discoveryMethod,
simulated
);
Callback statusCallback = new Callback() {
@Override
public void onSuccess() {
Expand Down Expand Up @@ -481,9 +475,7 @@ public void connectHandoffReader(final PluginCall call) {
return;
}

HandoffConnectionConfiguration connectionConfig = new HandoffConnectionConfiguration(
locationId
);
HandoffConnectionConfiguration connectionConfig = new HandoffConnectionConfiguration();

Terminal
.getInstance()
Expand Down Expand Up @@ -671,7 +663,7 @@ public void processPayment(final PluginCall call) {
if (currentPaymentIntent != null) {
Terminal
.getInstance()
.processPayment(
.confirmPaymentIntent(
currentPaymentIntent,
new PaymentIntentCallback() {
@Override
Expand Down Expand Up @@ -903,7 +895,8 @@ public void setSimulatorConfiguration(@NonNull final PluginCall call) {

SimulatorConfiguration newConfig = new SimulatorConfiguration(
availableReaderUpdate,
simulatedCard
simulatedCard,
null
);

Terminal.getInstance().setSimulatorConfiguration(newConfig);
Expand Down Expand Up @@ -1095,13 +1088,13 @@ public void onStartInstallingUpdate(
}

@Override
public void onReaderReconnectStarted(@NonNull Cancelable cancelReconnect) {
public void onReaderReconnectStarted(@NonNull Reader reader, @NonNull Cancelable cancelReconnect) {
pendingReaderAutoReconnect = cancelReconnect;
notifyListeners("didStartReaderReconnect", null);
}

@Override
public void onReaderReconnectSucceeded() {
public void onReaderReconnectSucceeded(@NonNull Reader reader) {
pendingReaderAutoReconnect = null;
notifyListeners("didSucceedReaderReconnect", null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.stripe.stripeterminal.external.models.ChargeJsonAdapter;
import com.stripe.stripeterminal.external.models.ConnectionStatus;
import com.stripe.stripeterminal.external.models.DeviceType;
import com.stripe.stripeterminal.external.models.DiscoveryMethod;
import com.stripe.stripeterminal.external.models.DiscoveryConfiguration;
import com.stripe.stripeterminal.external.models.Location;
import com.stripe.stripeterminal.external.models.PaymentIntent;
import com.stripe.stripeterminal.external.models.PaymentIntentStatus;
Expand Down Expand Up @@ -233,23 +233,24 @@ public static JSObject serializeSimulatorConfiguration(
return object;
}

public static DiscoveryMethod translateDiscoveryMethod(Integer method) {
public static DiscoveryConfiguration translateDiscoveryConfiguration(
Integer method, Boolean simulated, Integer timeout, String locationId) {
if (method == 0) {
return DiscoveryMethod.BLUETOOTH_SCAN;
return new DiscoveryConfiguration.BluetoothDiscoveryConfiguration(timeout, simulated);
} else if (method == 1) {
return DiscoveryMethod.BLUETOOTH_SCAN;
return new DiscoveryConfiguration.BluetoothDiscoveryConfiguration(timeout, simulated);
} else if (method == 2) {
return DiscoveryMethod.INTERNET;
return new DiscoveryConfiguration.InternetDiscoveryConfiguration(locationId, simulated);
} else if (method == 4) {
return DiscoveryMethod.USB;
} else if (method == 5) {
return DiscoveryMethod.EMBEDDED;
return new DiscoveryConfiguration.UsbDiscoveryConfiguration(timeout, simulated);
// } else if (method == 5) {
// return new DiscoveryConfiguration.EmbeddedDiscoveryConfiguration();
} else if (method == 6) {
return DiscoveryMethod.HANDOFF;
return new DiscoveryConfiguration.HandoffDiscoveryConfiguration();
} else if (method == 7) {
return DiscoveryMethod.LOCAL_MOBILE;
return new DiscoveryConfiguration.LocalMobileDiscoveryConfiguration(simulated);
} else {
return DiscoveryMethod.BLUETOOTH_SCAN;
return new DiscoveryConfiguration.BluetoothDiscoveryConfiguration();
}
}

Expand Down Expand Up @@ -280,7 +281,7 @@ public static Integer translatePaymentIntentStatusToJS(int status) {
return 1;
} else if (status == PaymentIntentStatus.REQUIRES_CAPTURE.ordinal()) {
return 2;
} else if (status == 5) { // PaymentIntentStatus seems to be missing a value for Processing??
} else if (status == PaymentIntentStatus.PROCESSING.ordinal()) {
return 3;
} else if (status == PaymentIntentStatus.CANCELED.ordinal()) {
return 4;
Expand Down
6 changes: 4 additions & 2 deletions ios/Plugin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Plugin/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)\n$(FRAMEWORK_SEARCH_PATHS)\n$(FRAMEWORK_SEARCH_PATHS)";
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.Plugin;
Expand All @@ -483,7 +483,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Plugin/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)";
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.Plugin;
Expand All @@ -501,6 +501,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = PluginTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.PluginTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -516,6 +517,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = PluginTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.PluginTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Loading