Last active
November 28, 2023 20:17
-
-
Save AguacateVelarde/2e61f7f09c46ad78ae520c87eb3134a1 to your computer and use it in GitHub Desktop.
Propaga SDK integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
import { StyleSheet, View, Button } from 'react-native'; | |
import { usePropaga } from '@propaga/react-native-sdk'; | |
export default function App() { | |
const [isPropagaActive, setIsPropagaActive] = useState(false); | |
const { | |
startPropaga, | |
PropagaPaymentComponent, | |
loaded, | |
PropagaButton, | |
} = usePropaga(); | |
return ( | |
<View style={styles.container}> | |
{loaded && ( | |
<PropagaButton | |
totalAmount={2000} | |
isActive={isPropagaActive} | |
cornerStoreId="...." | |
token={'...'} | |
onPress={() => { | |
setIsPropagaActive(!isPropagaActive); | |
}} /> | |
)} | |
<Button title="Pagar" onPress={startPropaga} /> | |
<PropagaPaymentComponent | |
transaction={{ | |
cornerStoreId: "....", | |
products: [{ | |
externalSKU: '123', | |
name: 'Pepsi', | |
quantity: 1 | |
}], | |
totalAmount: 2001, | |
wholesalerTransactionId: 'TRAN-3245', | |
}} | |
user={{ | |
phoneNumber: '.....', | |
firstName: '....', | |
lastNames: '....', | |
latitude: '19', | |
longitude: '-99', | |
}} | |
config={{ | |
token: '...', | |
}} | |
onSuccessTransaction={(response) => console.log(response)} | |
onErrorTransaction={(error) => console.log(error)} | |
/> | |
</View> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: '#fff', | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment