klix-app/merchant-api-php

3.0.7 2022-06-15 14:29 UTC

This package is auto-updated.

Last update: 2022-07-15 14:52:57 UTC


README

Requirements

PHP 7.2 and later.

The following PHP extensions are required:

  • curl
  • json
  • openssl

Installation

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "require": {
    "klix/klix-sdk-php": "*@dev"
  }
}

Then run

composer install

Manual Installation

Download the files and include autoload.php:

require_once('/path/to/klix-sdk-php/vendor/autoload.php');

Getting Started

Simple usage looks like:

<?php
require_once 'vendor/autoload.php';
$klix = new \Klix\KlixApi($config['brand_id'], $config['api_key'], $config['endpoint']);
$client = new \Klix\Model\ClientDetails();
$client->email = 'test@example.com';
$purchase = new \Klix\Model\Purchase();
$purchase->client = $client;
$details = new \Klix\Model\PurchaseDetails();
$product = new \Klix\Model\Product();
$product->name = 'Test';
$product->price = 100;
$details->products = [$product];
$purchase->purchase = $details;
$purchase->brand_id = $config['brand_id'];
$purchase->success_redirect = 'https://portal.klix.app/api/v1/?success=1';
$purchase->failure_redirect = 'https://portal.klix.app/api/v1/?success=0';

$result = $klix->createPurchase($purchase);

if ($result && $result->checkout_url) {
	// Redirect user to checkout
	header("Location: " . $result->checkout_url);
	exit;
}

Testing

./vendor/bin/phpunit tests