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

Dev merge to main #70

Merged
merged 45 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
55074c6
MOB-40 and MOB-41
Aug 13, 2024
0ff7856
Merge pull request #53 from degica/fix/MOB-40
tharindu-rhino Aug 14, 2024
3d7c571
Update translation
rramsden Aug 16, 2024
c9a068e
Update english translation to remove slang
rramsden Aug 16, 2024
dd4d78c
Merge pull request #54 from degica/translation-fix-ja
rramsden Aug 16, 2024
e9cd2e9
Use white for input fields and background
rramsden Aug 17, 2024
82c97aa
Merge pull request #56 from degica/update-color-scheme
tharindu-rhino Aug 19, 2024
7479646
Card validation errors
Aug 19, 2024
90e85e6
paymentMethods rename
Aug 19, 2024
0858720
Key services integration
Aug 19, 2024
c7f4c9d
publishable key rename
Aug 19, 2024
cd6278e
Added a loader to example app
Aug 20, 2024
6b4d77e
Merge pull request #57 from degica/task/MOB-44
tharindu-rhino Aug 20, 2024
424df2c
Update JP translation for redirection
rramsden Aug 20, 2024
f480f49
Input error style fixes
Aug 20, 2024
3c158e3
Merge pull request #59 from degica/task/MOB-48
tharindu-rhino Aug 20, 2024
3e040d4
selected language passed to session service
Aug 22, 2024
aa3fa7f
Merge pull request #60 from degica/task/MOB-50
tharindu-rhino Aug 22, 2024
a4d0efd
Merge pull request #58 from degica/update-ja-trans
tharindu-rhino Aug 22, 2024
d09dde7
user cancelled on web fix
chathurapathiranage Aug 22, 2024
d3e030d
Merge pull request #61 from degica/task/MOB-51
chathurapathiranage Aug 23, 2024
e57fdbb
Card input style bug fix
Aug 23, 2024
e310b73
Hardcode the version into API requests
Aug 23, 2024
8d8447e
Merge pull request #62 from degica/task/MOB-52
tharindu-rhino Aug 23, 2024
177fe5c
response screen changes
chathurapathiranage Aug 26, 2024
d233ecd
Updates to JA translations
rramsden Aug 26, 2024
4d584c5
Merge pull request #63 from degica/i18n-updates
rramsden Aug 26, 2024
72953fb
Awaiting status screen
Aug 26, 2024
13f46a5
import oder reformatted
Aug 26, 2024
e47553d
Merge pull request #64 from degica/task/MOB-55
tharindu-rhino Aug 26, 2024
c42e054
added background listner for the response
chathurapathiranage Aug 26, 2024
6268275
added background listner for the response
chathurapathiranage Aug 26, 2024
f17df2e
Merge pull request #65 from degica/task/MOB-56
tharindu-rhino Aug 27, 2024
e35b73b
Update readme.md
rramsden Aug 27, 2024
5b9d188
Main state provider functionality update
Aug 27, 2024
541ecb4
Loader zIndex and keyboard dismiss handled
Aug 27, 2024
d962513
Fixing card payment without 3Ds
Aug 28, 2024
da28c2a
Merge pull request #66 from degica/task/MOB-57
tharindu-rhino Aug 28, 2024
eebac62
Update waiting translation
rramsden Aug 28, 2024
359b04c
Merge pull request #67 from degica/translation-tweaks
rramsden Aug 28, 2024
26c8cd9
change failed message of other payment methods
chathurapathiranage Aug 28, 2024
b1ad2fa
change failed message of other payment methods
chathurapathiranage Aug 28, 2024
d76a020
Merge pull request #68 from degica/task/MOB-58
chathurapathiranage Aug 28, 2024
af470db
payment waiting translation fix
chathurapathiranage Aug 29, 2024
968816c
Merge pull request #69 from degica/task/MOB-59
chathurapathiranage Aug 29, 2024
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
40 changes: 19 additions & 21 deletions example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
import React, {useState} from 'react';
import React, {useEffect, useState} from 'react';
import {SafeAreaView, StyleSheet} from 'react-native';
import {KomojuSDK, LanguageTypes} from '@komoju/komoju-react-native';

import PaymentScreen from './PaymentScreen';
import SettingsModal, {SettingsIcon} from './components/settingsComponent';
import LanguageSelectComponent from './components/languageSelectComponet';
import getPublishableKey from './services/keyService';
import Loader from './components/Loader';

