|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\MyPay\Message; |
| 4 | + |
| 5 | +use Omnipay\MyPay\Encryption; |
| 6 | +use Omnipay\MyPay\Traits\HasCost; |
| 7 | +use Omnipay\MyPay\Traits\HasKey; |
| 8 | +use Omnipay\MyPay\Traits\HasStore; |
| 9 | +use Omnipay\MyPay\Traits\HasUid; |
| 10 | + |
| 11 | +class RefundRequest extends AbstractRequest |
| 12 | +{ |
| 13 | + use HasStore; |
| 14 | + use HasUid; |
| 15 | + use HasKey; |
| 16 | + use HasCost; |
| 17 | + |
| 18 | + /** |
| 19 | + * 4.作廢或作廢重開(預設) |
| 20 | + * 6.折讓 如有電子發票此欄位有效. |
| 21 | + * |
| 22 | + * @param int $value |
| 23 | + * @return $this |
| 24 | + */ |
| 25 | + public function setInvoiceState($value) |
| 26 | + { |
| 27 | + return $this->setParameter('invoice_state', $value); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * @return int |
| 32 | + */ |
| 33 | + public function getInvoiceState() |
| 34 | + { |
| 35 | + return $this->getParameter('invoice_state') ?: 4; |
| 36 | + } |
| 37 | + |
| 38 | + public function getData() |
| 39 | + { |
| 40 | + $this->validate('key', 'uid', 'amount'); |
| 41 | + |
| 42 | + return [ |
| 43 | + 'key' => $this->getKey(), |
| 44 | + 'uid' => $this->getUid(), |
| 45 | + 'cost' => $this->getAmount(), |
| 46 | + 'invoice_state' => $this->getInvoiceState(), |
| 47 | + ]; |
| 48 | + } |
| 49 | + |
| 50 | + protected function createBody(Encryption $encryption, array $data) |
| 51 | + { |
| 52 | + return [ |
| 53 | + 'store_uid' => $this->getStoreUid(), |
| 54 | + 'service' => $encryption->encrypt([ |
| 55 | + 'service_name' => 'api', |
| 56 | + 'cmd' => 'api/refund', |
| 57 | + ]), |
| 58 | + 'encry_data' => $encryption->encrypt($data), |
| 59 | + ]; |
| 60 | + } |
| 61 | + |
| 62 | + protected function createResponse($data) |
| 63 | + { |
| 64 | + return $this->response = new RefundResponse($this, $data); |
| 65 | + } |
| 66 | +} |
0 commit comments