Skip to content

greenglobal/laravel-payment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Payment Package for Laravel

This is a Laravel Package for Payment Gateway Integration.

Installation

Composer

composer require ggphp/laravel-payment

Configuration

Config File

Publish the default config file payment.php to your application

php artisan config:publish --force

Then choose payment-config

Run Migrations

php artisan migrate

Customer Model Setup

Next, add the CustomerBillableTrait to your customer model definition:

use GGPHP\Payment\CustomerPaymentTrait;

class User extends Eloquent
{
  use CustomerPaymentTrait;
}

Customers

Creating A Customer

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,
]);

Updating A Customer

To update an existing customers:

$user->payment()->update([
  'email' => $email,
]);

Deleting A Customer

Deleting a customer:

$user->payment()->delete();

Create Credit Cards

You may add more than one credit card on a customer:

$card = $user->card()->create('credit_card_token');

Create A Charge

Creating a new charge on a customer:

$charge = $user->charges()->create(5996, ['description' => 'description']);

Cards

Creating Card on a Customer

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

Get all cards on a Customer:

$cards $user->card()->all();

Get first card on a Customer

Get first card on a Customer:

$card = $user->card()->first();

Find A Card

To find an existing card:

$card = $user->card()->find('id_card');

Update card on a Customer

To update an existing card:

$card = $card->update([
  'exp_month' => '1'
]);

Delete A Card

To delete an existing card:

$card->delete();

Charge

Creating A Charge

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);

Capturing A Charge

To Capturing A Charge:

$charge = $user->charges()->create(499, array('capture' => false));

$charge->capture();

Refunding A Charge

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

Get all charges on a Customer:

$cards $user->charges()->all();

Get first charges on a Customer

Get first card on a Customer:

$card = $user->charges()->first();

Update charge

To update an existing charge:

$card = $charge->update([
  'description' => 'description'
]);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages