From 024530ad582092c4ca6ef6e620abb89b78195a82 Mon Sep 17 00:00:00 2001 From: beefcakefu <103491197+beefcakefu@users.noreply.github.com> Date: Thu, 30 Jun 2022 14:00:00 +0800 Subject: [PATCH 1/2] Update sandbox endpoint and versioning scheme Sandbox endpoint has been moved and versioning scheme has been changed according to https://hit-pay.com/docs.html. This commit reflects those changes. --- HitPay.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HitPay.php b/HitPay.php index db7fb83..19d1b39 100644 --- a/HitPay.php +++ b/HitPay.php @@ -4,11 +4,11 @@ class HitPay { - const version = '1'; + const version = 'v1'; protected $curl; protected $endpoint = 'https://api.hit-pay.com/'; - protected $endpointSandbox = 'https://api.staging.hit-pay.com/'; + protected $endpointSandbox = 'https://api.sandbox.hit-pay.com/'; protected $apiKey = null; protected $authToken = null; protected $isSandBox = false; From 3e856b29f819ac885bc500d81fa1fba959b27007 Mon Sep 17 00:00:00 2001 From: beefcakefu <103491197+beefcakefu@users.noreply.github.com> Date: Fri, 1 Jul 2022 13:45:50 +0800 Subject: [PATCH 2/2] Update error detection in payment request As according to https://hit-pay.com/docs.html, response no longer includes 'success' and 'message' keys. Updating error handling to check for existence of 'errors' key, throwing an exception with JSON encoded 'errors' array as its message if found, or return the response object. --- HitPay.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HitPay.php b/HitPay.php index 19d1b39..b7d35c4 100644 --- a/HitPay.php +++ b/HitPay.php @@ -113,8 +113,8 @@ private function api_call($method, $path, array $data=null) } } - if ($responseObj['success'] == false) { - $message = json_encode($responseObj['message']); + if (isset($responseObj['errors']) { + $message = json_encode($responseObj['errors']); throw new \Exception($message . PHP_EOL); }