1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Stripe; |
4
|
|
|
|
5
|
|
|
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Traits\GatewayTrait; |
6
|
|
|
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Traits\OverwriteServerCompletePurchaseTrait; |
7
|
|
|
use ByTIC\Payments\Stripe\Message\PurchaseRequest; |
8
|
|
|
use Omnipay\Common\Message\AbstractRequest as CommonAbstractRequest; |
9
|
|
|
use Omnipay\Common\Message\RequestInterface; |
10
|
|
|
use Omnipay\Stripe\PaymentIntentsGateway as AbstractGateway; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class Gateway |
14
|
|
|
* @package ByTIC\Payments\Stripe |
15
|
|
|
* @method \Omnipay\Common\Message\NotificationInterface acceptNotification(array $options = array()) |
16
|
|
|
*/ |
17
|
|
|
class Gateway extends AbstractGateway |
18
|
|
|
{ |
19
|
|
|
use GatewayTrait; |
20
|
|
|
use OverwriteServerCompletePurchaseTrait; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param array $parameters |
24
|
|
|
* @return PurchaseRequest |
25
|
1 |
|
*/ |
26
|
|
|
public function purchase(array $parameters = []): RequestInterface |
27
|
1 |
|
{ |
28
|
|
|
return $this->createRequestWithInternalCheck('purchase', $parameters); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @inheritDoc |
33
|
|
|
*/ |
34
|
|
|
public function setSandbox($value): self |
35
|
|
|
{ |
36
|
|
|
return $this->setTestMode($value == 'yes'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @inheritDoc |
41
|
|
|
*/ |
42
|
|
|
public function getSandbox(): string |
43
|
|
|
{ |
44
|
|
|
return $this->getTestMode() === true ? 'yes' : 'no'; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return bool |
49
|
|
|
*/ |
50
|
|
|
public function isActive(): bool |
51
|
|
|
{ |
52
|
|
|
if (strlen($this->getApiKey()) >= 5) { |
53
|
|
|
return true; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return false; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return mixed |
61
|
1 |
|
*/ |
62
|
|
|
public function getPublicKey() |
63
|
1 |
|
{ |
64
|
|
|
return $this->getParameter('publicKey'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param $value |
69
|
|
|
* @return CommonAbstractRequest |
70
|
1 |
|
*/ |
71
|
|
|
public function setPublicKey($value) |
72
|
1 |
|
{ |
73
|
|
|
return $this->setParameter('publicKey', $value); |
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** @noinspection PhpMissingParentCallCommonInspection |
77
|
|
|
* |
78
|
|
|
* {@inheritdoc} |
79
|
1 |
|
*/ |
80
|
|
|
public function getDefaultParameters() |
81
|
|
|
{ |
82
|
1 |
|
return [ |
83
|
1 |
|
'testMode' => true, // Must be the 1st in the list! |
84
|
1 |
|
'publicKey' => $this->getPublicKey(), |
85
|
|
|
'apiKey' => $this->getApiKey(), |
86
|
|
|
]; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function __call($name, $arguments) |
90
|
|
|
{ |
91
|
|
|
// TODO: Implement @method \Omnipay\Common\Message\NotificationInterface acceptNotification(array $options = array()) |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|