TransactionRequest::addOrder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace CommerceGuys\AuthNet\DataTypes;
4
5
class TransactionRequest extends BaseDataType
6
{
7
    const AUTH_ONLY = 'authOnlyTransaction';
8
    const PRIOR_AUTH_CAPTURE = 'priorAuthCaptureTransaction';
9
    const AUTH_CAPTURE = 'authCaptureTransaction';
10
    const CAPTURE_ONLY = 'captureOnlyTransaction';
11
    const REFUND = 'refundTransaction';
12
    const VOID = 'voidTransaction';
13
14
    protected $propertyMap = [
15
        'transactionType',
16
        'amount',
17
        'currencyCode',
18
        'payment',
19
        'profile',
20
        'solution',
21
        'callId',
22
        'terminalNumber',
23
        'authCode',
24
        'refTransId',
25
        'order',
26
        'lineItems',
27
        'tax',
28
        'duty',
29
        'shipping',
30
        'taxExempt',
31
        'poNumber',
32
        'customer',
33
        'billTo',
34
        'shipTo',
35
        'customerIP',
36
        'cardholderAuthentication',
37
        'retail',
38
        'employeeId',
39
        'transactionSettings',
40
        'userFields',
41
        'surcharge',
42
        'merchantDescriptor',
43
    ];
44
45
    protected $properties = [
46
        'solution' => [
47
            'id' => 'A1000009',
48
        ],
49
    ];
50
51 9
    public function addPayment(PaymentMethodInterface $paymentMethod)
52
    {
53 9
        $this->properties['payment'][$paymentMethod->getType()] = $paymentMethod->toArray();
54 9
    }
55
56 8
    public function addOrder(Order $order)
57
    {
58 8
        $this->addDataType($order);
59 8
    }
60
61 1
    public function addLineItem(LineItem $lineItem)
62
    {
63 1
        $this->properties['lineItems'][] = [
64 1
            $lineItem->getType() => $lineItem->toArray(),
65
        ];
66 1
    }
67
}
68