File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed
Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff 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 /**
You can’t perform that action at this time.
0 commit comments