Completed
Push — 2.0 ( 7f87f2...afdd14 )
by Roman
16:48
created

ShopPayment::onAwaitingAuthorized()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
use SilverStripe\Omnipay\Service\ServiceResponse;
4
5
/**
6
 * Customisations to {@link Payment} specifically for the shop module.
7
 *
8
 * @package shop
9
 */
10
class ShopPayment extends DataExtension
11
{
12
    private static $has_one = array(
13
        'Order' => 'Order',
14
    );
15
16
    public function onAwaitingAuthorized(ServiceResponse $response)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
    {
18
        $this->placeOrder();
19
    }
20
21
    public function onAwaitingCaptured(ServiceResponse $response)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        $this->placeOrder();
24
    }
25
26
    public function onAuthorized(ServiceResponse $response)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
    {
28
        $this->placeOrder();
29
    }
30
31
    public function onCaptured(ServiceResponse $response)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33
        $order = $this->owner->Order();
34
        if ($order->exists()) {
35
            OrderProcessor::create($order)->completePayment();
36
        }
37
    }
38
39
    protected function placeOrder()
40
    {
41
        $order = $this->owner->Order();
42
        if ($order->exists()) {
43
            OrderProcessor::create($order)->placeOrder();
44
        }
45
    }
46
}
47