Code Monkey home page Code Monkey logo

xendit-php's Introduction

Xendit PHP SDK

Xendit PHP SDK

The official Xendit PHP SDK provides a simple and convenient way to call Xendit's REST API in applications written in PHP.

  • Package version: 5.0.0

Getting Started

Installation

Requirements

PHP 7.4 and later.

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/xendit/xendit-php.git"
    }
  ],
  "require": {
    "xendit/xendit-php": "5.0.0"
  }
}

Then run composer install

Autoloading

Download the files and include autoload.php:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

Authorization

The SDK needs to be instantiated using your secret API key obtained from the Xendit Dashboard. You can sign up for a free Dashboard account here.

use Xendit\Configuration;

Configuration::setXenditKey('XENDIT_API_KEY');

Documentation

Find detailed API information and examples for each of our product’s by clicking the links below,

All URIs are relative to https://api.xendit.co. For more information about our API, please refer to https://developers.xendit.co/.

Further Reading

xendit-php's People

Contributors

0505gonzalez avatar abhijeetjuneja avatar afik avatar albertlieyingadrian avatar asokawotulo avatar boxbag avatar corbadigitpaint avatar david-kurniawan avatar edwinyoyada avatar ellennugroho avatar ervanadetya avatar glendaesutanto avatar hakiemaul avatar hendryzheng avatar hglohika avatar kevindavee avatar kshitij-parashar avatar luminto17 avatar michaellimair avatar mul14 avatar muthmainnah234 avatar nazieb avatar qriouslad avatar rizkyduut avatar stanleynguyen avatar stephenthajeb avatar wlzch avatar xen-hendryzheng avatar xtianatilano avatar yanuaraditia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xendit-php's Issues

unexpected '=' at ApiRequestor.php

Error ketika production request payment

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

HttpClient/GuzzleClient.php

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

Not respon testing API request

Saya sudah membuat akun Xendit dan masih dalam tahap testing dengan menggunakan API request.
Saya melakukan API request langsung dari aplikasi klien saya menggunakan codeigniter.
End point yg saya coba adalah Create Customers dan Get Balance.
Namun request saya tidak ada respon baik itu gagal maupun berhasil.
Customers
get balance

Parameter Success Redirect URL

I want to redirect my invoice to after the payment was a success.
I don't see any parameter of success redirect URL, also I try to CURL and doesn't see the response of success redirect URL. What should I do?

Screenshot from 2019-07-04 21-26-36

Missing default http timeout

    public function __construct(Guzzle $http = null)
    {
        if ($http) {
            $this->http = $http;
        } else {
            $baseUri = strval(Xendit::$apiBase);
            $this->http = new Guzzle(
                [
                    'base_uri' => $baseUri,
                    'verify' => false,
                    'timeout' => 60
                ]
            );
        }
    }

Dependency deprecation

Deprecation warning: require-dev.mikey179/vfsStream is invalid, it should not contain uppercase characters. Please use mikey179/vfsstream instead. Make sure you fix this as Composer 2.0 will error.

API key is not authorized

Hi,
this is mani when i get balance from test mode show below error
"Xendit\Exceptions\ApiException
API key is not authorized for this API service"

my code look like below
Xendit::setApiKey('set_my secret_key');
$getBalance = \Xendit\Balance::getBalance('CASH');
dd($getBalance);

i am using laravel

Ewallet versi terbaru "Failed to validate the request, 1 error occurred. " error 400

Halo Semuanya saya ada kendala dalam implementasi pembayaran ewallet versi baru. saya sudah mengikuti semua aturan yang ditentukan oleh pihak xendit, saya udah mencoba beberapa cara, bahkan sama sampai buka doc. postman xendit untuk test secara langsung dengan menggunakan secret key milik saya. dan hasilnya tetap sama. seperti dibawah ini

image

ini code yang saya gunakan..
image

image

ini param yang saya set
if($request->ewallet_type == 'SHOPEEPAY'){
$payload = [
'reference_id' => $vendors->vendor->prefix.'-'.$request->external_id,
'currency'=>'IDR',
'checkout_method'=>'ONE_TIME_PAYMENT',
'amount' => (int)$request->amount,
'channel_code' => 'ID_'.$request->ewallet_type,
'channel_properties'=>[
'success_redirect_url'=>$request->success_redirect_url
]
];
}

