react-native-cielolio
v1.3.6
Published
React Native CieloLio
Downloads
23
Maintainers
Readme
react-native-cielolio
React Native CieloLio
Installation
- Install a package
from npm
npm install react-native-cielolio --save
- Download SDK Cielo
After download SDK clone in your mavenLocal repository .m2/repository:
- Windows:
C:\Users\<user>\.m2
- Linux:
/home/<user>/.m2
- Mac:
/Users/<user>/.m2
- Add at end of file /android/build.gradle
allprojects {
repositories {
mavenLocal()
}
}
- Add dependency in build.gradle:
dependencies {
implementation 'com.cielo.lio:order-manager:2.0.1'
}
- Change or add in android/app/src/main/AndroidManifest.xml allowBackup to true
android:allowBackup="true"
Usage
- initialize(clientID: string, accessToken: string): Promise
Load library with client ID, accessToken.
- Client-Id Access identification;
- Access-Token Access token identification, which stores the access rules allowed to the Client ID;
createDraftOrder(orderId: string): void
Create a draft order.
addItem(sku: string, name: string, unitPrice: number, quantity: number, unitOfMeasure: string): void
Add items to order.
placeOrder(): void
Place order.
requestPayment(amount: number, orderId: string): Promise
Request Payment.
Example
import {
initialize,
createDraftOrder,
addItem,
placeOrder,
requestPayment,
} from 'react-native-cielolio';
const total = 1000;
const sku = 'sku-123';
const clientID = 'your-client-id';
const accessToken = 'your-access-token';
const orderId = 'your-invoice-code';
const productName = 'Product Name';
const productQuantity = 1;
const unitOfMeasure = 'UN';
initialize(clientID, accessToken)
.then(() => {
createDraftOrder(orderId);
addItem(
sku,
productName,
total,
productQuantity,
unitOfMeasure,
);
placeOrder();
requestPayment(total, orderId)
.then(res => {
const paymentData = transformCieloPaymentResponse(JSON.parse(res));
resolve(paymentData);
})
.catch(e => {
const error = handleResponseError(e);
reject(error || 'PAYMENT_ERROR');
});
})
.catch((e) => {
reject(e || 'INITIALIZE_ERROR');
});
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library