Skip to content

Commit

Permalink
Merge pull request #13 from victorighalo/develop
Browse files Browse the repository at this point in the history
fix: bug fixes for post and put requests
  • Loading branch information
seerbit-developers authored Mar 15, 2023
2 parents b787506 + 27cd613 commit a9e167c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":1,"defects":{"Seerbit\\Request\\StandardTest::testInitialize":7,"Seerbit\\Request\\ValidationTest::testTransactionValidateStatus":8,"Seerbit\\Request\\ValidationTest::testSubscriptionValidateStatus":8,"Seerbit\\Request\\ResourcesTest::testBanksList":8,"Seerbit\\Request\\OrderTest::testCreateOrder":7,"Seerbit\\Request\\RecurrentValidationTest::testSubscriptionValidateStatus":8},"times":{"Seerbit\\Request\\TokenizeTest::testTokenize":9.791,"Seerbit\\Request\\StandardTest::testInitialize":2.065,"Seerbit\\Request\\ValidationTest::testTransactionValidateStatus":2.981,"Seerbit\\Request\\ValidationTest::testSubscriptionValidateStatus":1.333,"Seerbit\\Request\\ResourcesTest::testBanksList":0.741,"Seerbit\\Request\\OrderTest::testCreateOrder":0.604,"Seerbit\\Request\\RecurrentValidationTest::testSubscriptionValidateStatus":1.443}}
{"version":1,"defects":{"Seerbit\\Request\\StandardTest::testInitialize":7,"Seerbit\\Request\\ValidationTest::testTransactionValidateStatus":8,"Seerbit\\Request\\ValidationTest::testSubscriptionValidateStatus":8,"Seerbit\\Request\\ResourcesTest::testBanksList":8,"Seerbit\\Request\\OrderTest::testCreateOrder":7,"Seerbit\\Request\\RecurrentValidationTest::testSubscriptionValidateStatus":8},"times":{"Seerbit\\Request\\TokenizeTest::testTokenize":9.791,"Seerbit\\Request\\StandardTest::testInitialize":1.059,"Seerbit\\Request\\ValidationTest::testTransactionValidateStatus":2.981,"Seerbit\\Request\\ValidationTest::testSubscriptionValidateStatus":1.333,"Seerbit\\Request\\ResourcesTest::testBanksList":0.741,"Seerbit\\Request\\OrderTest::testCreateOrder":0.604,"Seerbit\\Request\\RecurrentValidationTest::testSubscriptionValidateStatus":1.443}}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@

## 2.3.4 - 2023-03-13
- Update transaction status validation

