RefundRequest::getData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 15
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Omnipay\Worldline\Message;
4
5
/**
6
 * Worldline Refund Request
7
 *
8
 * @see https://docs.direct.worldline-solutions.com/en/api-reference#tag/Payments/operation/RefundPaymentApi
9
 */
10
class RefundRequest extends AbstractRequest
11
{
12
    protected $requestMethod = 'POST';
13
14
    public function getData()
15
    {
16
        $this->validate('merchantId', 'amount', 'currency', 'transactionReference');
17
18
        $data = [
19
            'amountOfMoney' => [
20
                'amount' => $this->getAmountInteger(),
21
                'currencyCode' => $this->getCurrency(),
22
            ],
23
            'operationReferences' => [
24
                'merchantReference' => $this->getTransactionId(),
25
            ],
26
        ];
27
28
        return $data;
29
    }
30
31
    protected function createResponse($data)
32
    {
33
        return $this->response = new RefundResponse($this, json_decode($data));
34
    }
35
36
    protected function getAction()
37
    {
38
        return '/v2/'.$this->getMerchantId().'/payments/'.$this->getTransactionReference().'/refund';
39
    }
40
}
41