This is a Laravel Package for Payment Gateway Integration.
composer require ggphp/laravel-payment
Publish the default config file payment.php
to your application
php artisan config:publish --force
Then choose payment-config
php artisan migrate
Next, add the CustomerBillableTrait to your customer model definition:
use GGPHP\Payment\CustomerPaymentTrait;
class User extends Eloquent
{
use CustomerPaymentTrait;
}
Once you have a customer model instance, you can create simple the customer in the billing gateway:
$user = User::find(1);
$user->payment()->create();
If you would like create customer with properties:
$user->payment()->create([
'email' => $email,
]);
To update an existing customers:
$user->payment()->update([
'email' => $email,
]);
Deleting a customer:
$user->payment()->delete();
You may add more than one credit card on a customer:
$card = $user->card()->create('credit_card_token');
Creating a new charge on a customer:
$charge = $user->charges()->create(5996, ['description' => 'description']);
Once you have a customer model instance, you can create simple the card:
$user = User::find(1);
$card = $user->card()->create('credit_card_token');
Get all cards on a Customer:
$cards $user->card()->all();
Get first card on a Customer:
$card = $user->card()->first();
To find an existing card:
$card = $user->card()->find('id_card');
To update an existing card:
$card = $card->update([
'exp_month' => '1'
]);
To delete an existing card:
$card->delete();
Creating a new charge on a customer:
$charge = $user->charges()->create(499);
If you would like create charge with properties:
$user->charges()->create(499, [
'email' => $email,
]);
To charge on a new credit card token:
$charge = $user->charges()->withCardToken('token')->create(499);
You may also specify an existing credit card to use for a charge:
$charge = $user->charges()->withCard('card_id')->create(499);
To Capturing A Charge:
$charge = $user->charges()->create(499, array('capture' => false));
$charge->capture();
Refunding a charge is also possible:
$charge->refund();
If you would like refund charge with properties:
$charge->refund([
'amount' => 399,
'reason' => 'reason'
]);
Get all charges on a Customer:
$cards $user->charges()->all();
Get first card on a Customer:
$card = $user->charges()->first();
To update an existing charge:
$card = $charge->update([
'description' => 'description'
]);