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

feat: ACH public API, sample UI and Android wrapper #216

Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
099d71f
chore: implement StripeAchUserDetailsCollectableDataRN
FlaviuExtPrimer May 17, 2024
d486ed1
chore: implement StripeAchUserDetailsStep
FlaviuExtPrimer May 17, 2024
5b321ad
chore: implement PrimerRNHeadlessUniversalCheckoutStripeAchUserDetail…
FlaviuExtPrimer May 17, 2024
fbc8576
chore: implement StripeAchMandateManager
FlaviuExtPrimer May 17, 2024
36cbd16
chore: refactor StripeAchMandateManager
FlaviuExtPrimer May 20, 2024
53355c9
chore: convert TokenizationStartedRN into object
FlaviuExtPrimer May 20, 2024
57a9e88
chore: align ACH step and collectable naming with Android SDK
FlaviuExtPrimer May 23, 2024
5f5e3a8
chore: implement callback support for AchAdditionalInfo
FlaviuExtPrimer May 23, 2024
ebf027d
chore: implement AchManager
FlaviuExtPrimer May 23, 2024
c18dad8
chore: fix properties not being serialized
FlaviuExtPrimer May 23, 2024
cc4dd65
chore: implement vault manager support for ACH
FlaviuExtPrimer May 24, 2024
1456823
chore: implement HeadlessCheckoutAchScreen
FlaviuExtPrimer May 24, 2024
7704a10
chore: fix build issues caused by migration to compileSdk 34
FlaviuExtPrimer May 28, 2024
d5e6986
chore: remove react-native-picker/picker
FlaviuExtPrimer May 28, 2024
c2a0996
chore: update yarn.lock
FlaviuExtPrimer May 28, 2024
681c06c
chore: rename ACH component providing function to be generic
FlaviuExtPrimer May 28, 2024
10e5e11
chore: use generic name for ACH mandate manager
FlaviuExtPrimer May 28, 2024
39d5da7
chore: fix ACH imports
FlaviuExtPrimer May 28, 2024
d58492a
chore: fix ACH onValidationError handling
FlaviuExtPrimer May 28, 2024
c63b019
Merge remote-tracking branch 'origin/master' into feat/ACC-3019-ACC-3…
FlaviuExtPrimer May 28, 2024
b10316e
chore: upgrade Github Actions JDK to 17
FlaviuExtPrimer May 28, 2024
c54f881
chore: upgrade Github Action JDK for unit tests to 17
FlaviuExtPrimer May 28, 2024
da9f14a
chore: use lowercase string type for ACH steps and collectable data
FlaviuExtPrimer May 28, 2024
89907ff
chore: provide generic names for ACH steps and validatable data
FlaviuExtPrimer May 28, 2024
f500a22
chore: have AchManager take in paymentMethodType
FlaviuExtPrimer May 29, 2024
b014281
chore: rename StripeAchComponent to StripeAchUserDetailsComponent
FlaviuExtPrimer May 30, 2024
37fe91e
chore: updated IPrimerStripeOptions to use the same API for both plat…
FlaviuExtPrimer Jun 10, 2024
ff731d4
Merge branch 'master' of https://github.com/primer-io/primer-sdk-reac…
FlaviuExtPrimer Jun 13, 2024
c2ded20
Merge branch 'master' of https://github.com/primer-io/primer-sdk-reac…
FlaviuExtPrimer Jul 23, 2024
c262c34
chore: update Stripe wrapper, include deviceInfo and scenario in clie…
FlaviuExtPrimer Jul 23, 2024
6dd2000
chore: remove staging repo
FlaviuExtPrimer Aug 2, 2024
982fe3e
chore: add new lines
FlaviuExtPrimer Aug 2, 2024
8b02032
chore: remove eclipse prefs
FlaviuExtPrimer Aug 2, 2024
02ba97d
chore: bump RN target SDK to 34
FlaviuExtPrimer Aug 2, 2024
a697906
chore: refactor toWritableMap(), toWritableArray() for reuse
FlaviuExtPrimer Aug 2, 2024
475e7bf
chore: refactor error mapping code
FlaviuExtPrimer Aug 2, 2024
bdd2d50
chore: implement removeType()
FlaviuExtPrimer Aug 2, 2024
175b4d8
chore: add userAgent to client session
FlaviuExtPrimer Aug 8, 2024
75aa5f5
chore: rename AchManager user detail setter functions
FlaviuExtPrimer Aug 8, 2024
525451d
Merge remote-tracking branch 'origin/master' into feat/ACC-3019-ACC-3…
jnewc Sep 12, 2024
b05200a
Remove key
jnewc Sep 12, 2024
6131cbd
update android sdk to latest
jnewc Sep 12, 2024
c31f934
Align gradle version
jnewc Sep 12, 2024
688f1d9
Android updates for 2.30.1
jnewc Sep 13, 2024
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
6 changes: 6 additions & 0 deletions .github/workflows/android-build-and-distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:
with:
access_token: ${{ github.token }}