## 2.3.5 - 2023-03-15
- Bug fixes
6 changes: 3 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</testsuite>
</testsuites>
<php>
<env name="SEERBIT_PUBLIC_KEY" value="SBPUBK_R0RRJIOLOICPJVDF5PLZTTUAOKHBCBXF"/>
<env name="SEERBIT_SECRET_KEY" value="SBSECK_VZZXPRI2ZB5D4D4GJRTQZO3SCCGYMUY4ZCVZYJLA"/>
<env name="SEERBIT_TOKEN" value="MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+"/>
<env name="SEERBIT_PUBLIC_KEY" value=""/>
<env name="SEERBIT_SECRET_KEY" value=""/>
<env name="SEERBIT_TOKEN" value=""/>
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/Seerbit/HttpClient/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class CurlClient implements IClient
{

protected bool $shouldLog = false;
protected bool $shouldLog = true;
/**
* @throws SeerbitException
*/
Expand Down
32 changes: 24 additions & 8 deletions src/Seerbit/Service/TransactionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
namespace Seerbit\Service;

use \Seerbit\HttpClient\CurlClient;
use Seerbit\SeerbitException;

class TransactionService implements IService
{

protected $client;
protected \Seerbit\Client $client;

private $httpClient;
private CurlClient $httpClient;

protected $requiresToken = false;
protected bool $requiresToken = false;

/**
* @throws SeerbitException
*/
public function __construct(\Seerbit\Client $client)
{

Expand Down Expand Up @@ -41,12 +45,16 @@ public function __construct(\Seerbit\Client $client)
$this->client = $client;
}

public function getClient()
public function getClient(): \Seerbit\Client
{
return $this->client;
}

protected function postRequest($endpoint,$path){
/**
* @throws SeerbitException
*/
protected function postRequest($path, $params): array
{
return $this->httpClient->POST(
$this,
$this->client->getConfig()->get('endpoint') . $path,
Expand All @@ -56,7 +64,11 @@ protected function postRequest($endpoint,$path){
);
}

protected function getRequest($path){
/**
* @throws SeerbitException
*/
protected function getRequest($path): array
{
return $this->httpClient->GET(
$this,
$this->client->getConfig()->get('endpoint') . $path,
Expand All @@ -65,7 +77,11 @@ protected function getRequest($path){
);
}

protected function putRequest($endpoint,$path){
/**
* @throws SeerbitException
*/
protected function putRequest($path, $params): array
{
return $this->httpClient->POST(
$this,
$this->client->getConfig()->get('endpoint') . $path,
Expand All @@ -76,7 +92,7 @@ protected function putRequest($endpoint,$path){
}


public function requiresToken()
public function requiresToken(): bool
{
return $this->requiresToken;
}
Expand Down
50 changes: 15 additions & 35 deletions tests/Request/seerbit.log
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
[2023-03-09T12:54:53.851959+00:00] seerbit-php-api-library.INFO: Request url to SeerBit: https://seerbitapi.com/api/v3/payments/query/6431082077214616733024 [] []
[2023-03-09T12:54:53.852752+00:00] seerbit-php-api-library.INFO: JSON Request payload to SeerBit:null [] []
[2023-03-09T12:54:53.853440+00:00] seerbit-php-api-library.INFO: Request headers to SeerbitArray ( [0] => Authorization: Bearer MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+ ) [] []
[2023-03-09T12:54:54.974458+00:00] seerbit-php-api-library.INFO: JSON Response is: { "message" : "Invalid Authentication Token", "error" : "INPUT" } [] []
[2023-03-09T12:54:54.974698+00:00] seerbit-php-api-library.ERROR: Invalid Authentication Token [] []
[2023-03-09T12:54:54.990167+00:00] seerbit-php-api-library.INFO: Request url to SeerBit: https://seerbitapi.com/api/v2/recurring/billingId/6431082077214616733024 [] []
[2023-03-09T12:54:54.990230+00:00] seerbit-php-api-library.INFO: JSON Request payload to SeerBit:null [] []
[2023-03-09T12:54:54.990253+00:00] seerbit-php-api-library.INFO: Request headers to SeerbitArray ( [0] => Authorization: Bearer MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+ ) [] []
[2023-03-09T12:57:55.429041+00:00] seerbit-php-api-library.INFO: JSON Response is: <html> <head><title>504 Gateway Time-out</title></head> <body> <center><h1>504 Gateway Time-out</h1></center> </body> </html> [] []
[2023-03-09T12:57:55.430413+00:00] seerbit-php-api-library.ERROR: <html> <head><title>504 Gateway Time-out</title></head> <body> <center><h1>504 Gateway Time-out</h1></center> </body> </html> [] []
[2023-03-13T07:50:18.533195+00:00] seerbit-php-api-library.INFO: Request url to SeerBit: https://seerbitapi.com/api/v3/payments/query/6431082077214616733024 [] []
[2023-03-13T07:50:18.535704+00:00] seerbit-php-api-library.INFO: JSON Request payload to SeerBit:null [] []
[2023-03-13T07:50:18.536384+00:00] seerbit-php-api-library.INFO: Request headers to SeerbitArray ( [0] => Authorization: Bearer MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+ ) [] []
[2023-03-13T07:50:21.268613+00:00] seerbit-php-api-library.INFO: JSON Response is: { "message" : "Invalid Authentication Token", "error" : "INPUT" } [] []
[2023-03-13T07:50:21.268841+00:00] seerbit-php-api-library.ERROR: Invalid Authentication Token [] []
[2023-03-13T07:50:21.285077+00:00] seerbit-php-api-library.INFO: Request url to SeerBit: https://seerbitapi.com/api/v2/recurring/billingId/6431082077214616733024 [] []
[2023-03-13T07:50:21.285137+00:00] seerbit-php-api-library.INFO: JSON Request payload to SeerBit:null [] []
[2023-03-13T07:50:21.285161+00:00] seerbit-php-api-library.INFO: Request headers to SeerbitArray ( [0] => Authorization: Bearer MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+ ) [] []
[2023-03-13T07:50:22.616479+00:00] seerbit-php-api-library.INFO: JSON Response is: { "message" : "Confirm Merchant Environment", "error" : "PERMISSION" } [] []
[2023-03-13T07:50:22.616555+00:00] seerbit-php-api-library.ERROR: Confirm Merchant Environment [] []
[2023-03-13T08:00:08.217295+00:00] seerbit-php-api-library.INFO: Request url to SeerBit: https://seerbitapi.com/api/v3/payments/query/SBT-T78693956103 [] []
[2023-03-13T08:00:08.218793+00:00] seerbit-php-api-library.INFO: JSON Request payload to SeerBit:null [] []
[2023-03-13T08:00:08.218969+00:00] seerbit-php-api-library.INFO: Request headers to SeerbitArray ( [0] => Authorization: Bearer MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+ ) [] []
[2023-03-13T08:00:11.177410+00:00] seerbit-php-api-library.INFO: JSON Response is: { "status" : "SUCCESS", "data" : { "code" : "00", "message" : "Successful", "payments" : { "redirectLink" : "https://checkout.seerbitapi.com/#/", "amount" : 5.07, "fee" : "0.07", "mobilenumber" : "404", "publicKey" : "SBPUBK_R0RRJIOLOICPJVDF5PLZTTUAOKHBCBXF", "paymentType" : "CARD", "productId" : "", "maskedPan" : "4105-40xx-xxxx-0739", "gatewayMessage" : "Successful", "gatewayCode" : "00", "gatewayref" : "SEERBIT894365961678694004220", "businessName" : "Jack Sparrow Test Ent", "mode" : "live", "redirecturl" : "https://checkout.seerbitapi.com/#/", "channelType" : "VISA", "sourceIP" : "154.113.161.130", "deviceType" : "Desktop", "cardBin" : "410540", "lastFourDigits" : "0739", "country" : "NG", "currency" : "NGN", "paymentReference" : "SBT-T78693956103", "reason" : "Successful", "initiationTime" : "2023-03-13 08:53:22.737", "completionTime" : "2023-03-13 08:54:24.229", "transactionProcessedTime" : "2023-03-13 08:53:22.737", "expiryMonth" : "11", "expiryYear" : "24", "cardKey" : "9d71beff03b1e01eece7aea63a339bcc258efa48de3dc6ba3624c30c43a5d5fb" }, "customers" : { "customerId" : "SBT3a4ece2fc3d42ee9c975", "customerName" : "Joe Sharper", "customerMobile" : "404", "customerEmail" : "[email protected]", "fee" : "0.07" } } } [] []
[2023-03-13T08:00:11.177800+00:00] seerbit-php-api-library.INFO: Params in response from Seerbit:{ "status" : "SUCCESS", "data" : { "code" : "00", "message" : "Successful", "payments" : { "redirectLink" : "https://checkout.seerbitapi.com/#/", "amount" : 5.07, "fee" : "0.07", "mobilenumber" : "404", "publicKey" : "SBPUBK_R0RRJIOLOICPJVDF5PLZTTUAOKHBCBXF", "paymentType" : "CARD", "productId" : "", "maskedPan" : "4105-40xx-xxxx-0739", "gatewayMessage" : "Successful", "gatewayCode" : "00", "gatewayref" : "SEERBIT894365961678694004220", "businessName" : "Jack Sparrow Test Ent", "mode" : "live", "redirecturl" : "https://checkout.seerbitapi.com/#/", "channelType" : "VISA", "sourceIP" : "154.113.161.130", "deviceType" : "Desktop", "cardBin" : "410540", "lastFourDigits" : "0739", "country" : "NG", "currency" : "NGN", "paymentReference" : "SBT-T78693956103", "reason" : "Successful", "initiationTime" : "2023-03-13 08:53:22.737", "completionTime" : "2023-03-13 08:54:24.229", "transactionProcessedTime" : "2023-03-13 08:53:22.737", "expiryMonth" : "11", "expiryYear" : "24", "cardKey" : "9d71beff03b1e01eece7aea63a339bcc258efa48de3dc6ba3624c30c43a5d5fb" }, "customers" : { "customerId" : "SBT3a4ece2fc3d42ee9c975", "customerName" : "Joe Sharper", "customerMobile" : "404", "customerEmail" : "[email protected]", "fee" : "0.07" } } } [] []
[2023-03-13T08:01:47.685971+00:00] seerbit-php-api-library.INFO: Request url to SeerBit: https://seerbitapi.com/api/v2/recurring/billingId/SBT-R72515278662RECURRENT2023-02-2810:00:00.401 [] []
[2023-03-13T08:01:47.687064+00:00] seerbit-php-api-library.INFO: JSON Request payload to SeerBit:null [] []
[2023-03-13T08:01:47.687208+00:00] seerbit-php-api-library.INFO: Request headers to SeerbitArray ( [0] => Authorization: Bearer MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+ ) [] []
[2023-03-13T08:01:50.234725+00:00] seerbit-php-api-library.INFO: JSON Response is: { "message" : "Confirm Merchant Environment", "error" : "PERMISSION" } [] []
[2023-03-13T08:01:50.234925+00:00] seerbit-php-api-library.ERROR: Confirm Merchant Environment [] []
[2023-03-13T08:34:24.827764+00:00] seerbit-php-api-library.INFO: Request url to SeerBit: https://seerbitapi.com/api/v2/recurring/billingId/SBT-R78694421820 [] []
[2023-03-13T08:34:24.829252+00:00] seerbit-php-api-library.INFO: JSON Request payload to SeerBit:null [] []
[2023-03-13T08:34:24.830030+00:00] seerbit-php-api-library.INFO: Request headers to SeerbitArray ( [0] => Authorization: Bearer MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+ ) [] []
[2023-03-13T08:34:26.246457+00:00] seerbit-php-api-library.INFO: JSON Response is: { "message" : "Confirm Merchant Environment", "error" : "PERMISSION" } [] []
[2023-03-13T08:34:26.246882+00:00] seerbit-php-api-library.ERROR: Confirm Merchant Environment [] []
[2023-03-15T16:50:41.968226+00:00] seerbit-php-api-library.INFO: Request url to SeerBit: https://seerbitapi.com/api/v2/Array [] []
[2023-03-15T16:50:41.969205+00:00] seerbit-php-api-library.INFO: JSON Request payload to SeerBit:null [] []
[2023-03-15T16:50:41.969246+00:00] seerbit-php-api-library.INFO: Request headers to SeerBitArray ( [0] => Content-Type: application/json [1] => Authorization: Bearer MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+ ) [] []
[2023-03-15T16:50:42.618281+00:00] seerbit-php-api-library.INFO: JSON Response is: { "timestamp" : "2023-03-15T16:50:42.673+0000", "status" : 404, "error" : "Not Found", "path" : "/api/v2/Array" } [] []
[2023-03-15T16:50:42.618369+00:00] seerbit-php-api-library.INFO: Params in response from SeerBit: Array ( [timestamp] => 2023-03-15T16:50:42.673+0000 [status] => 404 [error] => Not Found [path] => /api/v2/Array ) [] []
[2023-03-15T16:53:37.725886+00:00] seerbit-php-api-library.INFO: Request url to SeerBit: https://seerbitapi.com/api/v2/payments [] []
[2023-03-15T16:53:37.727142+00:00] seerbit-php-api-library.INFO: JSON Request payload to SeerBit:{"amount":"1000","callbackUrl":"http:yourwebsite.com","country":"NG","currency":"NGN","email":"[email protected]","paymentReference":"AAE45BD4530B","productDescription":"product_description","productId":"64310880-2708933-427","tokenize":true,"publicKey":"SBPUBK_R0RRJIOLOICPJVDF5PLZTTUAOKHBCBXF","hash":"37285cf419553d3e70628f50a0b3662e654fca470b8de210eaaa94ee72d297f8","hashType":"sha256"} [] []
[2023-03-15T16:53:37.727192+00:00] seerbit-php-api-library.INFO: Request headers to SeerBitArray ( [0] => Content-Type: application/json [1] => Authorization: Bearer MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+ ) [] []
[2023-03-15T16:53:38.822546+00:00] seerbit-php-api-library.INFO: JSON Response is: { "status" : "SUCCESS", "data" : { "code" : "00", "payments" : { "redirectLink" : "https://checkout.seerbitapi.com/?mid=SBPUBK_R0RRJIOLOICPJVDF5PLZTTUAOKHBCBXF&paymentReference=AAE45BD4530B", "paymentStatus" : "08" }, "message" : "Successful" } } [] []
[2023-03-15T16:53:38.822670+00:00] seerbit-php-api-library.INFO: Params in response from SeerBit: Array ( [status] => SUCCESS [data] => Array ( [code] => 00 [payments] => Array ( [redirectLink] => https://checkout.seerbitapi.com/?mid=SBPUBK_R0RRJIOLOICPJVDF5PLZTTUAOKHBCBXF&paymentReference=AAE45BD4530B [paymentStatus] => 08 ) [message] => Successful ) ) [] []
[2023-03-15T16:54:37.479939+00:00] seerbit-php-api-library.INFO: Request url to SeerBit: https://seerbitapi.com/api/v2/payments [] []
[2023-03-15T16:54:37.480639+00:00] seerbit-php-api-library.INFO: JSON Request payload to SeerBit:{"amount":"1000","callbackUrl":"http:yourwebsite.com","country":"NG","currency":"NGN","email":"[email protected]","paymentReference":"6ABD799A65FC","productDescription":"product_description","productId":"64310880-2708933-427","tokenize":true,"publicKey":"SBPUBK_R0RRJIOLOICPJVDF5PLZTTUAOKHBCBXF","hash":"6eebeada1042b314f039b492fe5179f7d897a05108fd8fbdca5e092f5ade948d","hashType":"sha256"} [] []
[2023-03-15T16:54:37.480677+00:00] seerbit-php-api-library.INFO: Request headers to SeerBitArray ( [0] => Content-Type: application/json [1] => Authorization: Bearer MuWdxMou5My6cw8OS/dhOn9zg7LBXQ5cFvK+8xxBad8wolEa1cnepf57Om2YSmZ3DoZ4QWA6HKm0ffV9P/kQHFESYy6fEs6VQKQ0ytYJPztCBFPJfYSztA1ksmKwsOr+ ) [] []
[2023-03-15T16:54:38.526094+00:00] seerbit-php-api-library.INFO: JSON Response is: { "status" : "SUCCESS", "data" : { "code" : "00", "payments" : { "redirectLink" : "https://checkout.seerbitapi.com/?mid=SBPUBK_R0RRJIOLOICPJVDF5PLZTTUAOKHBCBXF&paymentReference=6ABD799A65FC", "paymentStatus" : "08" }, "message" : "Successful" } } [] []
[2023-03-15T16:54:38.526329+00:00] seerbit-php-api-library.INFO: Params in response from SeerBit: Array ( [status] => SUCCESS [data] => Array ( [code] => 00 [payments] => Array ( [redirectLink] => https://checkout.seerbitapi.com/?mid=SBPUBK_R0RRJIOLOICPJVDF5PLZTTUAOKHBCBXF&paymentReference=6ABD799A65FC [paymentStatus] => 08 ) [message] => Successful ) ) [] []

0 comments on commit a9e167c

Please sign in to comment.