Skip to content

Instantly share code, notes, and snippets.

@AguacateVelarde
Last active November 28, 2023 20:17
Show Gist options
  • Save AguacateVelarde/2e61f7f09c46ad78ae520c87eb3134a1 to your computer and use it in GitHub Desktop.
Save AguacateVelarde/2e61f7f09c46ad78ae520c87eb3134a1 to your computer and use it in GitHub Desktop.
Propaga SDK integration
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