Skip to content

Commit

Permalink
Merge pull request #27 from degica/task/MOB-1
Browse files Browse the repository at this point in the history
[MOB-1] Render instruction pages when instructions URL is available
  • Loading branch information
tharindu-rhino authored Jul 4, 2024
2 parents 3eb014b + 32b3dec commit 466c460
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
16 changes: 16 additions & 0 deletions payment_sdk/src/KomojuProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,22 @@ export const MainStateProvider = (props: KomojuProviderIprops) => {
handleWebViewNavigationStateChange(newNavState, paymentType),
},
});
} else if (
paymentType === PaymentType.KONBINI &&
response?.payment?.payment_details?.instructions_url
) {
dispatch({
type: Actions.SET_WEBVIEW_LINK,
payload: {
link: response?.payment?.payment_details?.instructions_url,
onNavChange: (newNavState: newNavStateProps) =>
handleWebViewNavigationStateChange(newNavState, paymentType),
},
});
dispatch({
type: Actions.SET_PAYMENT_STATE,
payload: ResponseScreenStatuses.COMPLETE,
});
} else if (response?.status === PaymentStatuses.SUCCESS) {
onPaymentSuccess();
} else {
Expand Down
4 changes: 2 additions & 2 deletions payment_sdk/src/__tests__/validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("isCardNumberValid", () => {
});

it("returns false for input exceeding max card length", () => {
expect(isCardNumberValid("12345678901234567")).toBe(false);
expect(isCardNumberValid("12345678901234567890")).toBe(false);
});

it("returns false for input with non-numeric characters", () => {
Expand All @@ -25,7 +25,7 @@ describe("isCardNumberValid", () => {
});

it("returns false for card number with spaces but exceeding max length", () => {
expect(isCardNumberValid("1234 5678 1234 5678 90")).toBe(false);
expect(isCardNumberValid("1234 5678 1234 5678 9012")).toBe(false);
});

it("returns false for input length not matching numeric conversion", () => {
Expand Down
9 changes: 7 additions & 2 deletions payment_sdk/src/components/Sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,18 @@ const Sheet: ForwardRefRenderFunction<SheetRefProps, SheetProps> = (
<TouchableOpacity
style={styles.crossBtn}
onPress={() =>
closeSheet(paymentState !== ResponseScreenStatuses.SUCCESS)
closeSheet(
!(
paymentState === ResponseScreenStatuses.SUCCESS ||
paymentState === ResponseScreenStatuses.COMPLETE
)
)
}
>
<Image source={closeIcon} />
</TouchableOpacity>
</RNAnimated.View>
{paymentState ? (
{paymentState && paymentState !== ResponseScreenStatuses.COMPLETE ? (
<ResponseScreen
status={paymentState}
onPress={ctaOnPress}
Expand Down
7 changes: 7 additions & 0 deletions payment_sdk/src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ export enum TokenResponseStatuses {
}

export enum ResponseScreenStatuses {
/** When a payment is fully complete Displaying success screen immediately and disabling the cancel payment popup */
SUCCESS = "success",
/** Displaying failed screen immediately */
FAILED = "failed",
/** For displaying payment instruction screens and disabling the cancel payment popup */
COMPLETE = "complete",
}

export enum CurrencySign {
Expand Down Expand Up @@ -106,6 +110,9 @@ export type newNavStateProps = {
export type SessionPayResponseType = {
redirect_url: string;
status: string;
payment: {
payment_details: { instructions_url: string };
};
};

export type sessionShowPaymentMethodType = {
Expand Down
2 changes: 1 addition & 1 deletion payment_sdk/src/util/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
SessionShowResponseType,
} from "./types";

const MAX_CARD_LENGTH = 16;
const MAX_CARD_LENGTH = 19;

export const isCardNumberValid = (cardString: string) => {
const text = cardString.replaceAll(" ", "");
Expand Down

0 comments on commit 466c460

Please sign in to comment.