jaddek/ixopay-sdk-php

Ixopay (v3) http api client

dev-main 2021-12-28 10:14 UTC

This package is not auto-updated.

Last update: 2024-05-14 21:28:27 UTC


README

https://gateway.ixopay.com/documentation/apiv3

Samples

In ./examples folder.

Credentials:

$user = '';
$password = '';
$apiKey = '';
$sharedSecret = '';

Basic usage

Credentials

Api User Credentials

$user and $password location here:

Merchant Configuration
-->Merchants
---->Choose more for merchant
------>Users:

-> fields username and password
$userCredentials = new \Jaddek\Ixopay\Http\UserCredentials($user, $password);

Connector Credentials

$apiToken and $sharedSecret location here:

Merchant Configuration
-->Merchants
--->Connectors
---->Edit: 

-> fields ApiKey and SharedSecret
$connectorCredentials = \Jaddek\Ixopay\Http\ConnectorCredentials::class($apiKey, $sharedSecret);

Environment

There are two environments: sandbox and production.

Sandbox mode available by

\Jaddek\Ixopay\Http\FactorySandbox::class

Production mode available by

\Jaddek\Ixopay\Http\Factory::class

These factories make an HttpClient related to each environment. Urls are hardcoded.

If you don't want to use factory, just create a HttpClient.

Symfony\Component\HttpClient\HttpClient::createForBaseUri(self::getHost());

Endpoints

$endpoint = \Jaddek\Ixopay\Http\FactorySandbox::buildEndpoint(
    \Jaddek\Ixopay\Http\Endpoint\Transactions::class,
); 

new \Jaddek\Ixopay\Http\Endpoint\Transactions($httpClient, $logger);

Methods

Each endpoint has all methods related to API documentation: https://gateway.ixopay.com/documentation/apiv3

All methods work through DTO objects, so the majority of fields and ENUMs are available by suggestions.

// build a DTO
$debit = new \Jaddek\Ixopay\Http\Request\Transaction\TransactionDebit(
    merchantTransactionId: time(),
    amount: 10,
    currency: 'EUR'
);

//Make a call
$result = $endpoint->debit(
    $debit,
    $connectorCredentials,
    $userCredentials
);

// Response
$result->toArray();

Hydrator

You can use Providers that hydrate the whole response to object.

$provider = new \Jaddek\Ixopay\Http\Provider\TransactionHydrationProvider($endpoint);

$object = $provider->debit(
    $debit,
    $connectorCredentials,
    $userCredentials
);

print_r($object->getErrors());
print_r($object->getRedirectUrl());

Example

$userCredentials      = new \Jaddek\Ixopay\Http\UserCredentials($user, $password);
$connectorCredentials = new \Jaddek\Ixopay\Http\ConnectorCredentials($apiToken, $sharedSecret);

$endpoint = \Jaddek\Ixopay\Http\FactorySandbox::buildEndpoint(
    \Jaddek\Ixopay\Http\Endpoint\Transactions::class,
);

$debit = new \Jaddek\Ixopay\Http\Request\Transaction\TransactionDebit(
    merchantTransactionId: time(),
    amount: 10,
    currency: 'EUR'
);

$result = $endpoint->debit(
    $debit,
    $connectorCredentials,
    $userCredentials
);

print_r($result->toArray());