Added Update Method in Payment

- Payment allows update calls with patch requests
- Samples to demonstrate its abilities
This commit is contained in:
japatel
2014-12-17 12:47:22 -06:00
parent 39188ae395
commit 515b747223
5 changed files with 317 additions and 0 deletions

View File

@@ -438,6 +438,30 @@ class Payment extends ResourceModel
return $ret;
}
/**
* Partially update a payment resource by by passing the payment_id in the request URI. In addition, pass a patch_request_object in the body of the request JSON that specifies the operation to perform, path of the target location, and new value to apply. Please note that it is not possible to use patch after execute has been called.
*
* @param PatchRequest $patchRequest
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return boolean
*/
public function update($patchRequest, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($patchRequest, 'patchRequest');
$payLoad = $patchRequest->toJSON();
self::executeCall(
"/v1/payments/payment/{$this->getId()}",
"PATCH",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* Executes the payment (after approved by the Payer) associated with this resource when the payment method is PayPal.
*