-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExternalGateway.php
110 lines (95 loc) · 2.45 KB
/
ExternalGateway.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
namespace Omnipay\YM;
use Guzzle\Http\Message\Response;
use Omnipay\Common\AbstractGateway;
use Omnipay\Common\Exception\InvalidResponseException;
use Omnipay\Common\Message\AbstractResponse;
class ExternalGateway extends AbstractGateway {
/**
* Get gateway display name
*
* This can be used by carts to get the display name for each gateway.
*/
public function getName()
{
return 'Yandex.Money External';
}
/**
* @param $value
*
* @return $this
*/
public function setInstanceId($value)
{
return $this->setParameter('instanceId', $value);
}
/**
* @return mixed
*/
public function getInstanceId()
{
return $this->getParameter('instanceId');
}
/**
* @param $value
*
* @return $this
*/
public function setWalletId($value)
{
return $this->setParameter('walletId', $value);
}
/**
* @return mixed
*/
public function getWalletId()
{
return $this->getParameter('walletId');
}
/**
* Get instance id that is required for other operations.
*
* @param $clientId
*
* @return string
*
* @throws InvalidResponseException
*/
public function obtainInstanceId($clientId)
{
/** @var AbstractResponse $response */
$response = $this->createRequest('Omnipay\YM\Message\InstanceIdRequest', compact('clientId'))->send();
if ( ! $response->isSuccessful())
{
throw new InvalidResponseException($response->getMessage());
}
return $response->getTransactionReference();
}
/**
* @param array $parameters
*
* @return Message\RequestExternalPaymentRequest
*/
public function requestPayment(array $parameters = array())
{
return $this->createRequest('Omnipay\YM\Message\RequestExternalPaymentRequest', $parameters);
}
/**
* @param array $parameters
*
* @return Message\ProcessExternalPaymentRequest
*/
public function processPayment(array $parameters = array())
{
return $this->createRequest('Omnipay\YM\Message\ProcessExternalPaymentRequest', $parameters);
}
/**
* @param array $parameters
*
* @return Message\CreateCardRequest
*/
public function createCard(array $parameters = array())
{
return $this->createRequest('Omnipay\YM\Message\CreateCardRequest', $parameters);
}
}