Skip to content

Instantly share code, notes, and snippets.

@nazieb
Last active January 18, 2021 15:20
Show Gist options
  • Save nazieb/c52023c3b1c3be6bdc5e41a23f4429fc to your computer and use it in GitHub Desktop.
Save nazieb/c52023c3b1c3be6bdc5e41a23f4429fc to your computer and use it in GitHub Desktop.
Send Custom Header using Xendit PHP Library
<?php
class CustomXenditHttpClient implements \Xendit\HttpClientInterface
{
public function request($method, $uri, array $options = []) {
$client = new \GuzzleHttp\Client([
'headers' => ['X-API-VERSION' => '2019-02-04'],
'base_uri' => \Xendit\Xendit::$apiBase,
]);
return $client->request($method, $uri, $options);
}
}
<?php
Route::post('/ovo', function () {
$params = [
'external_id' => '12345678',
'amount' => 80001,
'phone' => '081234567890',
'ewallet_type' => 'OVO',
];
\Xendit\Xendit::setHttpClient(new CustomXenditHttpClient);
$ovo = \Xendit\Ewallets::create($params);
dd($ovo);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment