From aed2b5594012ab910be24b09259387bf5d271f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Gon=C3=A7alves?= Date: Fri, 20 Sep 2019 09:33:31 -0300 Subject: [PATCH 1/4] Adjust doctrine/annotations required version The newer versions does not support PHP 5.6 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8330466f..b3012ee9 100755 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require": { "php": ">=5.5.0", "doctrine/common": "~2.6", - "doctrine/annotations": "~1.4" + "doctrine/annotations": "1.4" }, "require-dev": { "phpunit/phpunit": "^5", From d2deb889edfba43c3ec2c721bb7774d4e8acb6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Gon=C3=A7alves?= Date: Mon, 23 Sep 2019 11:09:53 -0300 Subject: [PATCH 2/4] Implementation of delete method Implemented delete method for Customer and Card Classes --- src/MercadoPago/Entities/Card.php | 2 +- src/MercadoPago/Entities/Customer.php | 2 +- src/MercadoPago/Entity.php | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/MercadoPago/Entities/Card.php b/src/MercadoPago/Entities/Card.php index e183c6a8..20baee90 100755 --- a/src/MercadoPago/Entities/Card.php +++ b/src/MercadoPago/Entities/Card.php @@ -9,7 +9,7 @@ * @RestMethod(resource="/v1/customers/:customer_id/cards", method="create") * @RestMethod(resource="/v1/customers/:customer_id/cards/:id", method="read") * @RestMethod(resource="/v1/customers/:customer_id/cards/:id", method="update") - * @RestMethod(resource="/v1/customers/:customer_id/cards/:id", method="destroy") + * @RestMethod(resource="/v1/customers/:customer_id/cards/:id", method="delete") * @RequestParam(param="access_token") */ diff --git a/src/MercadoPago/Entities/Customer.php b/src/MercadoPago/Entities/Customer.php index 3f10539e..eb32d559 100755 --- a/src/MercadoPago/Entities/Customer.php +++ b/src/MercadoPago/Entities/Customer.php @@ -10,7 +10,7 @@ * @RestMethod(resource="/v1/customers/search", method="search") * @RestMethod(resource="/v1/customers/", method="create") * @RestMethod(resource="/v1/customers/:id", method="update") - * @RestMethod(resource="/v1/customers/:id", method="remove") + * @RestMethod(resource="/v1/customers/:id", method="delete") * @RequestParam(param="access_token") */ diff --git a/src/MercadoPago/Entity.php b/src/MercadoPago/Entity.php index 598abf1a..fa21a43c 100755 --- a/src/MercadoPago/Entity.php +++ b/src/MercadoPago/Entity.php @@ -494,5 +494,26 @@ protected function _camelize($input, $separator = '_') { return str_replace($separator, '', ucwords($input, $separator)); } + + + public function delete($options = []) + { + $params = []; + self::$_manager->setEntityUrl($this, 'delete', $params); + + $response = self::$_manager->execute($this, 'delete'); + + if ($response['code'] == "200" || $response['code'] == "201") { + $this->_fillFromArray($this, $response['body']); + return true; + } elseif (intval($response['code']) >= 400 && intval($response['code']) < 500) { + if (!is_null($response['body'])){ + $this->process_error_body($response['body']); + } + return false; + } else { + throw new Exception ("Internal API Error"); + } + } } From 662f23ce0c6a0e4a0dff43977ae325dc5072b089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Gon=C3=A7alves?= Date: Mon, 23 Sep 2019 11:30:04 -0300 Subject: [PATCH 3/4] Added capture method for payments --- src/MercadoPago/Entities/Shared/Payment.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/MercadoPago/Entities/Shared/Payment.php b/src/MercadoPago/Entities/Shared/Payment.php index 2baa47b2..a4fb5983 100755 --- a/src/MercadoPago/Entities/Shared/Payment.php +++ b/src/MercadoPago/Entities/Shared/Payment.php @@ -304,14 +304,21 @@ public function refund($amount = 0){ if ($refund->save()){ $payment = self::get($this->id); - $this->refunds = $payment->refunds; - $this->status = $payment->status; - $this->status_detail = $payment->status_detail; - $this->transaction_amount_refunded = $payment->transaction_amount_refunded; + $this->_fillFromArray($this, $payment->toArray()); return true; }else{ $this->error = $refund->error; return false; } } + + public function capture($amount = 0) + { + $this->capture = true; + if ($amount > 0){ + $this->transaction_amount = $amount; + } + + return $this->update(); + } } From 084f32e9d167daa58a87461de0ff03d2b97c0dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Gon=C3=A7alves?= Date: Mon, 23 Sep 2019 11:43:10 -0300 Subject: [PATCH 4/4] Update version --- src/MercadoPago/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MercadoPago/Version.php b/src/MercadoPago/Version.php index 77b880e8..9b832cab 100755 --- a/src/MercadoPago/Version.php +++ b/src/MercadoPago/Version.php @@ -4,5 +4,5 @@ class Version { public static - $_VERSION = '1.4.1'; + $_VERSION = '1.5.0'; } \ No newline at end of file