Create a new refund request

Facades: merchant

Overview

Creates a new refund request.

Parameters

ParameterDescription
invoiceIdThe BitPay invoice Id having the associated refund to be created.
amountAmount to be refunded in the currency indicated.
currencyReference currency used for the refund, usually the same as the currency used.
previewWhether to create the refund request as a preview (which will not be acted on until status is updated)
immediateWhether funds should be removed from merchant ledger immediately on submission or at time of processing
buyerPaysRefundFeeWhether the buyer should pay the refund fee (default is merchant)

Example

$date = new \DateTime();
$today = $date->format("Y-m-d");
$dateBefore = $date->modify('-30 day');
$sevenDaysAgo = $dateBefore->format("Y-m-d");

$invoices = $bitpay->getInvoices($sevenDaysAgo, $today, InvoiceStatus::Complete);

$firstInvoice = $invoices[0];
$invoice = $bitpay->getInvoice($firstInvoice->getId());

$refunded = $bitpay->createRefund($invoice->getId(), 10.0, Currency::USD, true, false, false);