- name: Set up JDK 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 17
distribution: 'corretto'

- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3

- uses: ruby/setup-ruby@6bd3d993c602f6b675728ebaecb2b569ff86e99b # v1.174.0
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/unit-tests-and-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
name: Run Android unit tests
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 17
distribution: 'corretto'

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup Node.js
Expand Down
10 changes: 10 additions & 0 deletions packages/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def enableProguardInReleaseBuilds = false
*/
def jscFlavor = 'org.webkit:android-jsc:+'

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

android {
ndkVersion rootProject.ext.ndkVersion
Expand All @@ -71,6 +76,10 @@ android {

namespace "com.example_0_70_6"

buildFeatures {
buildConfig true
}

defaultConfig {
applicationId "com.example_0_70_6"
minSdkVersion rootProject.ext.minSdkVersion
Expand Down Expand Up @@ -117,6 +126,7 @@ dependencies {
implementation "io.primer:3ds-android:1.4.3"
implementation "io.primer:ipay88-my-android:1.0.3"
implementation "io.primer:klarna-android:1.0.4"
implementation "io.primer:stripe-android:1.0.0"

implementation project(path: ':primerioreactnative')

Expand Down
9 changes: 4 additions & 5 deletions packages/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@

buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
compileSdkVersion = 34
targetSdkVersion = 33
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
kotlinVersion = '1.9.0'
kotlinVersion = '1.9.24'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.android.tools.build:gradle:8.2.2")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}

plugins {
id "org.jetbrains.kotlin.android" version "1.8.21" apply false
id "org.jetbrains.kotlin.android" version "1.9.24" apply false
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 1 addition & 3 deletions packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
"build:ios": "npx react-native bundle --entry-file='../sdk/index.js' --bundle-output='./ios/main.jsbundle' --dev=true --platform='ios'"
},
"dependencies": {
"@react-native-masked-view/masked-view": "^0.2.8",
"@react-native-picker/picker": "^2.4.8",
"@react-native-segmented-control/segmented-control": "^2.4.0",
"@react-native/gradle-plugin": "^0.72.0",
"@react-native/gradle-plugin": "^0.74.0",
"@react-navigation/native": "^6.1.1",
"@react-navigation/native-stack": "^6.9.6",
"add": "^2.0.6",
Expand Down
2 changes: 2 additions & 0 deletions packages/example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import RawRetailOutletScreen from './screens/RawRetailOutletScreen';
import HeadlessCheckoutVaultScreen from './screens/HeadlessCheckoutVaultScreen';
import HeadlessCheckoutKlarnaScreen from './screens/HeadlessCheckoutKlarnaScreen';
import HeadlessCheckoutWithRedirect from './screens/HeadlessCheckoutWithRedirect';
import HeadlessCheckoutStripeAchScreen from './screens/HeadlessCheckoutStripeAchScreen';
import { LogBox } from 'react-native';

const Stack = createNativeStackNavigator();
Expand All @@ -37,6 +38,7 @@ const App = () => {
<Stack.Screen name="RawRetailOutlet" component={RawRetailOutletScreen} />
<Stack.Screen name="Klarna" component={HeadlessCheckoutKlarnaScreen} />
<Stack.Screen name="HeadlessCheckoutWithRedirect" component={HeadlessCheckoutWithRedirect} />
<Stack.Screen name="HeadlessCheckoutStripeAchScreen" component={HeadlessCheckoutStripeAchScreen} />
</Stack.Navigator>
</NavigationContainer>
);
Expand Down
16 changes: 16 additions & 0 deletions packages/example/src/models/IClientSessionRequestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface IClientSessionRequestBody {
customerId?: string;
orderId?: string;
currencyCode?: string;
metadata?: IClientSessionMetadata;
order?: IClientSessionOrder;
customer?: IClientSessionCustomer;
paymentMethod?: IClientSessionPaymentMethod;
Expand All @@ -17,6 +18,15 @@ export interface IClientSessionOrder {
lineItems?: Array<IClientSessionLineItem>
}

export interface IClientSessionMetadata {
scenario?: string;
deviceInfo?: IClientSessionDeviceInfo;
}

export interface IClientSessionDeviceInfo {
ipAddress?: string;
}

export interface IClientSessionCustomer {
emailAddress?: string;
mobileNumber?: string;
Expand Down Expand Up @@ -91,6 +101,12 @@ export let appPaymentParameters: AppPaymentParameters = {
customerId: `rn-customer-${makeRandomString(8)}`,
orderId: `rn-order-${makeRandomString(8)}`,
currencyCode: 'EUR',
metadata: {
scenario: 'STRIPE_ACH_ONEOFF',
deviceInfo : {
ipAddress: '127.0.0.1'
}
},
order: {
countryCode: 'DE',
lineItems: [
Expand Down
17 changes: 17 additions & 0 deletions packages/example/src/screens/AchMandateAlert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { AchMandateManager } from '@primer-io/react-native';
import { Alert } from 'react-native';

export async function showAchMandateAlert() {
const achMandateManager = new AchMandateManager();
Alert.alert('ACH Mandate', 'Would you like to accept this mandate?', [
{
text: 'No',
onPress: () => achMandateManager.declineMandate(),
style: 'cancel',
},
{
text: 'Yes',
onPress: () => achMandateManager.acceptMandate()
},
]);
}
15 changes: 13 additions & 2 deletions packages/example/src/screens/HeadlessCheckoutScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import {
NativeUIManager,
PaymentMethod,
PrimerSettings,
SessionIntent,
SessionIntent
} from '@primer-io/react-native';
import SegmentedControl from '@react-native-segmented-control/segmented-control';
import { showAchMandateAlert } from './AchMandateAlert';

let log: string = '';
let merchantPaymentId: string | null = null;
Expand Down Expand Up @@ -80,6 +81,9 @@ export const HeadlessCheckoutScreen = (props: any) => {
iOS: {
urlScheme: 'merchant://primer.io',
},
stripeOptions: {
publishableKey: "pk_test_51O8zfQKUK6bXIdC2xPvSS6UvriE9kwpvttwB7H9PAzhNAZoGzLgiDOyd4WooozeWHxoRrKo6b2VjZYxNCMX3W7bk00rMDivjau"
},
gt-prime marked this conversation as resolved.
Show resolved Hide resolved
},
debugOptions: {
is3DSSanityCheckEnabled: false
Expand Down Expand Up @@ -142,6 +146,11 @@ export const HeadlessCheckoutScreen = (props: any) => {
)}\n`,
);
setIsLoading(false);
switch(merchantCheckoutAdditionalInfo.additionalInfoName) {
case "DisplayStripeAchMandateAdditionalInfo":
showAchMandateAlert();
break;
}
},
onCheckoutComplete: checkoutData => {
merchantCheckoutData = checkoutData;
Expand Down Expand Up @@ -375,6 +384,8 @@ export const HeadlessCheckoutScreen = (props: any) => {
console.log("Payment session intent is " + selectedSessionIntent)
if (paymentMethod.paymentMethodType === "KLARNA") {
props.navigation.navigate('Klarna', { paymentSessionIntent: selectedSessionIntent });
} else if (paymentMethod.paymentMethodType === "STRIPE_ACH") {
props.navigation.navigate('HeadlessCheckoutStripeAchScreen');
} else {
await nativeUIManager.showPaymentMethod(SessionIntent.CHECKOUT);
}
Expand Down Expand Up @@ -529,4 +540,4 @@ export const HeadlessCheckoutScreen = (props: any) => {
{renderLoadingOverlay()}
</View>
);
};
};
Loading
Loading