A simple Flutter wrapper for the shoket payment API, for more information on the API visit Shoket Official website.
- Ensure you have your API keys.
- Add the dependency
In your pubspec.yaml file add:
shoket: 0.0.4
Import in your file:
import"package:shoket/shoket.dart";
run flutter pub get
- Create a Shoket instance by calling the constructor
Shoket()
. The constructor accepts an API KEY as parameter. It returns an instance of Shoket which we then call the async method.charge()
or.verify()
on.
final shoket = Shoket(apiKey: "apiKey");
- Create a payment object with the payment details
var paymentDetails = Payment(
amount: "1000",
customerName: "John DOe",
email: "[email protected]",
numberUsed: "255717000000",
channel: "Halotel");
- Get the response by calling
.charge()
method passingpaymentDetails
object as a parameter. NOTE chargeresponse can be null
final ChargeResponse? response = await shoket.charge(paymentDetails);
- Handle the response
if (response == null) {
// the transaction failed
} else {
var status = response.status;
if (status == "success") {
// provide value to customer
} else {
// check message
print(response.message);
}
}
Check example app provided for further assistance
This project is licensed under the MIT License.