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
156 stars 76 forks source link

unexpected '=' at ApiRequestor.php #76

Closed holywingsindonesia closed 4 years ago

holywingsindonesia commented 4 years ago

Error ketika production request payment

[$rbody, $rcode, $rheaders] = $this->_httpClient()->sendRequest(

HttpClient/GuzzleClient.php

[$rbody, $rcode, $rheader] = $this->_executeRequest($opts, $url);

stanleynguyen commented 4 years ago

Hi @holywingsindonesia Can I have your code snippet that is throwing this error?

holywingsindonesia commented 4 years ago

`Xendit::setApiKey(getenv('xnd_production_S****'));

    $danaParams = [
        'external_id' => 'holywings_' . time(),
        'amount' => 2000,
        'phone' => '082112884647',
        'expiration_date' => '2020-05-02T00:00:00.000Z',
        'callback_url' => 'https://devtakeaway.holywings.id/callbacks',
        'redirect_url' => 'https://devtakeaway.holywings.id/site/wew',
        'ewallet_type' => 'DANA'
    ];

    $createDana = \Xendit\EWallets::create($danaParams);
    var_dump($createDana);`
stanleynguyen commented 4 years ago

@holywingsindonesia Can I have your PHP version as well?

holywingsindonesia commented 4 years ago

ah sorry, i forget switch php version in server. Thank you

stanleynguyen commented 4 years ago

@holywingsindonesia Cool. Is this issue considered resolved then? Please let us know if you encounter any other issues

holywingsindonesia commented 4 years ago

i back to mode development when i request payment get error Xendit\Exceptions\ApiException There was an error with the format submitted to the server.

` Xendit::setApiKey(getenv('xnd_development_dsaTihlnl**'));

    $danaParams = [
        'external_id' => 'demo_' . time(),
        'amount' => 32000,
        'phone' => '081298498259',
        'expiration_date' => '2020-02-20T00:00:00.000Z',
        'callback_url' => 'https://my-shop.com/callbacks',
        'redirect_url' => 'https://my-shop.com/home',
        'ewallet_type' => 'DANA'
    ];

    $createDana = \Xendit\EWallets::create($danaParams);
    var_dump($createDana);`

same like production

https://imgur.com/a/RtVt3on

stanleynguyen commented 4 years ago

@holywingsindonesia Your expiration_date seems to be the problem. It should be a date in the future, your current one is in the past (20 Feb 2020)

stanleynguyen commented 4 years ago

@holywingsindonesia Another possible cause for this API error is missing API key. You might be missing a call to setApiKey

holywingsindonesia commented 4 years ago

@holywingsindonesia Your expiration_date seems to be the problem. It should be a date in the future, your current one is in the past (20 Feb 2020)

already change keep same

Xendit::setApiKey(getenv('xnd_development_***')) this i already call setApiKey

$danaParams = [ 'external_id' => 'demo_' . time(), 'amount' => 32000, 'phone' => '081298498259', 'expiration_date' => '2020-05-02T00:00:00.000Z', 'callback_url' => 'https://my-shop.com/callbacks', 'redirect_url' => 'https://my-shop.com/home', 'ewallet_type' => 'DANA' ];

https://imgur.com/a/OXLfigc

stanleynguyen commented 4 years ago

@holywingsindonesia It should be Xendit::setApiKey('xnd_development_***') without getenv

holywingsindonesia commented 4 years ago

okay thank you, i will try at production type now

holywingsindonesia commented 4 years ago

get response Sender IP address is not whitelisted but i already put the IP server at dashboard

` Xendit::setApiKey('xnd_production_ShitOq***');

    $params = ["external_id" => "262**",
       "bank_code" => "BRI",
       "name" => "Cydh"
    ];

    $createVA = \Xendit\VirtualAccounts::create($params);
    var_dump($createVA);

    $id = $createVA['id'];

    $getVABanks = \Xendit\VirtualAccounts::getVABanks();
    var_dump($getVABanks);

    $getVA = \Xendit\VirtualAccounts::retrieve($id);
    var_dump($getVA);

    $updateParams = ["suggested_amount" => 10000];
    $updateVA = \Xendit\VirtualAccounts::update($id, $updateParams);
    var_dump($updateVA);

    $paymentID = "262**_591200000****";

    $getFVAPayment = \Xendit\VirtualAccounts::getFVAPayment($paymentID);
    var_dump($getFVAPayment);`

or something wrong with this code?

stanleynguyen commented 4 years ago

@holywingsindonesia Yes. To use Live API key, you have to whitelist your server's IP address in https://dashboard.xendit.co/settings/developers#ip-whitelists

holywingsindonesia commented 4 years ago

Already sir

already

stanleynguyen commented 4 years ago

@holywingsindonesia It's probably incorrect 🤔 You can try running this command curl https://ipinfo.io/ip in your server to see what your server's public IP is

holywingsindonesia commented 4 years ago

try ping devtakeaway.holywings.id its same like whitelist IP

this dedicated server sir,

already put and remove ip

stanleynguyen commented 4 years ago

Hi @holywingsindonesia I think you had a typo in your whitelisted IP in dashboard. The one set there is 103.28.148.68 while your actual IP is 103.28.148.86 (Notice the difference in the last 2 digits 68 vs 86)

holywingsindonesia commented 4 years ago

ah im so sorry, last question

26215 59xx000000000 - 26215 59xx999999999

` ["external_id" => "26215"

$paymentID = "26215_59xx000000005";

` That external and payment ID is right?

stanleynguyen commented 4 years ago

@holywingsindonesia I'm guessing you're trying to use getFVAPayment. payment_id should be the value of payment_id in payload you get from your callback for VA payment.

holywingsindonesia commented 4 years ago

ah okay, i get callback "account_number": "2621559126407242xx", its random generate? or i can make static number?

stanleynguyen commented 4 years ago

@holywingsindonesia payment_id is unique to every payment so it can't be fixed. May I know what is that you're trying to achieve?

holywingsindonesia commented 4 years ago

okay thank you, i wanna make 1 user => 1 account VA we wanna build takeaway service and with another method payment.

so : every transaction make 1 VA, can repeat the same VA for next payment with same user?

anyway thank you for you help.

stanleynguyen commented 4 years ago

Cool hope that was helpful for you @holywingsindonesia