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

selected language passed to session service #60

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
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
Loading