1 | <?php |
||
27 | class EpaymentsMerchant extends AbstractMerchant |
||
28 | { |
||
29 | /** |
||
30 | * @return \Omnipay\Common\GatewayInterface |
||
31 | */ |
||
32 | 3 | protected function createGateway() |
|
33 | { |
||
34 | 3 | return $this->gatewayFactory->build('ePayments', [ |
|
35 | 3 | 'partnerId' => $this->credentials->getPurse(), |
|
36 | 3 | 'secret' => $this->credentials->getKey1(), |
|
37 | ]); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param InvoiceInterface $invoice |
||
42 | * @return RedirectPurchaseResponse |
||
43 | */ |
||
44 | 1 | public function requestPurchase(InvoiceInterface $invoice) |
|
45 | { |
||
46 | /** |
||
47 | * @var PurchaseResponse |
||
48 | */ |
||
49 | 1 | $response = $this->gateway->purchase([ |
|
50 | 1 | 'orderId' => $invoice->getId(), |
|
51 | 1 | 'details' => $invoice->getDescription(), |
|
52 | 1 | 'amount' => $this->moneyFormatter->format($invoice->getAmount()), |
|
53 | 1 | 'currency' => strtolower($invoice->getCurrency()->getCode()), |
|
54 | 1 | 'returnUrl' => $invoice->getReturnUrl(), |
|
55 | 1 | 'cancelUrl' => $invoice->getCancelUrl(), |
|
56 | 1 | ])->send(); |
|
57 | |||
58 | 1 | return new RedirectPurchaseResponse($response->getRedirectUrl(), $response->getRedirectData()); |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * @param array $data |
||
63 | * @return CompletePurchaseResponse |
||
64 | */ |
||
65 | 1 | public function completePurchase($data) |
|
66 | { |
||
67 | /** @var \Omnipay\ePayments\Message\CompletePurchaseResponse $notification */ |
||
68 | 1 | $notification = $this->gateway->completePurchase($data)->send(); |
|
69 | |||
70 | 1 | $response = $this->fetchOrderDetails($notification->getOrderId()); |
|
71 | |||
72 | 1 | return (new CompletePurchaseResponse()) |
|
73 | 1 | ->setIsSuccessful($response->isSuccessful()) |
|
|
|||
74 | 1 | ->setAmount($this->moneyParser->parse($response->getAmount(), $response->getCurrency())) |
|
75 | 1 | ->setTransactionReference($response->getTransactionReference()) |
|
76 | 1 | ->setTransactionId($response->getTransactionId()) |
|
77 | 1 | ->setPayer($response->getTransactionReference()) |
|
78 | 1 | ->setTime($response->getPaymentDate()); |
|
79 | } |
||
80 | |||
81 | protected function fetchOrderDetails(string $orderId): DetailsResponse |
||
85 | } |
||
86 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: