Skip to content

Commit

Permalink
Merge pull request #221 from phgoncalves/master
Browse files Browse the repository at this point in the history
Add delete function
  • Loading branch information
Pedro Gonçalves committed Sep 23, 2019
2 parents 55b69bc + 084f32e commit e8764a9
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Entities/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -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")
*/

Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Entities/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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")
*/

Expand Down
15 changes: 11 additions & 4 deletions src/MercadoPago/Entities/Shared/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
21 changes: 21 additions & 0 deletions src/MercadoPago/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}

2 changes: 1 addition & 1 deletion src/MercadoPago/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
class Version
{
public static
$_VERSION = '1.4.1';
$_VERSION = '1.5.0';
}

0 comments on commit e8764a9

Please sign in to comment.