/**
* You can get your public key and secret keys from https://komoju.com/en/sign_in
* You can get your Publishable key and Secret keys from https://komoju.com/en/sign_in
* Your publishable key is required in order for Fields to access the KOMOJU API.
* Your secret key is required in order to create a session. This should be done in your backend on a real world application
*/
const PUBLIC_KEY = 'pk_test_bx0nb2z4jcczon39pm4m68l7';
const SECRET_KEY = 'sk_test_61qdasmogfjxtaco2zocdaaw';

function App(): React.JSX.Element {
const [komojuKeys, setKomojuKeys] = useState({
PUBLIC_KEY: PUBLIC_KEY,
SECRET_KEY: SECRET_KEY,
});
const [modalVisible, setModalVisible] = useState(false);
const [publishableKey, setPublishableKey] = useState('');
const [loading, setLoading] = useState(true);
const [language, setLanguage] = useState(LanguageTypes.ENGLISH);

useEffect(() => {
const keyService = async () => {
const key = await getPublishableKey();
setPublishableKey(key);
setLoading(false);
};

keyService();
}, []);

return (
<SafeAreaView style={styles.mainContainer}>
<SettingsIcon setModalVisible={setModalVisible} />
<LanguageSelectComponent language={language} setLanguage={setLanguage} />

<KomojuSDK.KomojuProvider
publicKey={komojuKeys.PUBLIC_KEY}
publishableKey={publishableKey}
language={language}>
<PaymentScreen secretKey={komojuKeys.SECRET_KEY} />
<PaymentScreen language={language} setLoading={setLoading} />
</KomojuSDK.KomojuProvider>

{modalVisible ? (
<SettingsModal
komojuKeys={komojuKeys}
modalVisible={modalVisible}
setModalVisible={setModalVisible}
setKomojuKeys={setKomojuKeys}
/>
) : null}
{loading ? <Loader /> : null}
</SafeAreaView>
);
}
Expand Down
18 changes: 13 additions & 5 deletions example/PaymentScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState} from 'react';
import React, {Dispatch, SetStateAction, useState} from 'react';
import {
useColorScheme,
View,
Expand All @@ -9,15 +9,21 @@ import {
Pressable,
Alert,
} from 'react-native';
import {KomojuSDK} from '@komoju/komoju-react-native';
import {KomojuSDK, SessionShowResponseType} from '@komoju/komoju-react-native';
import createSession from './services/sessionService';

export enum CurrencyTypes {
JPY = 'JPY',
USD = 'USD',
}

const PaymentScreen = ({secretKey}: {secretKey: string}) => {
const PaymentScreen = ({
language,
setLoading,
}: {
language: string;
setLoading: Dispatch<SetStateAction<boolean>>;
}) => {
const [amount, setAmount] = useState('');
const [currency, setCurrency] = useState(CurrencyTypes.JPY);
const colorScheme = useColorScheme(); // Detects the color scheme of the device
Expand All @@ -26,13 +32,15 @@ const PaymentScreen = ({secretKey}: {secretKey: string}) => {
const {createPayment} = KomojuSDK.useKomoju();

const handleSessionPay = async () => {
setLoading(true);
if (!amount) {
Alert.alert('Error', 'Please enter an amount to checkout');
return;
}

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

// invoke createPayment method with sessionId as parameters to open the payment portal
createPayment({
Expand All @@ -43,7 +51,7 @@ const PaymentScreen = ({secretKey}: {secretKey: string}) => {
};

// when the payment is complete pass a callback to get the final results of response
const onPaymentComplete = (response: any) => {
const onPaymentComplete = (response: SessionShowResponseType) => {
console.log(`Transaction Status: ${response?.status}`);
setAmount('');
};
Expand Down
Binary file removed example/assets/gear_icon.png
Binary file not shown.
21 changes: 21 additions & 0 deletions example/components/Loader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';

import {ActivityIndicator, StyleSheet, View} from 'react-native';

const Loader = () => {
return (
<View style={styles.container}>
<ActivityIndicator size="large" />
</View>
);
};

export default Loader;

const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
alignItems: 'center',
justifyContent: 'center',
},
});
186 changes: 0 additions & 186 deletions example/components/settingsComponent.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions example/services/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const PUBLISHABLE_KEY_URL = 'https://rn-komoju-app.glitch.me/serve-keys';
export const CREATE_SESSION_URL =
'https://rn-komoju-app.glitch.me/create-session';
19 changes: 19 additions & 0 deletions example/services/keyService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Alert} from 'react-native';
import {PUBLISHABLE_KEY_URL} from './constants';

const getPublishableKey = async () => {
try {
const response = await fetch(PUBLISHABLE_KEY_URL);
const {publishableKey} = await response.json();

return publishableKey;
} catch (e) {
Alert.alert(
'Error',
'Unable to fetch publishable Key. Is your server running?',
);
return null;
}
};

export default getPublishableKey;
Loading
Loading