Class 'XenditClient\XenditPHPClient' not found

Hi,
I try to create invoice with this php code:

require 'vendor/autoload.php';

$options['secret_api_key'] = 'xnd_development_xxxxxx';

$xenditPHPClient = new XenditClient\XenditPHPClient($options);

$external_id = 'demo_1475801962607';
$amount = 230000;
$payer_email = '[email protected]';
$description = 'Trip to Bali';

$response = $xenditPHPClient->createInvoice($external_id, $amount, $payer_email, $description);
print_r($response);

I get autoload.php by installing via composer require xendit/xendit-php

When I run the script, getting this error:
Uncaught Error: Class 'XenditClient\XenditPHPClient' not found

Please help what's wrong with my code?!

Mixed Content issue of payment using DANA

Hi, we got another problem with DANA payment.

Opening the checkout_url in Android's webview has a mixed content issue.

"Mixed Content: The page at 'https://m.sandbox.dana.id/m/portal/error?errorCode=network&refer=cashierOrder&bizNo=20200923111212800110166922300021127' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://mas-log-sit.58cloud.alipay.net/loggw/webLog.do'. This content should also be served over HTTPS.", source: https://m.sandbox.dana.id/m/portal/1.66.0/app.de976a31d80522ad6685.js

Also, instead of opening the correct url, it will be redirect to a page with error message:

"The network connection is unstable. Please try again later."
Error code: network

How should we solve this issue?

Many thanks before.

Cheers,
Cherry

Payout change requirement

Changelog:

  • email is required when creating payout
  • passcode is removed from response in every payout endpoint

Perubahan API KEY development ke API KEY production

saya mau bertanya, awalnya saya memasang api key development pada aplikasi saya untuk menggunakan api xendit lalu ketika saya mengubah api key development tersebut menjadi api key production semua transaksi saya seperti virtual account dan ewallet ovo tidak masuk ke live mode tetapi malah masuk ke test mode, itu kenapa ya ?
saya mengakses api xendit menggunakan library xendit-php ini

Cant use fixed VA for create Invoice

createInvoice ($external_id, $amount, $payer_email, $description)

How i suppose to pass "callback_virtual_account_id" to make invoice payment using fixed VA?

Error code 400

Hi there,

is there currently any problem with DANA server?

We got this error message while testing the API:
{"code":400,"error_message":"There was an external error from DANA. Please try again in a few minutes","error_code":"CHECKOUT_ERROR"}

I tried the example code, there was also same error:

Fatal error: Uncaught Xendit\Exceptions\ApiException: There was an external error from DANA. Please try again in a few minutes in /Users/xxx/Downloads/xendit-php-master/src/HttpClient/GuzzleClient.php:167
Stack trace:
#0 /Users/xxx/Downloads/xendit-php-master/src/HttpClient/GuzzleClient.php(140): Xendit\HttpClient\GuzzleClient::_handleAPIError(Array)
#1 /Users/xxx/Downloads/xendit-php-master/src/HttpClient/GuzzleClient.php(90): Xendit\HttpClient\GuzzleClient->_executeRequest(Array, '/ewallets')
#2 /Users/xxx/Downloads/xendit-php-master/src/ApiRequestor.php(87): Xendit\HttpClient\GuzzleClient->sendRequest('POST', '/ewallets', Array, Array)
#3 /Users/xxx/Downloads/xendit-php-master/src/ApiRequestor.php(43): Xendit\ApiRequestor->_requestRaw('POST', '/ewallets', Array, Array)
#4 /Users/xxx/Downloads/xendit-php-master/src/ApiOperations/Request.php(76): Xendit\ApiRequestor->request('POST', '/ewallets', Array, Array)
#5 /Users/xxx/Downloads/xendit-php-master/src/EWallets.php(73): Xendit\EWallets::_request('P in /Users/xxx/Downloads/xendit-php-master/src/HttpClient/GuzzleClient.php on line 167

Many thanks before.

Cheers,
Cherry

Uncaught API format Error

haii, can you help this eror

