Componette

Componette

contributte

contributte / gopay-simple v1.0

๐Ÿ’€ [DISCONTINUED] One-class Gopay API library. Use contributte/gopay-inline.

download-cloud-line composer require markette/gopay-simple

Website ๐Ÿš€ contributte.org | Contact ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป f3l1x.io | Twitter ๐Ÿฆ @contributte

Disclaimer

โš ๏ธ This project is no longer being maintained. Please use contributte/gopay-inline.
Composer markette/gopay-simple
Version
PHP
License

Documentation

Goal

One class rule-them-all, best way is $gopay->call().

Install

composer require markette/gopay-simple

Requirements

You need GoID, ClientID and ClientSecret.

Usage

This super simple class provides a few methods, 2 public and 4 protected, for easy extending / prototyping.

Public

  • call(string $method, string $endpoint, array $args = []) : stdClass
  • setMode(int $gopay::DEV/PROD) : void
  • $useragent : PHP+Markette/GopaySimple/{VERSION}
  • $options : [] (cURL options)

Protected

  • authenticate(array $args) : stdClass (token)
  • makeRequest(string $method, string $endpoint, array $args = []) : string
  • getEndpoint(string $type) : string
  • getEndpointUrl(string $uri) : string

Common part

use Markette\GopaySimple\GopaySimple;

$gopay = new GopaySimple($clientId, $clientSecret);

# For testing purpose
$gopay->setMode($gopay::DEV);

Authorization (Oauth)

Auth process is very simple and automatic. So, you do not have to do anything.

If you really need override authorization, you have to extend GopaySimple and call authenticate($args) directly.

Payments

POST+payments/payment
$response = $gopay->call('POST', 'payments/payment', [
	'payer' => [
		'default_payment_instrument' => 'BANK_ACCOUNT',
		'allowed_payment_instruments' => ['BANK_ACCOUNT'],
		'default_swift' => 'FIOBCZPP',
		'allowed_swifts' => ['FIOBCZPP', 'BREXCZPP'],
		'contact' => [
			'first_name' => 'Zbynek',
			'last_name' => 'Zak',
			'email' => 'zbynek.zak@gopay.cz',
			'phone_number' => '+420777456123',
			'city' => 'C.Budejovice',
			'street' => 'Plana 67',
			'postal_code' => '373 01',
			'country_code' => 'CZE',
		],
	],
	'target': ['type' => 'ACCOUNT', 'goid' => '_YOUR_GO_ID_',
	'amount' => 150,
	'currency' => 'CZK',
	'order_number' => '001',
	'order_description' => 'pojisteni01',
	'items' => [
		['name' => 'item01', 'amount' => 50],
		['name' => 'item02', 'amount' => 100],
	],
	'additional_params' => [
		array('name' => 'invoicenumber', 'value' => '20160001')
	],
	'return_url' => 'http://www.your-url.tld/return',
	'notify_url' => 'http://www.your-url.tld/notify',
	'lang' => 'cs',
]);
GET+payments/payment/{id}
$response = $gopay->call('GET', 'payments/payment/{id}');

Best practice

You should inject GopaySimple into your service layer. And configure $args before creating payment for target.

Example of GopayService.

Testing

  1. Start build-in server at tests/buildin/run.sh
  2. Run tester at tests/tester

Development

This package was maintain by these authors.


Consider to support contributte development team. Also thank you for being used this package.

  • v1.0 v1.0

    Bumped v1.0 โœ‹

bar-chart-fill

Statistics

download-cloud-fill
44293
star-fill
1
bug-fill
0
flashlight-fill
114d
price-tag-2-line

Badges

guide-fill

Dependencies

php (>=5.6)
ext-curl (*)
Componette Componette felix@nette.org