QorePay logo
QorePay logo

PHP Library

Download Library

Requirements

PHP 7.2 and later.

The following PHP extensions are required:

  • curl
  • json
  • openssl

Installation

Composer

1composer install

Getting Started

Simple usage looks like:

1<?php
2require_once 'vendor/autoload.php';
3$api = new QorepayQorepayApi($config['brand_id'], $config['api_key'], $config['endpoint']);
4$client = new QorepayModelClientDetails();
5$client->email = '[email protected]';
6$purchase = new QorepayModelPurchase();
7$purchase->client = $client;
8$details = new QorepayModelPurchaseDetails();
9$product = new QorepayModelProduct();
10$product->name = 'Test';
11$product->price = 100;
12$details->products = [$product];
13$purchase->purchase = $details;
14$purchase->brand_id = $config['brand_id'];
15$purchase->success_redirect = 'https://gate.qorepay.com/api/v1/?success=1';
16$purchase->failure_redirect = 'https://gate.qorepay.com/api/v1/?success=0';
17
18$result = $api->createPurchase($purchase);
19
20if ($result && $result->checkout_url) {
21// Redirect user to checkout
22header("Location: " . $result->checkout_url);
23exit;
24}

Testing

1./vendor/bin/phpunit tests