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

Class 'XenditClient\XenditPHPClient' not found #64

Closed z03n87 closed 4 years ago

z03n87 commented 4 years ago

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 = 'sample_email@xendit.co'; $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?!

stanleynguyen commented 4 years ago

Looks like you are using the old API. What's the xendit-php version are you using? v2 of our library introduced breaking changes. Please have a look at https://github.com/xendit/xendit-php/blob/master/examples/InvoiceExample.php for your reference

z03n87 commented 4 years ago

version 2.3 So, in this new version what is use Dotenv\Dotenv; use Xendit\Xendit;

Where do I get this?

stanleynguyen commented 4 years ago

I would recommend you to use https://getcomposer.org/ and follow our installation instruction https://github.com/xendit/xendit-php#installation

z03n87 commented 4 years ago

Thanks for the respond.

I did install via composer, and get all files with autoload.php

so I try this code:

require 'vendor/autoload.php'; Xendit::setApiKey('xnd_development_xxxxx');

$params = ['external_id' => 'demo_147580196270','payer_email' => 'sample_email@xendit.co','description' => 'Trip to Bali','amount' => 32000];

$createInvoice = \Xendit\Invoice::create($params); var_dump($createInvoice);

Still error : Uncaught Error: Class 'Xendit' not found

below is the image of my installation via composer: composer

stanleynguyen commented 4 years ago

Have you included this use Xendit\Xendit;? @z03n87

z03n87 commented 4 years ago

ok finally Done, thanks a lot.