A Flutter plugin for Cielo Lio V2.
In your flutter project add the dependency:
dependencies:
...
cielo_lio_helper: ^0.1.0
For help getting started with Flutter, view the online documentation.
Set intent filters accordingly to your needs:
<!-- Example of intent filter to receive print responses from Lio, change host and scheme if needed -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="dev.mauricifj"
android:scheme="print_response" />
</intent-filter>
<!-- Example of intent filter to receive payment responses from Lio, change host and scheme if needed -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="dev.mauricifj"
android:scheme="payment_response" />
</intent-filter>
<!-- Example of intent filter to receive reversal responses from Lio, change host and scheme if needed -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="dev.mauricifj"
android:scheme="reversal_response" />
</intent-filter>
Init cielo_lio_helper
by providing the host and schemes from the previous step:
CieloLioHelper.init(
host: "dev.mauricifj",
schemes: SchemeAggregate(
printResponseScheme: "print_response",
paymentResponseScheme: "payment_response",
reversalResponseScheme: "reversal_response",
),
);
The easiest way to use this library is via the top-level functions. They allow you to use InfoManager and OrderManager with minimal hassle:
String ec;
try {
ec = await CieloLioHelper.ec;
} on PlatformException {
ec = 'Failed to get ec.';
}
String logicNumber;
try {
logicNumber = await CieloLioHelper.logicNumber;
} on PlatformException {
logicNumber = 'Failed to get logic number.';
}
double batteryLevel;
try {
batteryLevel = await CieloLioHelper.batteryLevel;
} on PlatformException {
batteryLevel = -1;
}
var random = Random();
var unitPrice = random.nextInt(400) + 100;
var quantity = random.nextInt(9) + 1;
var total = unitPrice * quantity;
var request = CheckoutRequest(
clientID: "YOUR-CLIENT-ID",
accessToken: "YOUR-ACCESS-TOKEN",
value: total,
paymentCode: "CREDITO_AVISTA",
installments: 0,
email: "[email protected]",
merchantCode: "0000000000000003",
reference: "reference_text",
items: List.from(
[
Item(
sku: "${Random().nextInt(100000) + 1000}",
name: "water bottle",
unitPrice: unitPrice,
quantity: quantity,
unitOfMeasure: "bottle",
),
],
),
);
CieloLioHelper.checkout(request, (response) {
print(response.id);
});
var request = CancelRequest(
clientID: "YOUR-CLIENT-ID",
accessToken: "YOUR-ACCESS-TOKEN",
value: paymentResponse.payments[0].amount,
authCode: paymentResponse.payments[0].authCode,
cieloCode: paymentResponse.payments[0].cieloCode,
merchantCode: paymentResponse.payments[0].merchantCode,
id: paymentResponse.id,
);
CieloLioHelper.cancelPayment(request, (response) {
print(response.id);
});
CieloLioHelper.enqueue("SAMPLE TEXT", PrintAlignment.LEFT, 30, 1);
CieloLioHelper.enqueue("SAMPLE TEXT", PrintAlignment.CENTER, 20, 2);
CieloLioHelper.enqueue("SAMPLE TEXT\n\n\n", PrintAlignment.RIGHT, 10, 2);
CieloLioHelper.printQueue((LioResponse response) {
print(response.code);
print(response.message);
});
- Fork this repository on GitHub
- Clone it
- Commit your changes
- Push to your fork
- Create a Pull Request