Skip to content

Commit 8e5d1a6

Browse files
author
Stefan Richter
committed
Fix duplicate definition of remove_payment
1 parent 43fb72c commit 8e5d1a6

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

figo/Session.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,23 +368,22 @@ public function modify_payment($payment) {
368368
return (is_null($response) ? null : new Payment($this, $response));
369369
}
370370

371-
/**
372-
* Delete payment.
373-
*
374-
* @param Payment payment object which should be deleted
375-
*/
376-
public function remove_payment($payment) {
377-
$this->query_api("/rest/accounts/".$payment->account_id."/payments/".$payment->payment_id, null, "DELETE");
378-
}
379-
380371
/**
381372
* Delete payment.
382373
*
383374
* @param string ID of the account on which the payment can be found
384-
* @param string ID of the payment to be deleted
375+
* @param string ID of the payment to be deleted (or null when using a payment instance as first parameter)
385376
*/
386-
public function remove_payment($account_id, $payment_id) {
387-
$this->query_api("/rest/accounts/".$account_id."/payments/".$payment_id, null, "DELETE");
377+
public function remove_payment($account_id_or_payment, $payment_id=null) {
378+
if(is_string($account_id_or_payment)) {
379+
if(is_string($payment_id)) {
380+
$this->query_api("/rest/accounts/".$account_id_or_payment."/payments/".$payment_id, null, "DELETE");
381+
} else {
382+
throw new Exception('invalid_request', 'Missing payment_id parameter');
383+
}
384+
} else {
385+
$this->query_api("/rest/accounts/".$account_id_or_payment->account_id."/payments/".$account_id_or_payment->payment_id, null, "DELETE");
386+
}
388387
}
389388

390389
/**

0 commit comments

Comments
 (0)