summaryrefslogtreecommitdiff
path: root/midtrans.dart
diff options
context:
space:
mode:
Diffstat (limited to 'midtrans.dart')
-rw-r--r--midtrans.dart39
1 files changed, 17 insertions, 22 deletions
diff --git a/midtrans.dart b/midtrans.dart
index 2746042..8779153 100644
--- a/midtrans.dart
+++ b/midtrans.dart
@@ -28,41 +28,37 @@ class Midtrans {
Midtrans(String apiKey, String pem) {
final apiKeyUtf8 = apiKey.toNativeUtf8();
final pemUtf8 = pem.toNativeUtf8();
- final midtrans_init = dylib.lookupFunction
+ dylib.lookupFunction
<Void Function(Pointer<Utf8>, Pointer<Utf8>),
void Function(Pointer<Utf8>, Pointer<Utf8>)>
- ('midtrans_init');
- midtrans_init(apiKeyUtf8, pemUtf8);
+ ('midtrans_init')(apiKeyUtf8, pemUtf8);
calloc.free(apiKeyUtf8);
calloc.free(pemUtf8);
}
String status(String orderID) {
- final midtrans_status = dylib.lookupFunction<MidtransStatus,
- MidtransStatus>('midtrans_status');
final order_id = orderID.toNativeUtf8();
- final status = midtrans_status(order_id).toDartString();
+ final status = dylib.lookupFunction
+ <MidtransStatus, MidtransStatus>
+ ('midtrans_status')(order_id).toDartString();
calloc.free(order_id);
return status;
}
String chargeBanktransfer(String bank, String orderID,
int grossAmount) {
- final midtrans_banktransfer_new = dylib.lookupFunction
- <MidtransBanktransferNew, MidtransBanktransferNew>
- ('midtrans_banktransfer_new');
- final midtrans_transaction_new = dylib.lookupFunction
- <MidtransTransaction Function(Pointer<Utf8>, Long),
- MidtransTransaction Function(Pointer<Utf8>, int)>
- ('midtrans_transaction_new');
- final midtrans_charge = dylib.lookupFunction
- <MidtransChargeBanktransfer, MidtransChargeBanktransfer>
- ('midtrans_charge_banktransfer');
final bankUtf8 = bank.toNativeUtf8();
final order_id = orderID.toNativeUtf8();
- final vaNumber = midtrans_charge(
- midtrans_banktransfer_new(bankUtf8),
- midtrans_transaction_new(order_id, grossAmount))
+ final vaNumber = dylib.lookupFunction
+ <MidtransChargeBanktransfer, MidtransChargeBanktransfer>
+ ('midtrans_charge_banktransfer')
+ (dylib.lookupFunction
+ <MidtransBanktransferNew, MidtransBanktransferNew>
+ ('midtrans_banktransfer_new')(bankUtf8),
+ dylib.lookupFunction
+ <MidtransTransaction Function (Pointer<Utf8>, Long),
+ MidtransTransaction Function (Pointer<Utf8>, int)>
+ ('midtrans_transaction_new')(order_id, grossAmount))
.toDartString();
calloc.free(bankUtf8);
calloc.free(order_id);
@@ -70,8 +66,7 @@ class Midtrans {
}
void cleanup() {
- final midtrans_cleanup = dylib.lookupFunction<Void Function(),
- void Function()>('midtrans_cleanup');
- midtrans_cleanup();
+ dylib.lookupFunction<Void Function(), void Function()>
+ ('midtrans_cleanup')();
}
}