1. Go to this page and download the library: Download glennraya/xendivel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
publicfunctionhandle(eWalletEvents $event){
// You can inspect the returned data from the webhoook in your logs file// storage/logs/laravel.log
logger('Webhook data received: ', $event->webhook_data);
// if($event->webhook_data['data']['status'] === 'SUCCEEDED') {// $invoice_data = [// // Invoice data...// ];// $email_invoice = new Xendivel();// $email_invoice->emailInvoiceTo('glenn@example.com', $invoice_data)// ->send();// }
}
namespaceApp\Http\Middleware;
useIlluminate\Foundation\Http\Middleware\VerifyCsrfTokenasMiddleware;
classVerifyCsrfTokenextendsMiddleware{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/protected $except = [
'/xendit/*',
'https://your-domain.com/xendit/*',
];
}
useGlennRaya\Xendivel\Xendivel;
Route::post('/checkout-email-invoice', function(Request $request){
$invoice_data = [
'invoice_number' => 1000023,
'card_type' => 'VISA',
'masked_card_number' => '400000XXXXXX0002',
'merchant' => [
'name' => 'Stark Industries',
'address' => '152 Maple Avenue Greenfield, New Liberty, Arcadia USA 54331',
'phone' => '+63 971-444-1234',
'email' => 'xendivel@example.com',
],
'customer' => [
'name' => 'Mr. Glenn Raya',
'address' => 'Alex Johnson, 4457 Pine Circle, Rivertown, Westhaven, 98765, Silverland',
'email' => 'victoria@example.com',
'phone' => '+63 909-098-654',
],
'items' => [
['item' => 'MacBook Pro 16" M3 Max', 'price' => $request->amount, 'quantity' => 1],
],
'tax_rate' => .12,
'tax_id' => '123-456-789',
'footer_note' => 'Thank you for your recent purchase with us! We are thrilled to have the opportunity to serve you and hope that your new purchase brings you great satisfaction.',
];
$payment = Xendivel::payWithCard($request)
->emailInvoiceTo('glenn@example.com', $invoice_data)
->send()
->getResponse();
return $payment;
});
useGlennRaya\Xendivel\Xendivel;
Route::post('/checkout-email-invoice', function(Request $request){
$invoice_data = [
// Invoice data...
];
$payment = Xendivel::payWithCard($request)
->emailInvoiceTo('glenn@example.com', $invoice_data)
->subject('Thank you for your purchase!')
->send()
->getResponse();
});
useGlennRaya\Xendivel\Xendivel;
Route::post('/checkout-email-invoice', function(Request $request){
$invoice_data = [
// Invoice data...
];
$payment = Xendivel::payWithCard($request)
->emailInvoiceTo('glenn@example.com', $invoice_data)
->subject('Thank you for your purchase!')
->message('We appreciate your business and look forward to serving you again. We have attached your invoice.')
->send()
->getResponse();
});
useGlennRaya\Xendivel\Xendivel;
publicfunctionhandle(eWalletEvents $event){
// You can inspect the returned data from the webhoook in your logs file// storage/logs/laravel.log
logger('Webhook data received: ', $event->webhook_data);
// $invoice_data = [// Invoice data...// ];if($event->webhook_data['data']['status'] === 'SUCCEEDED') {
$email_invoice = new Xendivel();
$email_invoice->emailInvoiceTo('glenn@example.com', $invoice_data)
->send();
}
}
useGlennRaya\Xendivel\Xendivel;
Route::get('/refund', function(){
$response = Xendivel::getPayment('6595d0fg82741f0011f778fd', 'card')
->refund(3500)
->emailRefundConfirmationTo('glenn@example.com')
->subject('Your refund is on the way!')
->message('We have successfully processed your refund! It should reflect on your account within 3 banking days.')
->send()
->getResponse();
return $response;
});