Skip to content

Commit

Permalink
Merge changes from feat/ACC-3390-ACH-iOS-wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
FlaviuExtPrimer committed Jul 23, 2024
2 parents 04c85bd + d7e559d commit d3caaf3
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 268 deletions.
4 changes: 2 additions & 2 deletions packages/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ dependencies {

implementation project(':primerioreactnative')

implementation "io.primer:3ds-android:1.4.2"
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.1.0" // TODO TWS: use release version
implementation "io.primer:stripe-android:1.0.0"

implementation project(path: ':primerioreactnative')

Expand Down
2 changes: 2 additions & 0 deletions packages/example/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<resources>
<string name="app_name">example</string>

<string name="stripe_ach_full_mandate_text">Would you like to accept this mandate?</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ class ErrorExtensionTests: XCTestCase {
}

func testRNErrorForPrimerError() {
let error = PrimerError.generic(message: "message", userInfo: ["test1": "test2"], diagnosticsId: "diagnosticsId123")
let error = PrimerError.unknown(userInfo: ["test1": "test2"], diagnosticsId: "diagnosticsId123")

let expected: [String: String] = [
"errorId": "primer-generic",
"description": "[unknown] Something went wrong (diagnosticsId: diagnosticsId123)",
"errorId": "unknown",
"diagnosticsId": "diagnosticsId123",
"description": "[primer-generic] Generic error | Message: message | Data: {\n \"test1\" : \"test2\"\n}) (diagnosticsId: diagnosticsId123)"
"recoverySuggestion": "Contact Primer and provide them diagnostics id diagnosticsId123"
]
XCTAssertEqual(error.rnError, expected)
}
Expand Down

This file was deleted.

11 changes: 10 additions & 1 deletion 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;
metadata: IClientSessionMetadata;
customer?: IClientSessionCustomer;
Expand All @@ -20,6 +21,11 @@ export interface IClientSessionOrder {

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

export interface IClientSessionDeviceInfo {
ipAddress?: string;
}

export interface IClientSessionCustomer {
Expand Down Expand Up @@ -97,7 +103,10 @@ export let appPaymentParameters: AppPaymentParameters = {
orderId: `rn-order-${makeRandomString(8)}`,
currencyCode: 'EUR',
metadata: {
"scenario": "STRIPE_ACH_ONEOFF"
scenario: 'STRIPE_ACH_ONEOFF',
deviceInfo : {
ipAddress: '127.0.0.1'
}
},
order: {
countryCode: 'DE',
Expand Down
67 changes: 38 additions & 29 deletions packages/example/src/screens/CheckoutScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,41 +254,50 @@ const CheckoutScreen = (props: any) => {
android: {
threeDsAppRequestorUrl: "https://primer.io"
}
}
},
stripeOptions: {
publishableKey: "pk_test_51O8zfQKUK6bXIdC2xPvSS6UvriE9kwpvttwB7H9PAzhNAZoGzLgiDOyd4WooozeWHxoRrKo6b2VjZYxNCMX3W7bk00rMDivjau",
mandateData: {
fullMandateResourceKey: "stripe_ach_full_mandate_text", // TODO TWS: iOS to define localized string with this exact key
// merchantName: "Primer Inc.",
}
},
},
uiOptions: {
isInitScreenEnabled: true,
isSuccessScreenEnabled: true,
isErrorScreenEnabled: true,
theme: {
colors: {
mainColor: {
red: 214,
green: 255,
blue: 1,
alpha: 255
},
background: {
red: 255,
green: 214,
blue: 1,
alpha: 255
}
},
darkModeColors: {
mainColor: {
red: 1,
green: 255,
blue: 1,
alpha: 255
},
background: {
red: 255,
green: 1,
blue: 255,
alpha: 255
}
}
// 👇 Uncomment to try theming drop-in checkout

// colors: {
// mainColor: {
// red: 214,
// green: 255,
// blue: 1,
// alpha: 255
// },
// background: {
// red: 255,
// green: 214,
// blue: 1,
// alpha: 255
// }
// },
// darkModeColors: {
// mainColor: {
// red: 1,
// green: 255,
// blue: 1,
// alpha: 255
// },
// background: {
// red: 255,
// green: 1,
// blue: 255,
// alpha: 255
// }
// }
}
},
debugOptions: {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ dependencies {
api 'com.facebook.react:react-native:+'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"
implementation 'io.primer:android:2.27.2-snapshot' // TODO TWS: use release version
implementation 'io.primer:android:2.27.6-snapshot'

testImplementation 'io.mockk:mockk:1.13.10'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.json.JSONObject

class PrimerRN(reactContext: ReactApplicationContext, private val json: Json) :
class PrimerRN(private val reactContext: ReactApplicationContext, private val json: Json) :
ReactContextBaseJavaModule(reactContext) {
private val mListener = PrimerRNEventListener()

Expand All @@ -36,7 +36,7 @@ class PrimerRN(reactContext: ReactApplicationContext, private val json: Json) :
if (settingsStr.isBlank()) PrimerSettingsRN() else json.decodeFromString(
settingsStr
)
startSdk(settings.toPrimerSettings())
startSdk(settings.toPrimerSettings(reactContext))
promise.resolve(null)
} catch (e: Exception) {
Log.e("PrimerRN", "configure settings error: $e")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PrimerRNHeadlessUniversalCheckout(
PrimerHeadlessUniversalCheckout.current.start(
reactContext,
clientToken,
settings.toPrimerSettings(),
settings.toPrimerSettings(reactContext),
listener,
listener
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ class ReactNativePackage : ReactPackage {

override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
return mutableListOf(
PrimerCardNumberEditTextManager(),
PrimerCardholderNameEditTextManager(),
PrimerExpiryEditTextManager(),
PrimerCvvEditTextManager(),
PrimerKlarnaPaymentViewManager(reactContext)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ internal fun PrimerHeadlessUniversalCheckoutPaymentMethod.toPrimerRNHeadlessUniv
PrimerRNHeadlessUniversalCheckoutPaymentMethod(
paymentMethodType,
supportedPrimerSessionIntents,
paymentMethodManagerCategories.minus(PrimerPaymentMethodManagerCategory.CARD_COMPONENTS)
paymentMethodManagerCategories
)
Loading

0 comments on commit d3caaf3

Please sign in to comment.