Skip to content

Commit

Permalink
Merge pull request #60 from degica/task/MOB-50
Browse files Browse the repository at this point in the history
selected language passed to session service
  • Loading branch information
tharindu-rhino authored Aug 22, 2024
2 parents 3c158e3 + 3e040d4 commit aa3fa7f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function App(): React.JSX.Element {
<KomojuSDK.KomojuProvider
publishableKey={publishableKey}
language={language}>
<PaymentScreen setLoading={setLoading} />
<PaymentScreen language={language} setLoading={setLoading} />
</KomojuSDK.KomojuProvider>

{loading ? <Loader /> : null}
Expand Down
4 changes: 3 additions & 1 deletion example/PaymentScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export enum CurrencyTypes {
}

const PaymentScreen = ({
language,
setLoading,
}: {
language: string;
setLoading: Dispatch<SetStateAction<boolean>>;
}) => {
const [amount, setAmount] = useState('');
Expand All @@ -37,7 +39,7 @@ const PaymentScreen = ({
}

// fetch a session Id to initiate payment
const sessionId = await createSession({amount, currency});
const sessionId = await createSession({amount, currency, language});
setLoading(false);

// invoke createPayment method with sessionId as parameters to open the payment portal
Expand Down
3 changes: 3 additions & 0 deletions example/services/sessionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import {CREATE_SESSION_URL} from './constants';
type createSessionProps = {
amount: string;
currency: string;
language: string;
};

const createSession = async ({
amount,
currency,
language,
}: createSessionProps): Promise<string | null> => {
try {
const options = {
Expand All @@ -23,6 +25,7 @@ const createSession = async ({
body: JSON.stringify({
amount,
currency,
language,
}),
};
const response = await fetch(CREATE_SESSION_URL, options);
Expand Down

0 comments on commit aa3fa7f

Please sign in to comment.