Download the PHP package gopay/payments-sdk-php without Composer

On this page you can find all versions of the php package gopay/payments-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package payments-sdk-php

GoPay's PHP SDK for Payments REST API

License Latest Stable Version Total Downloads Monthly Downloads Dependency Status

Requirements

Installation

The simplest way to install SDK is to use Composer:

Basic usage

Configuration

Required fields

Required field Data type Documentation
goid string default GoPay account used in createPayment if target is not specified
clientId string https://doc.gopay.com/#access-token
clientSecret string https://doc.gopay.com/#access-token
gatewayUrl string test or production environment?

Optional fields

Optional field Data type Default value Documentation
scope string GoPay\Definition\TokenScope::ALL https://doc.gopay.com/#access-token
language string GoPay\Definition\Language::ENGLISH language used in createPayment if lang is not specified + used for localization of errors
timeout int 30 Browser timeout in seconds

Available methods

API SDK method
Create a payment $gopay->createPayment(array $payment)
Get status of a payment $gopay->getStatus($id)
Refund a payment $gopay->refundPayment($id, $amount)
Create a recurring payment $gopay->createRecurrence($id, array $payment)
Cancel a recurring payment $gopay->voidRecurrence($id)
Capture a preauthorized payment $gopay->captureAuthorization($id)
Capture a preauthorized payment partially $gopay->captureAuthorizationPartial($id, array $capturePayment)
Void a preauthorized payment $gopay->voidAuthorization($id)
Get payment card details $gopay->getCardDetails($cardId)
Delete a saved card $gopay->deleteCard($cardId)
Get allowed payment methods for a currency $gopay->getPaymentInstruments($goid, $currency)
Get all allowed payment methods $gopay->getPaymentInstrumentsAll($goid)
Generate an account statement $gopay->getAccountStatement(array $accountStatement)

SDK response? Has my call succeed?

SDK returns wrapped API response. Every method returns GoPay\Http\Response object. Structure of json/__toString should be same as in documentation. SDK throws no exception. Please create an issue if you catch one.

Method Description
$response->hasSucceed() checks if API returns status code 200
$response->json decoded response, returned objects are converted into associative arrays
$response->statusCode HTTP status code
$response->rawBody raw body from HTTP response

Are required fields and allowed values validated?

No. API validates fields pretty extensively so there is no need to duplicate validation in SDK. It would only introduce new type of error. Or we would have to perfectly simulate API error messages. That's why SDK just calls API which behavior is well documented in doc.gopay.com.


Advanced usage

Initiation of the payment gateway

Inline gateway

Redirect gateway

Asynchronous initialization using JavaScript

Enums (Code lists)

Instead of hardcoding bank codes string you can use predefined enums. Check using enums in create-payment example

Type Description
Language Payment language, localization of error messages
Token scope Authorization scope for OAuth2
Payment enums Enums for creating payment
Response enums Result of creating payment, executing payment operations
ItemType enums Type of an item
VatRate enums VatRate of an item

Framework integration

Cache access token

Access token expires after 30 minutes so it's expensive to use new token for every request. Unfortunately it's default behavior of GoPay\Token\InMemoryTokenCache. But you can implement your cache and store tokens in Memcache, Redis, files, ... It's up to you.

Your cache must implement GoPay\Token\TokenCache interface. Be aware that there are two scopes (TokenScope) and SDK can be used for different clients (clientId, gatewayUrl). So client passed to methods is unique identifier (string) that is built for current environment. Below you can see example implementation of caching tokens in file:

Log HTTP communication

You can log every request and response from communication with API. Check available loggers below. Or you can implement your own logger, just implement GoPay\Http\Log\Logger interface.

Available logger Description
NullLogger Default logger which does nothing
PrintHttpRequest Prints basic information about request and response, used in remote tests

Contributing

Contributions from others would be very much appreciated! Send pull request/ issue. Thanks!

License

Copyright (c) 2015 GoPay.com. MIT Licensed, see LICENSE for details.


All versions of payments-sdk-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
guzzlehttp/guzzle Version ^7.7.0
symfony/deprecation-contracts Version ^3.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gopay/payments-sdk-php contains the following files

Loading the files please wait ....