diff --git a/composer.json b/composer.json index 3269bd9..1136beb 100755 --- a/composer.json +++ b/composer.json @@ -1,12 +1,15 @@ { "name": "moyasar/moyasar-php", - "description": "php api wrapper for moyasar.com", + "description": "PHP wrapper library for Moyasar Payment Service", "type": "library", "authors": [ { "name": "Sohib H Algotimel", "email": "s@sgh.sa", "homepage": "https://sgh.sa" + }, + { + "name": "Moyasar Dev Team" } ], "minimum-stability": "dev", diff --git a/src/Moyasar/Client.php b/src/Moyasar/Client.php index 6c2fbcc..328609b 100755 --- a/src/Moyasar/Client.php +++ b/src/Moyasar/Client.php @@ -57,6 +57,22 @@ public static function post($request, $options = []) throw new HttpRequestNotFound($response->getStatusCode() . ' status code returned'); } + public static function put($url,$options = []) + { + $client = new GuzzleHttp\Client(); + $data = [ + GuzzleHttp\RequestOptions::AUTH => [self::$apiKey, ''], + GuzzleHttp\RequestOptions::FORM_PARAMS => $options, + GuzzleHttp\RequestOptions::DEBUG => false + ]; + + $response = $client->put($url, $data); + if ($response->getStatusCode() == '200' OR '201') { + return $response->getBody()->getContents(); + } + throw new HttpRequestNotFound($response->getStatusCode() . ' status code returned'); + } + } diff --git a/src/Moyasar/Invoice.php b/src/Moyasar/Invoice.php index 09642f3..5ae51cd 100644 --- a/src/Moyasar/Invoice.php +++ b/src/Moyasar/Invoice.php @@ -35,5 +35,13 @@ public static function all(){ return json_decode(Client::get("https://api.moyasar.com/v1/invoices")); } + public static function update($id,$parameter = [] ){ + return json_decode(Client::put("https://api.moyasar.com/v1/invoices/$id", $parameter)); + } + + public static function cancel($id){ + return json_decode(Client::put("https://api.moyasar.com/v1/invoices/$id/cancel")); + } + } diff --git a/src/Moyasar/Payment.php b/src/Moyasar/Payment.php index 48db14c..a8e0025 100644 --- a/src/Moyasar/Payment.php +++ b/src/Moyasar/Payment.php @@ -8,7 +8,6 @@ namespace Moyasar; - class Payment { const AMOUNT = "amount"; @@ -110,5 +109,11 @@ public static function all(){ } + public static function update($id, $description = ""){ + $data = [ + self::DESCRIPTION => $description + ]; + return json_decode(Client::put("https://api.moyasar.com/v1/payments/$id", $data)); + } }