<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TextUI\XmlConfiguration\Logging;
use PHPUnit\TextUI\XmlConfiguration\Exception;
use PHPUnit\TextUI\XmlConfiguration\Logging\TestDox\Html as TestDoxHtml;
use PHPUnit\TextUI\XmlConfiguration\Logging\TestDox\Text as TestDoxText;
use PHPUnit\TextUI\XmlConfiguration\Logging\TestDox\Xml as TestDoxXml;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*
* @psalm-immutable
*/
final class Logging
{
/**
* @var ?Junit
*/
private $junit;
/**
* @var ?Text
*/
private $text;
/**
* @var ?TeamCity
*/
private $teamCity;
/**
* @var ?TestDoxHtml
*/
private $testDoxHtml;
/**
* @var ?TestDoxText
*/
private $testDoxText;
/**
* @var ?TestDoxXml
*/
private $testDoxXml;
public function __construct(?Junit $junit, ?Text $text, ?TeamCity $teamCity, ?TestDoxHtml $testDoxHtml, ?TestDoxText $testDoxText, ?TestDoxXml $testDoxXml)
{
$this->junit = $junit;
$this->text = $text;
$this->teamCity = $teamCity;
$this->testDoxHtml = $testDoxHtml;
$this->testDoxText = $testDoxText;
$this->testDoxXml = $testDoxXml;
}
public function hasJunit(): bool
{
return $this->junit !== null;
}
public function junit(): Junit
{
if ($this->junit === null) {
throw new Exception('Logger "JUnit XML" is not configured');
}
return $this->junit;
}
public function hasText(): bool
{
return $this->text !== null;
}
public function text(): Text
{
if ($this->text === null) {
throw new Exception('Logger "Text" is not configured');
}
return $this->text;
}
public function hasTeamCity(): bool
{
return $this->teamCity !== null;
}
public function teamCity(): TeamCity
{
if ($this->teamCity === null) {
throw new Exception('Logger "Team City" is not configured');
}
return $this->teamCity;
}
public function hasTestDoxHtml(): bool
{
return $this->testDoxHtml !== null;
}
public function testDoxHtml(): TestDoxHtml
{
if ($this->testDoxHtml === null) {
throw new Exception('Logger "TestDox HTML" is not configured');
}
return $this->testDoxHtml;
}
public function hasTestDoxText(): bool
{
return $this->testDoxText !== null;
}
public function testDoxText(): TestDoxText
{
if ($this->testDoxText === null) {
throw new Exception('Logger "TestDox Text" is not configured');
}
return $this->testDoxText;
}
public function hasTestDoxXml(): bool
{
return $this->testDoxXml !== null;
}
public function testDoxXml(): TestDoxXml
{
if ($this->testDoxXml === null) {
throw new Exception('Logger "TestDox XML" is not configured');
}
return $this->testDoxXml;
}
}
Initiates a new payment transaction.
create-order
| Parameter | Type | Details |
|---|---|---|
| amount | decimal | Your Amount , Must be rounded at 2 precision. |
| currency | string | Currency Code, Must be in Upper Case (Alpha-3 code) |
| success_url | string | Enter your return or success URL |
| cancel_url | string (optional) | Enter your cancel or failed URL |
Request Example (guzzle)
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', $base_url.'create-order', [
'headers' => [
'Authorization' => 'Bearer '. $authorizationToken,
'accept' => 'application/json',
'content-type' => 'application/json',
],
'form_params' => [
'amount' => '$amount',
'currency' => 'currency',
'success_url' => 'success_url',
'cancel_url' => 'cancel_url',
],
]);
echo $response->getBody();
**Response: SUCCESS (200 OK)**
{
"message": {
"success": [
"Order created successfully."
]
},
"data": {
"redirect_url":"https://example.com/login/OISADFDFSDFSF",
"order_details":{
"amount" : "10",
"fixed_charge" : 2,
"percent_charge" : 1,
"total_charge" : 3,
"total_payable" : 13,
"currency" : "USD",
"expiry_time": "2024-04-25T06:48:35.984285Z",
"success_url": "http://127.0.0.1/nfcpay/user/transaction/success",
"cancel_url": "http://127.0.0.1/nfcpay/user/transaction/cancel"
}
},
"type": "success"
}
**Response: ERROR (400 FAILED)**
{
"message": {
"error": [
"Invalid token."
]
},
"data": null,
"type": "error"
}