bigfish/paymentgateway-php7-sdk

BIG FISH Payment Gateway - PHP7 SDK

3.5.0 2020-06-15 04:52 UTC

This package is auto-updated.

Last update: 2020-11-15 05:50:19 UTC


README

Version

3.5.0

Requirements

  • PHP 7.2
  • PHP cURL extension
  • PHP OpenSSL extension
  • PHP JSON extension

Installation

BIG FISH Payment Gateway is available at packagist.org, so you can use composer to download this library.

{
    "require": {
        "bigfish/paymentgateway-php7-sdk": "3.*"
    }
}

or run

composer require bigfish/paymentgateway-php7-sdk

Technical documentation

https://docs.paymentgateway.hu/

Source code

https://github.com/bigfish-hu/payment-gateway-php7-sdk

Example usage

Basic configuration

$config = new \BigFish\PaymentGateway\Config();
$config->storeName = "example store name";
$config->apiKey = "ExamPleApiKey";
$config->encryptPublicKey = "publicKeyGoesHere";
$config->testMode = true;

$paymentGateway = new \BigFish\PaymentGateway($config);

Init request

$init = new \BigFish\PaymentGateway\Request\Init();
$init->setProviderName(\BigFish\PaymentGateway::PROVIDER_CIB) // the chosen payment method
    ->setResponseUrl('http://your.companys.webshop.url/payment_gateway_response') // callback url
    ->setAmount(1234)
    ->setCurrency('HUF')
    ->setOrderId('ORD-1234') // your custom order id
    ->setUserId('USER-1234') // your custom user id
    ->setLanguage('HU');

$response = $paymentGateway->send($init);

Start request

if (!$response->ResultCode == "SUCCESSFUL" || !$response->TransactionId) {
    // handle error here
}

$paymentGateway->send(
        (new \BigFish\PaymentGateway\Request\Start())->setTransactionId($response->TransactionId)
    );

Result request

$result = $paymentGateway->send(
        (new \BigFish\PaymentGateway\Request\Result())->setTransactionId($_GET['TransactionId'])
    );

Details request

$details = $paymentGateway->send(
        (new \BigFish\PaymentGateway\Request\Details())->setTransactionId($_GET['TransactionId'])
    );

Close request

$response = $paymentGateway->send(
        (new \BigFish\PaymentGateway\Request\Close())->setTransactionId($transactionId)
    );

Refund request

$response = $paymentGateway->send(
        (new \BigFish\PaymentGateway\Request\Refund())
            ->setTransactionId($transactionId)
            ->setAmount(100)
    );

One click token cancel request

$response = $paymentGateway->send(
        (new \BigFish\PaymentGateway\Request\OneClickTokenCancel())->setTransactionId($transactionId)
    );

All one click token cancel request

$response = $paymentGateway->send(
        (new \BigFish\PaymentGateway\Request\OneClickTokenCancelAll())
            ->setProviderName(\BigFish\PaymentGateway::PROVIDER_BORGUN2)
            ->setUserId('userId')
    );

Init Recurring Payment - InitRP

$initRP = new \BigFish\PaymentGateway\Request\InitRP();
$initRP->setReferenceTransactionId("783593c87fee4d372f47f53840028682")
    ->setResponseUrl("http://your.companys.webshop.url/payment_gateway_response") // callback url
    ->setAmount(200)
    ->setCurrency("HUF")
    ->setOrderId("BF-TEST-ORDER-REG") // your custom order id
    ->setUserId("BF-TEST-USER-REG");

$response = $paymentGateway->send($initRP);

StartRP request

if (!$response->ResultCode == "SUCCESSFUL" || !$response->TransactionId) {
    // handle error here
}

$result = $paymentGateway->send(
        (new \BigFish\PaymentGateway\Request\StartRP())->setTransactionId($response->TransactionId)
    );

Create Payment Link - PaymentLinkCreate

$paymentLink = new \BigFish\PaymentGateway\Request\PaymentLinkCreate();
$paymentLink->setProviderName(\BigFish\PaymentGateway::PROVIDER_CIB) // the chosen payment method
    ->setAmount(1234)
    ->setCurrency('HUF')
    ->setOrderId('ORD-1234') // your custom order id
    ->setUserId('USR-1234') // your customer id
    ->setLanguage('HU');

$response = $paymentGateway->send($paymentLink);

Cancel request

$response = $paymentGateway->send(
        (new \BigFish\PaymentGateway\Request\PaymentLinkCancel())->setPaymentLinkName($paymentLinkName)
    );

Details request

$response = $paymentGateway->send(
        (new \BigFish\PaymentGateway\Request\PaymentLinkDetails())->setPaymentLinkName($paymentLinkName)
    );

Info data

Basic usage

$infoObject = new \BigFish\PaymentGateway\Data\Info();
 
$infoShipping = new \BigFish\PaymentGateway\Data\Info\Order\InfoOrderShippingData();
$infoShipping->setFirstName("John")
    ->setLastName("Doe")
    ->setEmail("test@testmail.com")
    ->setPhoneCc("36")
    ->setPhone("801234567")
    ->setCity("Budapest");

$infoObject->setObject($infoShipping); //add $infoShipping to $infoObject
 
$infoOrderProductItem = new \BigFish\PaymentGateway\Data\Info\Order\InfoOrderProductItem();
$infoOrderProductItem->setSku("PMG055005")
    ->setName("Product11")
    ->setQuantity("10")
    ->setQuantityUnit("db")
    ->setUnitPrice("22.00")
    ->setImageUrl("http://webhsop/product11.jpg")
    ->setDescription("Product11 desc.");

$infoObject->setObject($infoOrderProductItem); //add $infoShipping to $infoObject
 
$infoOrderProductItem = new \BigFish\PaymentGateway\Data\Info\Order\InfoOrderProductItem();
$infoOrderProductItem->setSku("PMG055008")
    ->setName("Product12")
    ->setQuantity("10")
    ->setQuantityUnit("db")
    ->setUnitPrice("22.00")
    ->setImageUrl("http://webhsop/product12.jpg")
    ->setDescription("Product12 desc.");

$infoObject->setObject($infoOrderProductItem); //add $infoShipping to $infoObject

Init

...
    $init->setInfo($infoObject);
...

InitRP

...
    $initRP->setInfo($infoObject);
...

Payment Link

...
    $paymentLink->setInfo($infoObject);
...