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\yandexkassa; |
||
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\YandexKassa\Gateway; |
||
18 | use Omnipay\YandexKassa\Message\CaptureResponse; |
||
19 | use Omnipay\YandexKassa\Message\DetailsResponse; |
||
20 | |||
21 | /** |
||
22 | * Class YandexKassaMerchant. |
||
23 | * |
||
24 | * @author Dmytro Naumenko <[email protected]> |
||
25 | */ |
||
26 | class YandexKassaMerchant extends AbstractMerchant |
||
27 | { |
||
28 | /** |
||
29 | * @var Gateway |
||
30 | */ |
||
31 | protected $gateway; |
||
32 | |||
33 | protected function createGateway() |
||
34 | { |
||
35 | return $this->gatewayFactory->build('YandexKassa', [ |
||
36 | 'shopId' => $this->credentials->getPurse(), |
||
37 | 'secret' => $this->credentials->getKey1(), |
||
38 | ]); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param InvoiceInterface $invoice |
||
43 | * @return RedirectPurchaseResponse |
||
44 | * @throws \Omnipay\Common\Exception\InvalidResponseException |
||
45 | */ |
||
46 | public function requestPurchase(InvoiceInterface $invoice) |
||
47 | { |
||
48 | /** |
||
49 | * @var \Omnipay\YandexKassa\Message\PurchaseResponse $response |
||
50 | */ |
||
51 | $response = $this->gateway->purchase([ |
||
52 | 'transactionId' => $invoice->getId(), |
||
53 | 'details' => $invoice->getDescription(), |
||
54 | 'amount' => $this->moneyFormatter->format($invoice->getAmount()), |
||
55 | 'currency' => $invoice->getCurrency()->getCode(), |
||
56 | 'returnUrl' => $invoice->getReturnUrl(), |
||
57 | ])->send(); |
||
58 | |||
59 | return (new RedirectPurchaseResponse($response->getRedirectUrl(), $response->getRedirectData())) |
||
60 | ->setMethod($response->getRedirectMethod()); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param array $data |
||
65 | * @return CompletePurchaseResponse |
||
66 | */ |
||
67 | public function completePurchase($data) |
||
68 | { |
||
69 | $notification = $this->gateway->notification($data)->send(); |
||
0 ignored issues
–
show
|
|||
70 | /** @var DetailsResponse $details */ |
||
71 | $details = $this->gateway->details([ |
||
72 | 'transactionReference' => $notification->getTransactionReference() |
||
73 | ])->send(); |
||
74 | /** @var CaptureResponse $response */ |
||
75 | $response = $this->gateway->capture([ |
||
0 ignored issues
–
show
The method
capture() does not exist on Omnipay\YandexKassa\Gateway . Did you maybe mean supportsCapture() ?
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...
|
|||
76 | 'transactionId' => $details->getTransactionId(), |
||
77 | 'transactionReference' => $details->getTransactionReference(), |
||
78 | 'amount' => $details->getAmount(), |
||
79 | 'currency' => $details->getCurrency(), |
||
80 | ])->send(); |
||
81 | |||
82 | return (new CompletePurchaseResponse()) |
||
83 | ->setIsSuccessful($response->isSuccessful()) |
||
84 | ->setAmount($this->moneyParser->parse($response->getAmount(), $response->getCurrency())) |
||
85 | ->setTransactionReference($response->getTransactionReference()) |
||
86 | ->setTransactionId($response->getTransactionId()) |
||
87 | ->setPayer($response->getPayer()) |
||
88 | ->setTime($response->getPaymentDate()); |
||
89 | } |
||
90 | } |
||
91 |
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.