You are here

public function Mollie_API_Resource_Payments::refund in Commerce Mollie 7

Parameters

Mollie_API_Object_Payment $payment:

Return value

Mollie_API_Object_Payment_Refund

File

Mollie/API/Resource/Payments.php, line 49

Class

Mollie_API_Resource_Payments
Copyright (c) 2013, Mollie B.V. All rights reserved.

Code

public function refund(Mollie_API_Object_Payment $payment) {
  $resource = "{$this->getResourceName()}/" . urlencode($payment->id) . "/refunds";
  $result = $this
    ->performApiCall(self::REST_CREATE, $resource, new stdClass());

  /*
   * Update the payment with the new properties that we got from the refund.
   */
  if (!empty($result->payment)) {
    foreach ($result->payment as $payment_key => $payment_value) {
      $payment->{$payment_key} = $payment_value;
    }
  }
  return $this
    ->copy($result, new Mollie_API_Object_Payment_Refund());
}