diff options
-rw-r--r-- | midtrans.c | 11 | ||||
-rw-r--r-- | midtrans.dart | 8 | ||||
-rw-r--r-- | midtrans.h | 2 |
3 files changed, 13 insertions, 8 deletions
@@ -32,7 +32,7 @@ static size_t append(char *data, size_t size, size_t nmemb, return realsize; } -void midtrans_init(const char *api_key, const char *cainfo) +void midtrans_init(const char *api_key, const char *pem) { static const char *prefix = "SB-"; if (strncmp(api_key, prefix, strlen(prefix))) @@ -77,8 +77,13 @@ void midtrans_init(const char *api_key, const char *cainfo) slist = curl_slist_append(slist, "Content-Type: application/json"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); - if (cainfo) - curl_easy_setopt(curl, CURLOPT_CAINFO, cainfo); + if (pem) + curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, + &(struct curl_blob){ + .data = pem, + .len = strlen(pem), + .flags = CURL_BLOB_COPY + }); } static void *request(void *arg) diff --git a/midtrans.dart b/midtrans.dart index a5e622f..35ee23b 100644 --- a/midtrans.dart +++ b/midtrans.dart @@ -21,20 +21,20 @@ class MidtransBanktransfer extends Struct { class Midtrans { DynamicLibrary dylib; - Midtrans(String apiKey, String caInfo) { + Midtrans(String apiKey, String pem) { dylib = Platform.isAndroid ? DynamicLibrary.open('libmidtrans.so') : DynamicLibrary.process(); final apiKeyUtf8 = apiKey.toNativeUtf8(); - final caInfoUtf8 = caInfo.toNativeUtf8(); + final pemUtf8 = pem.toNativeUtf8(); final midtrans_init = dylib.lookupFunction <Void Function(Pointer<Utf8>, Pointer<Utf8>), void Function(Pointer<Utf8>, Pointer<Utf8>)> ('midtrans_init'); - midtrans_init(apiKeyUtf8, caInfoUtf8); + midtrans_init(apiKeyUtf8, pemUtf8); calloc.free(apiKeyUtf8); - calloc.free(caInfoUtf8); + calloc.free(pemUtf8); } void chargeBanktransfer(MidtransBanktransfer payment, @@ -22,7 +22,7 @@ struct midtrans_banktransfer { extern "C" { #endif -void midtrans_init(const char *api_key, const char *cainfo); +void midtrans_init(const char *api_key, const char *pem); void midtrans_status(const char *order_id); void midtrans_charge_banktransfer(struct midtrans_banktransfer *banktransfer, struct midtrans_transaction *transaction, |