Fatal error: Uncaught Xendit\Exceptions\ApiException: There was an error with the format submitted to the server. in C:\xampp\htdocs\xendit-php-master\src\HttpClient\GuzzleClient.php:166 Stack trace: #0 C:\xampp\htdocs\xendit-php-master\src\HttpClient\GuzzleClient.php(139): Xendit\HttpClient\GuzzleClient::_handleAPIError(Array) #1 C:\xampp\htdocs\xendit-php-master\src\HttpClient\GuzzleClient.php(92): Xendit\HttpClient\GuzzleClient->_executeRequest(Array, '/v2/invoices') #2 C:\xampp\htdocs\xendit-php-master\src\ApiRequestor.php(87): Xendit\HttpClient\GuzzleClient->sendRequest('POST', '/v2/invoices', Array, Array) #3 C:\xampp\htdocs\xendit-php-master\src\ApiRequestor.php(43): Xendit\ApiRequestor->_requestRaw('POST', '/v2/invoices', Array, Array) #4 C:\xampp\htdocs\xendit-php-master\src\ApiOperations\Request.php(76): Xendit\ApiRequestor->request('POST', '/v2/invoices', Array, Array) #5 C:\xampp\htdocs\xendit-php-master\src\ApiOperations\Create.php(40): Xendit\Invoice::_request('POST', '/v2/invoices', Array) #6 C:\xampp\htdoc in C:\xampp\htdocs\xendit-php-master\src\HttpClient\GuzzleClient.php on line 166

License Clarification

Umm.. This project doesn't have a license, it is not clear how people can use the software. Can you choose a license and add it to the project?

Syntax error for DANA payment

