strider-tech/peach-payments

Peach Payments integration for Laravel

0.5.0 2019-04-24 15:32 UTC

This package is auto-updated.

Last update: 2024-03-25 06:26:51 UTC


README

release packagist downloads

Installation

In Laravel versions >= 5.5 the service provider and facade will automatically be registered and enabled.

In older versions of the framework just add the package service provider and facade in 'config/app.php' file:

'providers' => [
    ...
    'StriderTech\PeachPayments\PeachPaymentsServiceProvider',
]

'aliases' => [
    ...
    'PeachPayments' => 'StriderTech\PeachPayments\Facade\PeachPaymentsFacade',
]

Add package migrations and vendors with commands:

php artisan vendor:publish --provider="StriderTech\PeachPayments\PeachPaymentsServiceProvider"

After publishing of vendors edit config file: app/config/peachpayments.php and run migrations:

php artisan migrate

Add the Billable trait to your model definition. This trait provides various methods to allow you to perform common tasks, such as registration cards, creating payments, applying coupons, and updating credit card information:

use StriderTech\PeachPayments\Billable;

class User extends Authenticatable
{
    use Billable;
}

Usage

Register Card

$user = Auth::user();

$card = new PaymentCard();
$card->setCardBrand(CardBrand::MASTERCARD)
    ->setCardNumber('5454545454545454')
    ->setCardHolder('Jane Jones')
    ->setCardExpiryMonth('05')
    ->setCardExpiryYear('2020')
    ->setCardCvv('123');
    
$user->storeCard($card);

Register Card by Token

$user->storeCardByToken($token);

Get user cards

$cards = $user->cards;

Pay with card

$paymentCard = PaymentCard::find($id);
$payment = new Payment();
$payment->fromPaymentCard($paymentCard);
$payment->setCurrency('ZAR')
    ->setAmount(90.9);
    
$user->pay($payment);

Get user payments

$payments = $user->payments;

Delete Card

$user->deleteCardByToken($token);