Charge.php
3 years ago
Create_Customer.php
4 years ago
Create_Customer_Card.php
4 years ago
Create_PayOrder.php
2 years ago
Create_Payment.php
2 years ago
Get_Customer.php
3 years ago
Get_Gift_Card.php
2 years ago
Refund.php
4 years ago
Search_Orders.php
10 months ago
Refund.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WooCommerce\Square\Gateway\API\Responses; |
| 4 | |
| 5 | defined( 'ABSPATH' ) || exit; |
| 6 | |
| 7 | /** |
| 8 | * The refund API response object. |
| 9 | * |
| 10 | * @since 2.0.0 |
| 11 | * |
| 12 | * @method \Square\Models\CreateRefundResponse|\Square\Models\GetPaymentRefundResponse get_data() |
| 13 | */ |
| 14 | class Refund extends \WooCommerce\Square\Gateway\API\Response { |
| 15 | |
| 16 | /** |
| 17 | * Determines if the transaction was approved. |
| 18 | * |
| 19 | * @since 2.0.0 |
| 20 | * |
| 21 | * @return bool |
| 22 | */ |
| 23 | public function transaction_approved() { |
| 24 | return parent::transaction_approved() && ( in_array( $this->get_status_code(), array( 'APPROVED', 'COMPLETED', 'PENDING' ), true ) ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Gets the transaction ID. |
| 29 | * |
| 30 | * @since 2.0.0 |
| 31 | * |
| 32 | * @return string |
| 33 | */ |
| 34 | public function get_transaction_id() { |
| 35 | |
| 36 | return $this->get_data() && $this->get_data()->getRefund() ? $this->get_data()->getRefund()->getId() : ''; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Gets the response status code. |
| 41 | * |
| 42 | * @since 2.0.0 |
| 43 | * |
| 44 | * @return string |
| 45 | */ |
| 46 | public function get_status_code() { |
| 47 | |
| 48 | if ( ! $this->has_errors() && $this->get_data() ) { |
| 49 | $code = $this->get_data()->getRefund()->getStatus(); |
| 50 | } else { |
| 51 | $code = parent::get_status_code(); |
| 52 | } |
| 53 | |
| 54 | return $code; |
| 55 | } |
| 56 | } |
| 57 |