1 | <?php |
||
10 | class MolliePaymentGateway implements PaymentGateway |
||
11 | { |
||
12 | private $gateway; |
||
13 | private $response; |
||
14 | |||
15 | public function __construct() |
||
16 | { |
||
17 | $this->response = false; |
||
18 | $this->gateway = new Mollie_API_Client; |
||
19 | $this->gateway->setApiKey(config('payable.mollie.key')); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @param Int |
||
24 | * @param Illuminate\Database\Eloquent\Model |
||
25 | * @return App\Payment |
||
26 | */ |
||
27 | public function chargeAmountForPayable( |
||
28 | Int $amount, |
||
29 | Model $payable, |
||
30 | String $description, |
||
31 | array $params = [] |
||
32 | ): Payment { |
||
33 | |||
34 | $this->response = $this->gateway->payments->create(array( |
||
35 | "amount" => number_format($amount / 100, 2), |
||
36 | "description" => $description, |
||
37 | "redirectUrl" => $params['return_url'], |
||
38 | "webhookUrl" => $params['webhook_url'], |
||
39 | )); |
||
40 | |||
41 | // create payment record for payable model |
||
42 | $payment = $payable->payments()->create([ |
||
43 | 'amount' => $amount, |
||
44 | 'status' => $this->response->status, |
||
45 | 'description' => $description, |
||
46 | 'redirect_url' => $this->response->links->paymentUrl, |
||
47 | 'return_url' => $this->response->links->redirectUrl, |
||
48 | 'gateway_name' => $this->getGatewayName(), |
||
49 | 'gateway_payment_reference' => $this->response->id, |
||
50 | ]); |
||
51 | |||
52 | return $payment; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return String |
||
57 | */ |
||
58 | public function getGatewayName() : String |
||
62 | |||
63 | /** |
||
64 | * @param Payment |
||
65 | * @return Payment |
||
66 | */ |
||
67 | public function fetchUpdateFor(Payment $payment) : Payment |
||
82 | } |
||
83 |
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.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.