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: fix compilation on new Android arch #250

Open
wants to merge 7 commits into
base: refactor/ACC-4512/cleanup-vaulting
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
22 changes: 11 additions & 11 deletions packages/example/src/screens/HeadlessCheckoutScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, {useEffect, useState} from 'react';
import {Alert, Image, TouchableOpacity, View} from 'react-native';
import React, { useEffect, useState } from 'react';
import { Alert, Image, TouchableOpacity, View } from 'react-native';
import {
createClientSession,
createPayment,
resumePayment,
} from '../network/api';
import {appPaymentParameters} from '../models/IClientSessionRequestBody';
import type {IPayment} from '../models/IPayment';
import {getPaymentHandlingStringVal} from '../network/Environment';
import {ActivityIndicator} from 'react-native';
import { appPaymentParameters } from '../models/IClientSessionRequestBody';
import type { IPayment } from '../models/IPayment';
import { getPaymentHandlingStringVal } from '../network/Environment';
import { ActivityIndicator } from 'react-native';
import {
Asset,
AssetsManager,
Expand Down Expand Up @@ -151,7 +151,7 @@ export const HeadlessCheckoutScreen = (props: any) => {
)}\n`,
);
setIsLoading(false);
switch(merchantCheckoutAdditionalInfo.additionalInfoName) {
switch (merchantCheckoutAdditionalInfo.additionalInfoName) {
case "DisplayStripeAchMandateAdditionalInfo":
showAchMandateAlert();
break;
Expand Down Expand Up @@ -389,8 +389,6 @@ 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 @@ -429,6 +427,8 @@ export const HeadlessCheckoutScreen = (props: any) => {
paymentMethodType: paymentMethod.paymentMethodType,
});
}
} else if (implementationType === "STRIPE_ACH" && paymentMethod.paymentMethodType === "STRIPE_ACH") {
props.navigation.navigate('HeadlessCheckoutStripeAchScreen');
} else {
Alert.alert(
'Warning!',
Expand All @@ -437,7 +437,7 @@ export const HeadlessCheckoutScreen = (props: any) => {
{
text: 'Cancel',
style: 'cancel',
onPress: () => {},
onPress: () => { },
},
],
{
Expand Down Expand Up @@ -501,7 +501,7 @@ export const HeadlessCheckoutScreen = (props: any) => {
.toLowerCase()
.replace('_', '-')}`}>
<Image
style={{height: 36, width: '100%', resizeMode: 'contain'}}
style={{ height: 36, width: '100%', resizeMode: 'contain' }}
source={{
uri:
paymentMethodsAsset.paymentMethodLogo.colored ||
Expand Down
28 changes: 15 additions & 13 deletions packages/example/src/screens/HeadlessCheckoutVaultScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,20 @@ export default HeadlessCheckoutVaultScreen = (props: any) => {
} else {
return (
vaultedPaymentMethods.map((item) => {
return <Text style={{
marginHorizontal: 20,
paddingTop: 1,
paddingBottom: 10,
paddingHorizontal: 10,
fontSize: 18,
height: 40,
color: 'black'
}} onPress={() => setSelectedVaultedPaymentMethod(item)}
>
{getVaultedPaymentData(item)}
</Text>
return <View style={{flexDirection:'row'}}>
<Text style={{
marginHorizontal: 20,
paddingTop: 1,
paddingBottom: 10,
paddingHorizontal: 10,
fontSize: 18,
flexWrap: 'wrap',
color: 'black'
}} onPress={() => setSelectedVaultedPaymentMethod(item)}
>
• {getVaultedPaymentData(item)}
</Text>
</View>
})
);
}
Expand Down Expand Up @@ -315,7 +317,7 @@ export default HeadlessCheckoutVaultScreen = (props: any) => {
case "STRIPE_ACH": {
const bankName = item.paymentInstrumentData?.bankName ?? "-";
suffix = "(" + bankName + ")"
const last4Digits = item.paymentInstrumentData?.last4Digits;
const last4Digits = item.paymentInstrumentData?.accountNumberLast4Digits;
if (last4Digits !== undefined) {
suffix += " ••••" + last4Digits
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import io.primer.android.completion.PrimerResumeDecisionHandler
import io.primer.android.domain.PrimerCheckoutData
import io.primer.android.domain.action.models.PrimerClientSession
import io.primer.android.domain.error.models.PrimerError
import io.primer.android.domain.payments.additionalInfo.MultibancoCheckoutAdditionalInfo
import io.primer.android.domain.payments.additionalInfo.PrimerCheckoutAdditionalInfo
import io.primer.android.domain.payments.additionalInfo.PromptPayCheckoutAdditionalInfo
import io.primer.android.vouchers.multibanco.MultibancoCheckoutAdditionalInfo
import io.primer.android.payments.core.additionalInfo.PrimerCheckoutAdditionalInfo
import io.primer.android.qrcode.QrCodeCheckoutAdditionalInfo
import io.primer.android.domain.tokenization.models.PrimerPaymentMethodData
import io.primer.android.domain.tokenization.models.PrimerPaymentMethodTokenData
import kotlinx.serialization.encodeToString
Expand Down Expand Up @@ -173,7 +173,7 @@ class PrimerRNEventListener : PrimerCheckoutListener {

override fun onAdditionalInfoReceived(additionalInfo: PrimerCheckoutAdditionalInfo) {
if (implementedRNCallbacks?.isOnCheckoutAdditionalInfoImplemented == true) {
if (additionalInfo is PromptPayCheckoutAdditionalInfo) {
if (additionalInfo is QrCodeCheckoutAdditionalInfo) {
sendEvent?.invoke(
PrimerEvents.ON_CHECKOUT_RECEIVED_ADDITIONAL_INFO.eventName,
JSONObject(Json.encodeToString(additionalInfo.toCheckoutAdditionalInfoRN())).apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import io.primer.android.components.domain.core.models.PrimerHeadlessUniversalCh
import io.primer.android.domain.PrimerCheckoutData
import io.primer.android.domain.action.models.PrimerClientSession
import io.primer.android.domain.error.models.PrimerError
import io.primer.android.domain.payments.additionalInfo.MultibancoCheckoutAdditionalInfo
import io.primer.android.domain.payments.additionalInfo.PrimerCheckoutAdditionalInfo
import io.primer.android.domain.payments.additionalInfo.PromptPayCheckoutAdditionalInfo
import io.primer.android.domain.payments.additionalInfo.AchAdditionalInfo
import io.primer.android.vouchers.multibanco.MultibancoCheckoutAdditionalInfo
import io.primer.android.payments.core.additionalInfo.PrimerCheckoutAdditionalInfo
import io.primer.android.qrcode.QrCodeCheckoutAdditionalInfo
import io.primer.android.stripe.ach.api.additionalInfo.AchAdditionalInfo
import io.primer.android.domain.tokenization.models.PrimerPaymentMethodData
import io.primer.android.domain.tokenization.models.PrimerPaymentMethodTokenData
import io.primer.android.Primer
Expand Down Expand Up @@ -250,7 +250,7 @@ class PrimerRNHeadlessUniversalCheckoutListener(
override fun onCheckoutAdditionalInfoReceived(additionalInfo: PrimerCheckoutAdditionalInfo) {
if (implementedRNCallbacks?.isOnCheckoutAdditionalInfoImplemented == true) {
when (additionalInfo) {
is PromptPayCheckoutAdditionalInfo -> {
is QrCodeCheckoutAdditionalInfo -> {
sendEvent?.invoke(
PrimerHeadlessUniversalCheckoutEvent.ON_CHECKOUT_ADDITIONAL_INFO.eventName,
JSONObject(json.encodeToString(additionalInfo.toCheckoutAdditionalInfoRN())).apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.primerioreactnative.components.datamodels.manager.raw.cardRedirect

import io.primer.android.components.domain.core.models.bancontact.PrimerBancontactCardData
import io.primer.android.bancontact.PrimerBancontactCardData
import kotlinx.serialization.Serializable

@Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.primerioreactnative.components.datamodels.manager.raw.phoneNumber

import io.primer.android.components.domain.core.models.phoneNumber.PrimerPhoneNumberData
import io.primer.android.phoneNumber.PrimerPhoneNumberData
import kotlinx.serialization.Serializable

@Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.primerioreactnative.components.datamodels.manager.raw.retailOutlets

import io.primer.android.components.domain.core.models.retailOutlet.PrimerRetailerData
import io.primer.android.PrimerRetailerData
import kotlinx.serialization.Serializable

@Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.primerioreactnative.components.datamodels.manager.raw.retailOutlets

import io.primer.android.data.payments.configure.retailOutlets.RetailOutletsList
import io.primer.android.RetailOutletsList
import kotlinx.serialization.Serializable

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import com.primerioreactnative.datamodels.extensions.ach.toUserDetailsRetrievedR
import com.primerioreactnative.utils.convertJsonToArray
import com.primerioreactnative.utils.convertJsonToMap
import com.primerioreactnative.utils.errorTo
import io.primer.android.components.manager.ach.PrimerHeadlessUniversalCheckoutAchManager
import io.primer.android.components.ach.PrimerHeadlessUniversalCheckoutAchManager
import io.primer.android.components.manager.core.composable.PrimerValidationStatus
import io.primer.android.components.presentation.paymentMethods.nativeUi.stripe.ach.StripeAchUserDetailsComponent
import io.primer.android.components.presentation.paymentMethods.nativeUi.stripe.ach.composable.AchUserDetailsCollectableData
import io.primer.android.components.presentation.paymentMethods.nativeUi.stripe.ach.composable.AchUserDetailsStep
import io.primer.android.stripe.ach.api.component.StripeAchUserDetailsComponent
import io.primer.android.stripe.ach.api.composable.AchUserDetailsCollectableData
import io.primer.android.stripe.ach.api.composable.AchUserDetailsStep
import io.primer.android.domain.error.models.PrimerError
import com.primerioreactnative.utils.toWritableArray
import com.primerioreactnative.utils.toWritableMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.primerioreactnative.utils.toWritableMap
import io.primer.android.ExperimentalPrimerApi
import io.primer.android.components.SdkUninitializedException
import io.primer.android.components.ui.assets.PrimerHeadlessUniversalCheckoutAssetsManager
import io.primer.android.ui.CardNetwork
import io.primer.android.configuration.data.model.CardNetwork
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.json.JSONObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.primerioreactnative.utils.convertJsonToArray
import com.primerioreactnative.utils.errorTo
import io.primer.android.components.manager.banks.composable.BanksCollectableData
import io.primer.android.components.manager.banks.composable.BanksStep
import io.primer.android.components.manager.componentWithRedirect.PrimerHeadlessUniversalCheckoutComponentWithRedirectManager
import io.primer.android.components.componentWithRedirect.PrimerHeadlessUniversalCheckoutComponentWithRedirectManager
import io.primer.android.components.manager.componentWithRedirect.component.BanksComponent
import io.primer.android.components.manager.core.composable.PrimerValidationStatus
import com.primerioreactnative.utils.toWritableArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import android.widget.TextView
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.ViewGroupManager
import io.primer.android.components.presentation.paymentMethods.nativeUi.klarna.PrimerKlarnaPaymentView
import io.primer.android.klarna.api.ui.PrimerKlarnaPaymentView
import java.lang.ref.WeakReference
import java.util.Timer
import java.util.TimerTask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import com.primerioreactnative.extensions.putErrors
import com.primerioreactnative.extensions.putValidationErrors
import io.primer.android.PrimerSessionIntent
import io.primer.android.components.manager.core.composable.PrimerValidationStatus
import io.primer.android.components.manager.klarna.PrimerHeadlessUniversalCheckoutKlarnaManager
import io.primer.android.components.presentation.paymentMethods.nativeUi.klarna.composable.KlarnaComponent
import io.primer.android.components.presentation.paymentMethods.nativeUi.klarna.models.KlarnaPaymentCollectableData
import io.primer.android.components.presentation.paymentMethods.nativeUi.klarna.models.KlarnaPaymentStep
import io.primer.android.klarna.PrimerHeadlessUniversalCheckoutKlarnaManager
import io.primer.android.klarna.api.component.KlarnaComponent
import io.primer.android.klarna.api.composable.KlarnaPaymentCollectableData
import io.primer.android.klarna.api.composable.KlarnaPaymentStep
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import io.primer.android.components.SdkUninitializedException
import io.primer.android.components.domain.exception.UnsupportedPaymentMethodManagerException
import io.primer.android.components.manager.raw.PrimerHeadlessUniversalCheckoutRawDataManager
import io.primer.android.components.manager.raw.PrimerHeadlessUniversalCheckoutRawDataManagerInterface
import io.primer.android.data.payments.configure.retailOutlets.RetailOutletsList
import io.primer.android.RetailOutletsList
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.primerioreactnative.datamodels

import io.primer.android.data.configuration.models.CountryCode
import io.primer.android.configuration.data.model.CountryCode
import io.primer.android.domain.action.models.*
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,23 @@ data class PrimerPaymentInstrumentTokenRN(
val cardholderName: String? = null,
val first6Digits: Int? = null,
val last4Digits: Int? = null,
val accountNumberLast4Digits: Int? = null,
val expirationMonth: Int? = null,
val expirationYear: Int? = null,
val gocardlessMandateId: String? = null,
val externalPayerInfo: ExternalPayerInfo? = null,
val klarnaCustomerToken: String? = null,
val sessionData: SessionData? = null,
// apaya
val mx: String? = null,
val mnc: Int? = null,
val mcc: Int? = null,
val hashedIdentifier: String? = null,
val currencyCode: String? = null,
val productId: String? = null,
// async
val paymentMethodType: String? = null,
// bin
val binData: BinData? = null,
val bankName: String? = null
)

@Serializable
data class ExternalPayerInfo(
val email: String,
val externalPayerId: String?,
val firstName: String?,
val lastName: String?
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.primerioreactnative.datamodels.extensions.ach

import com.primerioreactnative.datamodels.NamedComponentValidatableData
import com.primerioreactnative.datamodels.ach.AchUserDetailsStepRN
import io.primer.android.components.presentation.paymentMethods.nativeUi.stripe.ach.composable.AchUserDetailsCollectableData
import io.primer.android.stripe.ach.api.composable.AchUserDetailsCollectableData
import kotlinx.serialization.Serializable
import com.primerioreactnative.datamodels.ach.AchUserDetailsCollectableDataRN

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.primerioreactnative.datamodels.extensions.ach

import com.primerioreactnative.datamodels.ach.AchUserDetailsStepRN
import io.primer.android.components.presentation.paymentMethods.nativeUi.stripe.ach.composable.AchUserDetailsStep
import io.primer.android.stripe.ach.api.composable.AchUserDetailsStep

internal fun AchUserDetailsStep.UserDetailsCollected.toUserDetailsCollectedRN() =
AchUserDetailsStepRN.UserDetailsCollectedRN()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,34 @@ import com.primerioreactnative.datamodels.PrimerPaymentInstrumentTokenRN
import io.primer.android.data.tokenization.models.PaymentInstrumentData

internal fun PaymentInstrumentData.toPaymentInstrumentDataRN() =
PrimerPaymentInstrumentTokenRN.PaymentInstrumentData(
network,
cardholderName,
first6Digits,
last4Digits,
expirationMonth,
expirationYear,
gocardlessMandateId,
externalPayerInfo?.email?.let { PrimerPaymentInstrumentTokenRN.ExternalPayerInfo(it) },
klarnaCustomerToken,
sessionData?.let {
PrimerPaymentInstrumentTokenRN.PaymentInstrumentData(
network = network,
cardholderName = cardholderName,
first6Digits = first6Digits,
last4Digits = last4Digits,
accountNumberLast4Digits = accountNumberLast4Digits,
expirationMonth = expirationMonth,
expirationYear = expirationYear,
externalPayerInfo = externalPayerInfo?.let {
PrimerPaymentInstrumentTokenRN.ExternalPayerInfo(
email = it.email,
externalPayerId = it.externalPayerId,
firstName = it.firstName,
lastName = it.lastName
)
},
klarnaCustomerToken = klarnaCustomerToken,
sessionData = sessionData?.let {
PrimerPaymentInstrumentTokenRN.SessionData(
it.recurringDescription,
it.billingAddress?.let { PrimerPaymentInstrumentTokenRN.BillingAddress(it.email) })
recurringDescription = it.recurringDescription,
billingAddress = it.billingAddress?.let {
PrimerPaymentInstrumentTokenRN.BillingAddress(email = it.email)
}
)
},
paymentMethodType = paymentMethodType,
binData = binData?.let {
PrimerPaymentInstrumentTokenRN.BinData(network = it.network)
},
mx, mnc, mcc, hashedIdentifier, currencyCode, productId, paymentMethodType,
binData?.let { PrimerPaymentInstrumentTokenRN.BinData(it.network) }
)
bankName = bankName
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import com.primerioreactnative.datamodels.MultibancoCheckoutAdditionalInfoRN
import com.primerioreactnative.datamodels.PromptPayCheckoutAdditionalInfoRN
import com.primerioreactnative.datamodels.XenditCheckoutVoucherAdditionalInfoRN
import com.primerioreactnative.datamodels.AchAdditionalInfoDisplayMandateRN
import io.primer.android.domain.payments.additionalInfo.MultibancoCheckoutAdditionalInfo
import io.primer.android.domain.payments.additionalInfo.PrimerCheckoutAdditionalInfo
import io.primer.android.domain.payments.additionalInfo.PromptPayCheckoutAdditionalInfo
import io.primer.android.domain.payments.additionalInfo.XenditCheckoutVoucherAdditionalInfo
import io.primer.android.domain.payments.additionalInfo.AchAdditionalInfo
import io.primer.android.vouchers.multibanco.MultibancoCheckoutAdditionalInfo
import io.primer.android.payments.core.additionalInfo.PrimerCheckoutAdditionalInfo
import io.primer.android.qrcode.QrCodeCheckoutAdditionalInfo
import io.primer.android.vouchers.retailOutlets.XenditCheckoutVoucherAdditionalInfo
import io.primer.android.stripe.ach.api.additionalInfo.AchAdditionalInfo

internal fun PrimerCheckoutAdditionalInfo.toCheckoutAdditionalInfoRN() = when (this) {
is MultibancoCheckoutAdditionalInfo ->
MultibancoCheckoutAdditionalInfoRN(expiresAt, reference, entity)
is PromptPayCheckoutAdditionalInfo ->
PromptPayCheckoutAdditionalInfoRN(expiresAt, qrCodeUrl, qrCodeBase64)
is QrCodeCheckoutAdditionalInfo ->
PromptPayCheckoutAdditionalInfoRN(expiresAt.orEmpty(), qrCodeUrl, qrCodeBase64)
is XenditCheckoutVoucherAdditionalInfo ->
XenditCheckoutVoucherAdditionalInfoRN(expiresAt, couponCode, retailerName)
is AchAdditionalInfo.DisplayMandate ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.primerioreactnative.extensions

import com.primerioreactnative.datamodels.PrimerIssuingBankRN
import io.primer.android.domain.rpc.banks.models.IssuingBank
import io.primer.android.banks.implementation.rpc.domain.models.IssuingBank

internal fun IssuingBank.toPrimerIssuingBankRN() =
PrimerIssuingBankRN(id, name, disabled, iconUrl)
Loading
Loading