\Clapp\OtpHuGateway

Allows your users to use otpbank.hu's online payment gateway.

Summary

Methods
Properties
Constants
__construct()
purchase()
completePurchase()
transactionDetails()
setTransactionIdFactory()
setReturnUrl()
setShopId()
setPrivateKey()
setTransactionId()
getTransactionId()
No public properties found
No constants found
No protected methods found
$endpoint
$transactionIdFactory
N/A
No private methods found
No private properties found
N/A

Properties

$endpoint

$endpoint : string

the API endpoint used for communicating with the gateway

Type

string

$transactionIdFactory

$transactionIdFactory : \Clapp\OtpHu\TransactionIdFactory|null

the factory used to auto generate transactions IDs

Type

\Clapp\OtpHu\TransactionIdFactory|null

Methods

__construct()

__construct(\Guzzle\Http\ClientInterface  $httpClient = null, \Symfony\Component\HttpFoundation\Request  $httpRequest = null) 

Create a new gateway instance

Parameters

\Guzzle\Http\ClientInterface $httpClient

A Guzzle client to make API calls with

\Symfony\Component\HttpFoundation\Request $httpRequest

A Symfony HTTP request object

purchase()

purchase(array  $options) : \Clapp\OtpHu\Request\PaymentRequest

Start a new transaction on the gateway

Possible fields for $options are:

  • currency string 3 letter currency code, e.g. HUF
  • amount int|float|string amount of currency to charge (in any format accepted by number_format())
  • language string 2 letter language code, default: hu

Example:

$gateway->purchase([
    'amount' => 100,
    'currency' => 'HUF'
]);

Parameters

array $options

payment options

Returns

\Clapp\OtpHu\Request\PaymentRequest

the payment request that is ready to be sent to the gateway

completePurchase()

completePurchase(array  $options) : \Clapp\OtpHu\Request\TransactionDetailsRequest

Get the details of a transaction from the gateway, including whether or not it's already completed.

Possible fields for $options are:

  • transaction_id string the transaction ID of the transaction

Example:

$request = $gateway->completePurchase([
    'transaction_id' => 'ATransactionIdFromOurDatabase',
]);
$response = $request->send();

Parameters

array $options

payment options

Returns

\Clapp\OtpHu\Request\TransactionDetailsRequest

the request that is ready to be sent to the gateway

transactionDetails()

transactionDetails(array  $options) 

Alias for completePurchase()

completePurchase() is used for compatibility with Omnipay, but this method has a better name to describe what is actually happening

Parameters

array $options

payment options (see completePurchase())

setTransactionIdFactory()

setTransactionIdFactory(\Clapp\OtpHu\TransactionIdFactory  $factory) 

set the transcationFactory that will be used to generate transaction IDs if none is provided for purchase()

Parameters

\Clapp\OtpHu\TransactionIdFactory $factory

the new TransactionIdFactory instance

setReturnUrl()

setReturnUrl(string  $value) : \Clapp\OtpHu\AbstractRequest

Sets the URL where the user will be redirected by the gateway after completing or cancelling the payment on the gateway's website.

Parameters

string $value

absolute url where the user can be redirected to

Returns

\Clapp\OtpHu\AbstractRequest —

Provides a fluent interface

setShopId()

setShopId(string  $value) 

Sets the shop id

Parameters

string $value

shop id - the "#" prefix will be trimmed as it is controlled by setTestMode()

setPrivateKey()

setPrivateKey(string  $value) 

Sets the private key (PEM formatted) used to sign the requests

Example:

$gateway->setPrivateKey(file_get_contents('path/to/#02299991.privKey.pem'));

Parameters

string $value

private key's value in any format accepted by openssl_get_privatekey()

setTransactionId()

setTransactionId(string  $value) 

Sets the transaction ID to use for the next purchase() request

The transaction ID will be used to refer to the transaction later with transactionDetails() or completePurchase() It should be unique for each purchase. If omitted, it will be auto generated by the gateway

Parameters

string $value

transaction id

getTransactionId()

getTransactionId(array  $options = array()) : string

Get the transaction ID we are using

Parameters

array $options

gateway options that we also check for a transactionId field

Returns

string —

transactionId that we either provided or was auto generated by the gateway