Coder Social home page Coder Social logo

paygate's Introduction

WARNING: This repository is no longer maintained ⚠️

This repository will not be updated. The repository will be kept available in read-only mode.



Latest Version Tests Psalm Code Style Total Downloads Software License

This package provides an easy way to integrate PayGate's PayWeb3 API with Laravel.

The official documentation can be found here.

Compatibility Chart

Package Version Laravel PHP
2.0.0 7.15+ 7.4+
1.3.2 5.6 – 6.x 7.1+

Installation

You can install this package via composer using:

composer require pwparsons/paygate

The package will automatically register itself.

To publish the config file to config/paygate.php run:

php artisan vendor:publish --tag=paygate.config

Usage

After you've installed the package and filled in the values in the config file working with this package will be a breeze. All the following examples use the facade.

Creating a transaction

// Initiate transaction
$http = PayGate::initiate()
               ->withReference('pgtest_123456789')
               ->withAmount(32.99)
               ->withEmail('[email protected]')
               ->withCurrency('USD') // Optional: defaults to ZAR
               ->withCountry('USA') // Optional: defaults to ZAF
               ->withLocale('en-us') // Optional: defaults to 'en'
               ->withReturnUrl('https://website.com/return_url')
               ->withNotifyUrl('https://website.com/notify_url') // Optional
               ->create();

if ($http->fails()) {
    dump($http->getErrorCode());
    dump($http->getErrorMessage());
    dump($http->all());
}

// Redirect to PayGate's payment page
return PayGate::redirect();

An example of the initiate response can be found in the documentation.

Querying a transaction

$http = PayGate::query()
               ->withPayRequestId('YOUR_PAY_REQUEST_ID_HERE')
               ->withReference('pgtest_123456789')
               ->create();

if ($http->fails()) {
    dump($http->getErrorCode());
    dump($http->getErrorMessage());
    dump($http->all());
}

dd($http->all());

An example of the query response can be found in the documentation.

Tip

Paygate will post to the RETURN_URL and NOTIFY_URL. Exclude these URI's from CSRF verification by adding them to the VerifyCsrfToken middleware. E.g.

class VerifyCsrfToken extends Middleware
{
    protected $except = [
        'return_url',
        'notify_url',
    ];
}

Helpful Methods

The with magic method allows you to set a string after the word 'with' provided within the object it is being called on. This works in exactly the same way as the magic getter except it sets field values and returns the object so that you can chain setters, for example:

$object->withReference('pgtest_123456789')
       ->withAmount(32.99)
       ->withEmail('[email protected]')
       ->withReturnUrl('https://my.return.url/page');

Will result in the following:

{
    "REFERENCE": "pgtest_123456789",
    "AMOUNT": "3299",
    "EMAIL": "[email protected]",
    "RETURN_URL": "https://my.return.url/page"
}

The get magic method allows you to call any string after the word 'get' and it will return that value, for example:

{
    "PAYGATE_ID": "10011072130",
    "PAY_REQUEST_ID": "23B785AE-C96C-32AF-4879-D2C9363DB6E8",
    "REFERENCE": "pgtest_123456789"
}

Getting data from the object:

echo $object->getPaygateId();       // 10011072130
echo $object->getPayRequestId();    // 23B785AE-C96C-32AF-4879-D2C9363DB6E8
echo $object->getReference();       // pgtest_123456789

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see the license file for more information.

paygate's People

Contributors

pwparsons avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.