Code Monkey home page Code Monkey logo

goldenpay's Introduction

๐Ÿ’ณ GoldenPay library for PHP

If you are using Laravel, you can use laravel-goldenpay package instead for better integration with extra features.

Latest Stable Version Latest Unstable Version Total Downloads GitHub license

Build Status Test Coverage Maintainability Quality Score StyleCI

Requirements

PHP 7.2 or higher, with json extension.

Installation

composer require orkhanahmadov/goldenpay

Usage

First, instantiate Orkhanahmadov\Goldenpay\Goldenpay and call authenticate() method with "auth key" and "merchant name". Both can be acquired from Goldenpay merchant dashboard.

use Orkhanahmadov\Goldenpay\Goldenpay;

$goldenpay = new Goldenpay();
$goldenpay->authenticate('auth-key-here', 'merchant-name-here');

Getting payment key

To get new payment key use payment method.

Method accepts following arguments:

  • Amount - Amount to charge. Only integer accepted. For example 10.25 needs to be converted to 1025
  • Card type - Requires instance of Orkhanahmadov\Goldenpay\Enums\CardType. CardType::VISA() for VISA, CardType::MASTERCARD() for MasterCard
  • Description - Payment related description
  • Language (optional) - Sets payment page interface language. Requires instance of Orkhanahmadov\Goldenpay\Enums\Language. Language::EN() for english, Language::RU() for russian, Language::AZ() for azerbaijani. Default is azerbaijani
$paymentKey = $goldenpay->payment(100, CardType::VISA(), 'item-description', Language::EN());

Method will return instance of Orkhanahmadov\Goldenpay\Response\PaymentKey. You can access payment key and payment url from this object instance.

$paymentKey->getCode(); // endpoint response code
$paymentKey->getMessage(); // endpoint response message
$paymentKey->getPaymentKey(); // unique payment key
$paymentKey->paymentUrl(); // payment url. you should redirect user to this url to start payment

Important! Goldenpay charges all payments only in AZN.

Checking payment result

To check payment result use result method.

Method accepts following arguments:

  • Payment key - Previously available payment key
$paymentResult = $goldenpay->result('payment-key-here');

Method also accepts instance of Orkhanahmadov\Goldenpay\Response\PaymentKey as an argument.

Method will return instance of Orkhanahmadov\Goldenpay\Response\PaymentResult. You can access following properties from this object instance:

$paymentResult->getCode(); // status code
$paymentResult->getMessage(); // status message
$paymentResult->getPaymentKey(); // instance of Orkhanahmadov\Goldenpay\Response\PaymentKey
$paymentResult->getMerchantName(); // merchant name
$paymentResult->getAmount(); // charged amount in integer format. 100 = 1.00
$paymentResult->getCheckCount(); // shows how many times this payment key result checked
$paymentResult->getPaymentDate(); // \DateTimeImmutable instance of payment date
$paymentResult->getCardNumber(); // charged card number. only first 6 digits and last 4 digits. Example: 422865******8101
$paymentResult->getLanguage(); // 2 letter interface language: 'lv', 'en' or 'ru'
$paymentResult->getDescription(); // description used for payment
$paymentResult->getReferenceNumber(); // payment reference number

You can also use global helper function. Calling this function requires passing "auth key" and "merchant name".

$goldenpay = goldenpay('auth-key-here', 'merchant-name-here'); // returns instance of "Orkhanahmadov\Goldenpay\Goldenpay"
$goldenpay->payment(100, CardType::VISA(), 'your-description', Language::EN());

Orkhanahmadov\Goldenpay\Goldenpay implements Orkhanahmadov\Goldenpay\GoldenpayInterface. You can use this interface as abstraction for dependency injection.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

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 License File for more information.

goldenpay's People

Contributors

orkhanahmadov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ichirotiheiroki

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.