namdevel / gopay-api

[Gojek] Gopay Api PHP Class (Un-Official)
https://packagist.org/packages/namdevel/gopay-api
MIT License
81 stars 40 forks source link

transferGopay error #9

Closed g00m00nry0ng closed 3 years ago

g00m00nry0ng commented 3 years ago

Kalau dapat response begini saat transferGopay kira-kira kenapa ya Gan?

{ "data": { "kyc_status": "REJECTED", "is_blocked": false, "qr_id": "9e4fa336-0280-4fa3-8c54-8c9c0280047a0", "connection_type": "FRIEND", "connection_status": "ACTIVE", "name": "A***", "phone_number": "+6285843211234" }, "success": true, "errors": [] }{ "success": false, "error": { "code": "303", "description": "Field cannot be blank" }, "errors": [ { "code": "GoPay-303", "message": "Field cannot be blank.", "message_title": "Field cannot be blank.", "message_severity": "error" } ] }

g00m00nry0ng commented 3 years ago

Sepertinya proses getQrid-nya ga mulus kalau langsung transfer, mungkin script saya kurang pas, next jadinya saya coba 2 tahap

  1. getQrid, sukses dapat qr_id
  2. baru transferGopay menggunakan value dari no 1 tapi masih error sbb:

{ "success": false, "error": { "code": "310", "description": "Malformed data" }, "errors": [ { "code": "GoPay-310", "message": "Malformed data", "message_title": "Malformed data", "message_severity": "error" } ] }

ada masukan?

namdevel commented 3 years ago

boleh tau kode eksekusinya ?

namdevel commented 3 years ago

7 coba lihat ini kak, siapa tau problemnya sama

g00m00nry0ng commented 3 years ago

7 coba lihat ini kak, siapa tau problemnya sama

ok, bener Gan. problemnya di amount. setelah saya rubah $amount menjadi (int)$amount sudah fix sekarang. Thx ya

Scriptnya jadi sbb:

public function transferGopay($qr_id,$amount, $pin)
{
    $this->pin = $pin;
    $payload = array(
        'amount' => array(
            'currency' => 'IDR',
            'value' => (int)$amount
        ),
        'description' => 'nama pengirim',
        'metadata' => array(
            'post_visibility' => 'NO_SOCIAL',
            'theme_id' => 'THEME_CLASSIC'
        ),
        'payee' => array(
            'id' => $qr_id,
            'id_type' => 'GOPAY_QR_ID'
        )
    );
    echo self::Request(self::API_CUSTOMER . '/v1/funds/transfer', $payload, true);
}