mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
PSR-4 is much more robust and predictable. But to do this, a source root dir must be specified for every module. This could be done in the root file, but this is not very modular. Instead, now every module declares its own source root by using the amazing Composer Merge Plugin. This approach allows each module to also declare its own dependencies. Together, these changes allow modules to be easily extractable to separate pacakges when the need arises, and in general improves modularity significantly.
118 lines
1.9 KiB
PHP
118 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* The refund object.
|
|
*
|
|
* @package WooCommerce\PayPalCommerce\ApiClient\Entity
|
|
*/
|
|
|
|
declare( strict_types=1 );
|
|
|
|
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
|
|
|
/**
|
|
* Class Refund
|
|
*/
|
|
class Refund {
|
|
|
|
/**
|
|
* The Capture.
|
|
*
|
|
* @var Capture
|
|
*/
|
|
private $capture;
|
|
|
|
/**
|
|
* The invoice id.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $invoice_id;
|
|
|
|
/**
|
|
* The note to the payer.
|
|
*
|
|
* @var string
|
|
*/
|
|
private $note_to_payer;
|
|
|
|
/**
|
|
* The Amount.
|
|
*
|
|
* @var Amount|null
|
|
*/
|
|
private $amount;
|
|
|
|
/**
|
|
* Refund constructor.
|
|
*
|
|
* @param Capture $capture The capture where the refund is supposed to be applied at.
|
|
* @param string $invoice_id The invoice id.
|
|
* @param string $note_to_payer The note to the payer.
|
|
* @param Amount|null $amount The Amount.
|
|
*/
|
|
public function __construct(
|
|
Capture $capture,
|
|
string $invoice_id,
|
|
string $note_to_payer = '',
|
|
Amount $amount = null
|
|
) {
|
|
$this->capture = $capture;
|
|
$this->invoice_id = $invoice_id;
|
|
$this->note_to_payer = $note_to_payer;
|
|
$this->amount = $amount;
|
|
}
|
|
|
|
/**
|
|
* Returns the capture for the refund.
|
|
*
|
|
* @return Capture
|
|
*/
|
|
public function for_capture() : Capture {
|
|
return $this->capture;
|
|
}
|
|
|
|
/**
|
|
* Return the invoice id.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function invoice_id() : string {
|
|
return $this->invoice_id;
|
|
}
|
|
|
|
/**
|
|
* Returns the note to the payer.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function note_to_payer() : string {
|
|
return $this->note_to_payer;
|
|
}
|
|
|
|
/**
|
|
* Returns the Amount.
|
|
*
|
|
* @return Amount|null
|
|
*/
|
|
public function amount() {
|
|
return $this->amount;
|
|
}
|
|
|
|
/**
|
|
* Returns the object as array.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function to_array() : array {
|
|
$data = array(
|
|
'invoice_id' => $this->invoice_id(),
|
|
);
|
|
if ( $this->note_to_payer() ) {
|
|
$data['note_to_payer'] = $this->note_to_payer();
|
|
}
|
|
if ( $this->amount() ) {
|
|
$data['amount'] = $this->amount()->to_array();
|
|
}
|
|
return $data;
|
|
}
|
|
}
|