xendit / xendit-php

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services, xenPlatforms
https://developers.xendit.co/api-reference/
MIT License
152 stars 76 forks source link

QR Code result not showing the right qr_string #180

Closed faidancode closed 2 years ago

faidancode commented 2 years ago

Halo, pada saat saya membuat Qr code, saya sudah berhasil mendapatkan response. Akan tetapi saya selalu mendapat response qr_string yang sama.

"{\"id\":\"qr_3abb241c-2542-44c0-874f-37c8e213fe96\",\"external_id\":\"53bf8319-3c57-4cbb-9754-3aeeaaf90b42\",\"amount\":154000,\"description\":\"\",\"qr_string\":\"mock-QR-string-use-simulate-payment-to-test-flow\",\"callback_url\":\"https://mysite.com/complete-payment\",\"type\":\"DYNAMIC\",\"status\":\"ACTIVE\",\"created\":\"2022-03-11T02:50:52.092Z\",\"updated\":\"2022-03-11T02:50:52.092Z\",\"metadata\":null}"

response yang benar kan seperti ini "qr_string": "0002010102##########CO.XENDIT.WWW011893600#######14220002152#####414220010303TTT####015CO.XENDIT.WWW02180000000000000000000TTT52 045######ID5911XenditQRIS6007Jakarta6105121606##########3k1mOnF73h11111111#3k1mOnF73h6v53033605401163040BDB",

Ini code saya di Controller PHP

`$ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, 'https://api.xendit.co/qr_codes');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "external_id=$request->order_id&type=DYNAMIC&callback_url=https://mysite.com/complete-payment&amount=$request->grand_total");
    curl_setopt($ch, CURLOPT_USERPWD, $secretKey . ':' . '');

    $headers = array();
    $headers[] = 'Content-Type: application/x-www-form-urlencoded';
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    $result = curl_exec($ch);
    if (curl_errno($ch)) {
        return response()->json(curl_error($ch));
    } else {
        return response()->json($result);
    }
    curl_close($ch);`

Apakah ada yang salah dengan code saya?

AaEzha commented 2 years ago

Hai, @faidancode, kalau untuk Test Mode sepertinya ya memang seperti itu saja. Akan berbeda kalau sudah Live Mode.

Semoga menjawab.