Hi, my DANA e-Wallet has been activated by Xendit today. However, I tried to request payment with DANA e-Wallet and got another
syntax error, unexpected '='
[$rbody, $rcode, $rheaders] = $this->_httpClient()->sendRequest(
as encountered in a previous issue. I am using PHP 7.3 and xendit-php 2.3.1. I have also tried to update to xendit-php 2.4.1 but encountered another error as shown below.

version 2 4

Here is a small reproducible snippet of my code:

Xendit::setApiKey("xnd_production_ShitO****");
        $danaParams = [
            'external_id' => '020'.time(),
            'amount' => 10000,
            'phone' => '082112884647',
            'expiration_date' => '2020-05-14T00:00:00.000Z',
            'callback_url' => 'https://devtake.holywings.id/callbacks',
            'redirect_url' => 'https://devtake.holywings.id/',
            'ewallet_type' => 'DANA'
        ];

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

twitteroauth

boleh tolongin gak?

Uncaught Error: Class 'Composer\CaBundle\CaBundle' not found in C:\xampp\htdocs\nlp\twitteroauth-main\src\TwitterOAuth.php:572

bagaimana menyelesaikannya?

Package requirements not compatible with Laravel

This package requirement in your composer file

"vlucas/phpdotenv": "^4.1"

is not compatible with Laravel. I want to use it in my app that uses Laravel 5.5. I've also tested with the latest Laravel it won't install.

Can you please update your package requirements so that it can be more compatible globally? Tks.

Error Class 'Dotenv\Dotenv' not found

Tolong dibantu saya lagi integrasikan ovo payment dengan library v2 tapi malah terjadi error,
Fatal error: Uncaught Error: Class 'Dotenv\Dotenv' not found in C:\xampp\htdocs\xendit\tes.php:19 Stack trace: #0 {main} thrown in C:\xampp\htdocs\xendit\tes.php on line 19

Berikut code saya

use Dotenv\Dotenv;
use Xendit\Xendit;

require 'vendor/autoload.php';

$dotenv = Dotenv::createImmutable(__DIR__ . '/..');
$dotenv->load();
Xendit::setApiKey(getenv('xnd_production_aJgisgZJk9tc4bd5IM0moxxxx'));

$ovoParams = [
    'external_id'	=> 'demo_' . time(),
    'amount'		=> 32000,
    'phone'			=> '081298498259',
    'ewallet_type'	=> 'OVO'
];

try {
    $createOvo = \Xendit\EWallets::create($ovoParams);
    var_dump($createOvo);
} catch (\Xendit\Exceptions\ApiException $exception) {
    var_dump($exception);
}

$getOvo = \Xendit\EWallets::getPaymentStatus($ovoParams['external_id'], 'OVO');
var_dump($getOvo);

Code diatas saya ambil dari folder example dari repo github disini.

The API key is forbidden to perform this request

Hi ,
This is mani when i store credit card details throw below issue
"exception: "Xendit\Exceptions\ApiException"
file: "xendit/xendit-php/src/HttpClient/GuzzleClient.php"
line: 167
message: "The API key is forbidden to perform this request" "

mycode look like below
in laravel :
Xendit::setApiKey('hidden_development_key');
$params = ['amount' => 1013.5];
$captureCharge = \Xendit\Cards::capture($request->authid,$params);

in js file :
Xendit.card.createToken({
amount: parseInt(totalAmt),
card_number: $('#card_number').val(),
card_exp_month: getMonth,
card_exp_year: $('#expire_year').val(),
card_cvn: $('#cvv_number').val() ,
is_multiple_use: true,
}, xenditResponseHandler);
...

facade

Is there any Facade or Trait, Provider in this package that we can introduce it into packages file config/app.php in Laravel?

Xendit::getHttpClient() must be an instance

Halo saya sudah mengikuti contoh code yang diberikan,
setiap saya panggil request payment keluar error

`
Xendit::setApiKey(getenv("xnd_pro_*******"));

    $ovoParams = [
        'external_id' => 'demo_' . time(),
        'amount' => 32000,
        'phone' => '081298498259',
        'ewallet_type' => 'OVO'
    ];

    $createOvo = EWallets::create($ovoParams);
    var_dump($createOvo);

`

Payment not found

Hello Xendit team,

I tried to run the EwalletsExample.php and got error messages:
Fatal error: Uncaught Xendit\Exceptions\ApiException: Payment not found in /Users/kemkem/Downloads/xendit-php-master/src/HttpClient/GuzzleClient.php:167
Stack trace:
#0 /Users/kemkem/Downloads/xendit-php-master/src/HttpClient/GuzzleClient.php(140): Xendit\HttpClient\GuzzleClient::_handleAPIError(Array)
#1 /Users/kemkem/Downloads/xendit-php-master/src/HttpClient/GuzzleClient.php(90): Xendit\HttpClient\GuzzleClient->_executeRequest(Array, '/ewallets?exter...')
#2 /Users/kemkem/Downloads/xendit-php-master/src/ApiRequestor.php(87): Xendit\HttpClient\GuzzleClient->sendRequest('GET', '/ewallets?exter...', Array, Array)
#3 /Users/kemkem/Downloads/xendit-php-master/src/ApiRequestor.php(43): Xendit\ApiRequestor->_requestRaw('GET', '/ewallets?exter...', Array, Array)

What could be the cause?
It seems the request has been sent.

Many thanks.

Cheers,
Cherry

Pengalihan atau Checkout URL Pembayaran menggunakan OVO

Halo,

Saya ingin mengintegrasikan pembayaran xendit-php di dalam aplikasi, menggunakan eWallets.
Untuk pembayaran menggunakan OVO, bagaimanakah saya harus mengolah respon yang diberikan, atau mengalihkan pembayaran ke aplikasi OVO?

Saya belum jelas apakah pembayaran melalui OVO akan dialihkan ke webview atau membuka aplikasi OVO langsung.

Di dalam dokumentasi tidak ada checkout url untuk ovo, dan saya belum menemukan penjelasan lebih lanjut untuk mengolah business id yang didapatkan sebagai respon pembayaran.

Terima kasih banyak sebelumnya.

Salam,
Cherry

Ewallet Response Error Code

How to get Response error Code Ewallet OVO and Dana by PHP Script.

I received a response type string.

I try :

Param :
$data = [ 'external_id' => $Code, 'amount' => $Amount, 'phone' => '0' . $phone, 'ewallet_type' => $PaymentMethod ];

    try{
        $Result = EWallets::create($data);
    }catch (\ ApiExceptions $apiExceptions){
      // Condition A //
        $Data                       = [
            'status'                => false,
            'message'               => $apiExceptions->getMessage(),
            'code'                  => $apiExceptions->getCode()
        ];

        return response($Data, 200)
            ->header('Content-Type', 'text/plain');

    }catch (\ Exception $exception){
      // Condition B //
        $Data                       = [
            'status'                => false,
            'message'               => $exception->getMessage(),
            'code'                  => $exception->getCode()
        ];

        return response($Data, 200)
            ->header('Content-Type', 'text/plain');
    }

Respons condition B

Screen Shot 2020-02-28 at 16 08 30

Screen Shot 2020-02-28 at 16 08 46

How i can add params option ?

in this new library, i didn't found example for add param options like previous version when create fixed virtual account and invoice.

Like this from previous version

// Set VA closed true
$callback_virtual_account_options = ['is_closed' => true, 'expected_amount' => $amount];
$response = $xenditPHPClient->createCallbackVirtualAccount($external_id, $bank_code, $name, $callback_virtual_account_options);

// To allow payment via Fixed Virtual Account
$invoice_options = ['callback_virtual_account_id' => $virtual_account_id];
$responseInvoice = $xendit->createInvoice($external_id, $amount, $email, $description, $invoice_options);

thanks

Amount is mismatch

Hi ,
this is mani when i pay through xendit (amount is 5000) after successful payment then go to gateway dashboard show like below
https://prnt.sc/su55t5 , https://prnt.sc/su55t5 (payment amount is mismatch)

and my code look like below
$params = [ 'amount' => 5003,
'token_id' => $request->xendit_token,
'external_id' => 'card_'.time(),
'authentication_id' => $request->xendit_auth,
'card_cvn' => '123',
'capture' => true,
'currency'=>'IDR',
];
$createCharge = \Xendit\Cards::create($params);

Missing error handling of no response

$response = $e->getResponse();
$rbody = json_decode($response->getBody()->getContents(), true);
$rcode = $response->getStatusCode();
$rheader = $response->getHeaders();
self::_handleAPIError(
array('body' => $rbody,
'code' => $rcode,
'header' => $rheader)
);

sometimes give this error Call to a member function getBody() on null on line 133 as the response is not always there

Install error

saya sudah install dengan composer dan muncul folder vendor

lalu next stepnya, saya buka di localhost
http://localhost/xendit/vendor/xendit/xendit-php/tests/TestCase.php

keluar eror
Fatal error: Uncaught Error: Class 'PHPUnit\Framework\TestCase' not found in C:\xampp\htdocs\xendit\vendor\xendit\xendit-php\tests\TestCase.php:25 Stack trace: #0 {main} thrown in C:\xampp\htdocs\xendit\vendor\xendit\xendit-php\tests\TestCase.php on line 25

boleh tolong ??

Error When Running Balance Examples

Got this error when running balance PHP

Fatal error: Uncaught Xendit\Exceptions\ApiException: Please contact customer support in /Users/ervan/Documents/xendit/project/php/xendit-php/src/HttpClient/GuzzleClient.php:166 Stack trace: #0 /Users/ervan/Documents/xendit/project/php/xendit-php/src/HttpClient/GuzzleClient.php(139): Xendit\HttpClient\GuzzleClient::_handleAPIError(Array) #1 /Users/ervan/Documents/xendit/project/php/xendit-php/src/HttpClient/GuzzleClient.php(92): Xendit\HttpClient\GuzzleClient->_executeRequest(Array, '/balance?accoun...') #2 /Users/ervan/Documents/xendit/project/php/xendit-php/src/ApiRequestor.php(84): Xendit\HttpClient\GuzzleClient->sendRequest('GET', '/balance?accoun...', Array, Array) #3 /Users/ervan/Documents/xendit/project/php/xendit-php/src/ApiRequestor.php(43): Xendit\ApiRequestor->_requestRaw('GET', '/balance?accoun...', Array, Array) #4 /Users/ervan/Documents/xendit/project/php/xendit-php/src/ApiOperations/Request.php(76): Xendit\ApiRequestor->request('GET', '/balance?accoun...', Array, Array) #5 /Users/ervan/Documents/xendit/proj in /Users/ervan/Documents/xendit/project/php/xendit-php/src/HttpClient/GuzzleClient.php on line 166

README on methods

README portion for each of the functions should document the method's signature rather than just showing an example

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.