Completed
Pull Request — 2.0 (#101)
by Mark
02:17
created

PurchaseService::purchase()   F

Complexity

Conditions 10
Paths 321

Size

Total Lines 85
Code Lines 55

Duplication

Lines 15
Ratio 17.65 %
Metric Value
dl 15
loc 85
rs 3.6
cc 10
eloc 55
nc 321
nop 1

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
use Omnipay\Common\CreditCard;
4
use Omnipay\Common\Message\ResponseInterface;
5
6
class PurchaseService extends PaymentService
7
{
8
9
	/**
10
	 * Attempt to make a payment.
11
	 *
12
	 * @param  array $data returnUrl/cancelUrl + customer creditcard and billing/shipping details.
13
	 * 	Some keys (e.g. "amount") are overwritten with data from the associated {@link $payment}.
14
	 *  If this array is constructed from user data (e.g. a form submission), please take care
15
	 *  to whitelist accepted fields, in order to ensure sensitive gateway parameters like "freeShipping" can't be set.
16
	 *  If using {@link Form->getData()}, only fields which exist in the form are returned,
17
	 *  effectively whitelisting against arbitrary user input.
18
	 * @return ResponseInterface omnipay's response class, specific to the chosen gateway.
19
	 */
20
	public function purchase($data = array()) {
21
		if ($this->payment->Status !== "Created") {
0 ignored issues
show
Documentation introduced by
The property Status does not exist on object<Payment>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
22
			return null; //could be handled better? send payment response?
23
		}
24
		if (!$this->payment->isInDB()) {
25
			$this->payment->write();
26
		}
27
		//update success/fail urls
28
		$this->update($data);
29
30
		//set the client IP address, if not already set
31
		if(!isset($data['clientIp'])){
32
			$data['clientIp'] = Controller::curr()->getRequest()->getIP();
33
		}
34
35
		$gatewaydata = array_merge($data, array(
36
			'amount' => (float) $this->payment->MoneyAmount,
0 ignored issues
show
Documentation introduced by
The property MoneyAmount does not exist on object<Payment>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
37
			'currency' => $this->payment->MoneyCurrency,
0 ignored issues
show
Documentation introduced by
The property MoneyCurrency does not exist on object<Payment>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
38
			//set all gateway return/cancel/notify urls to PaymentGatewayController endpoint
39
			'returnUrl' => $this->getEndpointURL("complete", $this->payment->Identifier),
0 ignored issues
show
Documentation introduced by
The property Identifier does not exist on object<Payment>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
40
			'cancelUrl' => $this->getEndpointURL("cancel", $this->payment->Identifier),
0 ignored issues
show
Documentation introduced by
The property Identifier does not exist on object<Payment>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
41
			'notifyUrl' => $this->getEndpointURL("notify", $this->payment->Identifier)
0 ignored issues
show
Documentation introduced by
The property Identifier does not exist on object<Payment>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
42
		));
43
44
        // Often, the shop will want to pass in a transaction ID (order #, etc), but if there's
45
        // not one we need to set it as Ominpay requires this.
46
		if(!isset($gatewaydata['transactionId'])){
47
			$gatewaydata['transactionId'] = $this->payment->Identifier;
0 ignored issues
show
Documentation introduced by
The property Identifier does not exist on object<Payment>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
48
		}
49
50
        // We only look for a card if we aren't already provided with a token
51
        // Increasingly we can expect tokens or nonce's to be more common (e.g. Stripe and Braintree)
52
        if (empty($gatewaydata['token'])) {
53
            $gatewaydata['card'] = $this->getCreditCard($data);
54
        }
55
56
        $this->extend('onBeforePurchase', $gatewaydata);
57
        $request = $this->oGateway()->purchase($gatewaydata);
0 ignored issues
show
Bug introduced by
The method purchase() does not exist on Omnipay\Common\AbstractGateway. Did you maybe mean supportsCompletePurchase()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
58
        $this->extend('onAfterPurchase', $request);
59
60
        $message = $this->createMessage('PurchaseRequest', $request);
61
		$message->SuccessURL = $this->returnurl;
62
		$message->FailureURL = $this->cancelurl;
63
		$message->write();
64
65
		$gatewayresponse = $this->createGatewayResponse();
66
		try {
67
			$response = $this->response = $request->send();
68
            $this->extend('onAfterSendPurchase', $request, $response);
69
			$gatewayresponse->setOmnipayResponse($response);
70
			//update payment model
71
			if (GatewayInfo::is_manual($this->payment->Gateway)) {
0 ignored issues
show
Documentation introduced by
The property Gateway does not exist on object<Payment>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
72
				//initiate manual payment
73
				$this->createMessage('AuthorizedResponse', $response);
74
				$this->payment->Status = 'Authorized';
0 ignored issues
show
Documentation introduced by
The property Status does not exist on object<Payment>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
75
				$this->payment->write();
76
				$gatewayresponse->setMessage("Manual payment authorised");
77 View Code Duplication
			} elseif ($response->isSuccessful()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
78
				//successful payment
79
				$this->createMessage('PurchasedResponse', $response);
80
				$this->payment->Status = 'Captured';
0 ignored issues
show
Documentation introduced by
The property Status does not exist on object<Payment>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
81
				$gatewayresponse->setMessage("Payment successful");
82
				$this->payment->write();
83
				$this->payment->extend('onCaptured', $gatewayresponse);
84
			} elseif ($response->isRedirect()) {
85
				// redirect to off-site payment gateway
86
				$this->createMessage('PurchaseRedirectResponse', $response);
87
				$this->payment->Status = 'Authorized';
0 ignored issues
show
Documentation introduced by
The property Status does not exist on object<Payment>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
88
				$this->payment->write();
89
				$gatewayresponse->setMessage("Redirecting to gateway");
90 View Code Duplication
			} else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
				//handle error
92
				$this->createMessage('PurchaseError', $response);
93
				$gatewayresponse->setMessage(
94
					"Error (".$response->getCode()."): ".$response->getMessage()
95
				);
96
			}
97
		} catch (Omnipay\Common\Exception\OmnipayException $e) {
98
			$this->createMessage('PurchaseError', $e);
0 ignored issues
show
Documentation introduced by
$e is of type object<Omnipay\Common\Exception\OmnipayException>, but the function expects a array|string|object<Omni...<OmnipayException>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
99
			$gatewayresponse->setMessage($e->getMessage());
100
		}
101
		$gatewayresponse->setRedirectURL($this->getRedirectURL());
102
103
		return $gatewayresponse;
104
	}
105
106
	/**
107
	 * Finalise this payment, after off-site external processing.
108
	 * This is ususally only called by PaymentGatewayController.
109
	 * @return GatewayResponse encapsulated response info
110
	 */
111
	public function completePurchase($data = array()) {
112
		$gatewayresponse = $this->createGatewayResponse();
113
114
		//set the client IP address, if not already set
115
		if(!isset($data['clientIp'])){
116
			$data['clientIp'] = Controller::curr()->getRequest()->getIP();
117
		}
118
119
		$gatewaydata = array_merge($data, array(
120
			'amount' => (float) $this->payment->MoneyAmount,
0 ignored issues
show
Documentation introduced by
The property MoneyAmount does not exist on object<Payment>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
121
			'currency' => $this->payment->MoneyCurrency
0 ignored issues
show
Documentation introduced by
The property MoneyCurrency does not exist on object<Payment>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
122
		));
123
124
		$this->payment->extend('onBeforeCompletePurchase', $gatewaydata);
125
        $request = $this->oGateway()->completePurchase($gatewaydata);
0 ignored issues
show
Bug introduced by
The method completePurchase() does not exist on Omnipay\Common\AbstractGateway. Did you maybe mean supportsCompletePurchase()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
126
        $this->payment->extend('onAfterCompletePurchase', $request);
127
128
        $this->createMessage('CompletePurchaseRequest', $request);
129
		$response = null;
130
		try {
131
			$response = $this->response = $request->send();
132
            $this->extend('onAfterSendCompletePurchase', $request, $response);
133
			$gatewayresponse->setOmnipayResponse($response);
134 View Code Duplication
			if ($response->isSuccessful()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
135
				$this->createMessage('PurchasedResponse', $response);
136
				$this->payment->Status = 'Captured';
0 ignored issues
show
Documentation introduced by
The property Status does not exist on object<Payment>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
137
				$this->payment->write();
138
				$this->payment->extend('onCaptured', $gatewayresponse);
139
			} else {
140
				$this->createMessage('CompletePurchaseError', $response);
141
			}
142
		} catch (Omnipay\Common\Exception\OmnipayException $e) {
143
			$this->createMessage("CompletePurchaseError", $e);
0 ignored issues
show
Documentation introduced by
$e is of type object<Omnipay\Common\Exception\OmnipayException>, but the function expects a array|string|object<Omni...<OmnipayException>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
144
		}
145
146
		return $gatewayresponse;
147
	}
148
149
	public function cancelPurchase() {
150
		//TODO: do lookup? / try to complete purchase?
151
		//TODO: omnipay void call
152
		$this->payment->Status = 'Void';
0 ignored issues
show
Documentation introduced by
The property Status does not exist on object<Payment>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
153
		$this->payment->write();
154
		$this->createMessage('VoidRequest', array(
155
			"Message" => "The payment was cancelled."
156
		));
157
158
		//return response
159
	}
160
161
	/**
162
	 * @return \Omnipay\Common\CreditCard
163
	 */
164
	protected function getCreditCard($data) {
165
		return new CreditCard($data);
166
	}
167
168
}
169