These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Generalization over Omnipay and Payum |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/php-merchant |
||
6 | * @package php-merchant |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2015-2018, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hiqdev\php\merchant\merchants\yandex; |
||
12 | |||
13 | use hiqdev\php\merchant\InvoiceInterface; |
||
14 | use hiqdev\php\merchant\merchants\AbstractMerchant; |
||
15 | use hiqdev\php\merchant\response\CompletePurchaseResponse; |
||
16 | use hiqdev\php\merchant\response\RedirectPurchaseResponse; |
||
17 | use Omnipay\YandexMoney\P2pGateway; |
||
18 | |||
19 | /** |
||
20 | * Class YandexP2pMerchant. |
||
21 | * |
||
22 | * @author Dmytro Naumenko <[email protected]> |
||
23 | */ |
||
24 | class YandexP2pMerchant extends AbstractMerchant |
||
25 | { |
||
26 | /** |
||
27 | * @var P2pGateway |
||
28 | */ |
||
29 | protected $gateway; |
||
30 | |||
31 | 3 | protected function createGateway() |
|
32 | { |
||
33 | 3 | return $this->gatewayFactory->build('YandexMoney_P2p', [ |
|
34 | 3 | 'account' => $this->credentials->getPurse(), |
|
35 | 3 | 'password' => $this->credentials->getKey1(), |
|
36 | 3 | 'testMode' => $this->credentials->isTestMode(), |
|
37 | ]); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param InvoiceInterface $invoice |
||
42 | * @return RedirectPurchaseResponse |
||
43 | */ |
||
44 | 1 | public function requestPurchase(InvoiceInterface $invoice) |
|
45 | { |
||
46 | /** |
||
47 | * @var \Omnipay\YandexMoney\Message\p2p\PurchaseResponse |
||
48 | */ |
||
49 | 1 | $response = $this->gateway->purchase([ |
|
50 | 1 | 'transactionId' => $invoice->getId(), |
|
51 | 1 | 'description' => $invoice->getDescription(), |
|
52 | 1 | 'amount' => $this->moneyFormatter->format($invoice->getAmount()), |
|
53 | 1 | 'currency' => $invoice->getCurrency()->getCode(), |
|
54 | 1 | 'returnUrl' => $invoice->getReturnUrl(), |
|
55 | 1 | 'notifyUrl' => $invoice->getNotifyUrl(), |
|
56 | 1 | 'cancelUrl' => $invoice->getCancelUrl(), |
|
57 | 1 | 'method' => 'AC', // https://money.yandex.ru/doc.xml?id=526991 |
|
58 | 1 | ])->send(); |
|
59 | |||
60 | 1 | return new RedirectPurchaseResponse($response->getRedirectUrl(), $response->getRedirectData()); |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param array $data |
||
65 | * @return CompletePurchaseResponse |
||
66 | */ |
||
67 | 1 | public function completePurchase($data) |
|
68 | { |
||
69 | /** @var \Omnipay\YandexMoney\Message\p2p\CompletePurchaseResponse $response */ |
||
70 | 1 | $response = $this->gateway->completePurchase($data)->send(); |
|
71 | |||
72 | 1 | return (new CompletePurchaseResponse()) |
|
73 | 1 | ->setIsSuccessful($response->isSuccessful()) |
|
74 | 1 | ->setAmount($this->moneyParser->parse($response->getAmount(), $response->getCurrency())) |
|
75 | 1 | ->setFee($this->moneyParser->parse($response->getFee(), $response->getCurrency())) |
|
0 ignored issues
–
show
|
|||
76 | 1 | ->setTransactionReference($response->getTransactionReference()) |
|
77 | 1 | ->setTransactionId($response->getTransactionId()) |
|
78 | 1 | ->setPayer($response->getData()['sender'] ?? $response->getData()['email'] ?? '') |
|
79 | 1 | ->setTime( |
|
80 | 1 | (new \DateTime($response->getTime(), new \DateTimeZone('Europe/Moscow'))) |
|
81 | ->setTimezone(new \DateTimeZone('UTC')) |
||
82 | ); |
||
83 | } |
||
84 | } |
||
85 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.