Skip to content

Commit

Permalink
Sync interac_present info (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-lin-bbpos authored and nazli-stripe committed Nov 14, 2024
1 parent 7e776c3 commit 059de70
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions dev-app/src/screens/CollectCardPaymentScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,7 @@ export default function CollectCardPaymentScreen() {
},
],
});
const resolvedPaymentMethodTypes = enabledPaymentMethodTypes;
if (
enableInterac &&
!resolvedPaymentMethodTypes.includes('interac_present')
) {
resolvedPaymentMethodTypes.push('interac_present');
}

const routingPriority = {
requested_priority: inputValues.requestedPriority,
};
Expand All @@ -197,7 +191,7 @@ export default function CollectCardPaymentScreen() {
const resp = await api.createPaymentIntent({
amount: Number(inputValues.amount),
currency: inputValues.currency,
payment_method_types: resolvedPaymentMethodTypes,
payment_method_types: enabledPaymentMethodTypes,
payment_method_options: paymentMethodOptions,
capture_method: inputValues?.captureMethod,
on_behalf_of: inputValues?.connectedAccountId,
Expand Down Expand Up @@ -264,7 +258,7 @@ export default function CollectCardPaymentScreen() {
const response = await createPaymentIntent({
amount: Number(inputValues.amount),
currency: inputValues.currency,
paymentMethodTypes: resolvedPaymentMethodTypes,
paymentMethodTypes: enabledPaymentMethodTypes,
onBehalfOf: inputValues.connectedAccountId,
transferDataDestination: inputValues.connectedAccountId,
applicationFeeAmount: inputValues.applicationFeeAmount
Expand Down Expand Up @@ -650,7 +644,27 @@ export default function CollectCardPaymentScreen() {
<Switch
testID="enable-interac"
value={enableInterac}
onValueChange={(value) => setEnableInterac(value)}
onValueChange={(value) => {
setEnableInterac(value);
if (
value &&
!enabledPaymentMethodTypes.includes('interac_present')
) {
setEnabledPaymentMethodTypes([
...enabledPaymentMethodTypes,
'interac_present',
]);
} else if (
!value &&
enabledPaymentMethodTypes.includes('interac_present')
) {
setEnabledPaymentMethodTypes(
enabledPaymentMethodTypes.filter(
(type) => type !== 'interac_present'
)
);
}
}}
/>
}
/>
Expand All @@ -666,6 +680,9 @@ export default function CollectCardPaymentScreen() {
enabledPaymentMethodTypes: enabledPaymentMethodTypes,
onChange: (newPaymentMethodTypes: string[]) => {
setEnabledPaymentMethodTypes(newPaymentMethodTypes);
setEnableInterac(
newPaymentMethodTypes.includes('interac_present')
);
},
})
}
Expand Down

0 comments on commit 059de70

Please sign in to comment.