Code Duplication    Length = 54-55 lines in 3 locations

src/merchants/ikajo/IkajoMerchant.php 1 location

@@ 16-69 (lines=54) @@
13
 *
14
 * @author Dmytro Naumenko <[email protected]>
15
 */
16
class IkajoMerchant extends AbstractMerchant
17
{
18
    /**
19
     * @var Gateway
20
     */
21
    protected $gateway;
22
23
    protected function createGateway()
24
    {
25
        return $this->gatewayFactory->build('Ikajo', [
26
            'purse' => $this->credentials->getPurse(),
27
            'secret'  => $this->credentials->getKey1(),
28
        ]);
29
    }
30
31
    /**
32
     * @param InvoiceInterface $invoice
33
     * @return RedirectPurchaseResponse
34
     */
35
    public function requestPurchase(InvoiceInterface $invoice)
36
    {
37
        /**
38
         * @var \Omnipay\Ikajo\Message\PurchaseResponse $response
39
         */
40
        $response = $this->gateway->purchase([
41
            'transactionId' => $invoice->getId(),
42
            'description' => $invoice->getDescription(),
43
            'amount' => $this->moneyFormatter->format($invoice->getAmount()),
44
            'currency' => $invoice->getCurrency()->getCode(),
45
            'returnUrl' => $invoice->getReturnUrl(),
46
            'cancelUrl' => $invoice->getCancelUrl(),
47
        ])->send();
48
49
        return new RedirectPurchaseResponse($response->getRedirectUrl(), $response->getRedirectData());
50
    }
51
52
    /**
53
     * @param array $data
54
     * @return CompletePurchaseResponse
55
     */
56
    public function completePurchase($data)
57
    {
58
        /** @var \Omnipay\Ikajo\Message\CompletePurchaseResponse $response */
59
        $response = $this->gateway->completePurchase($data)->send();
60
61
        return (new CompletePurchaseResponse())
62
            ->setIsSuccessful($response->isSuccessful())
63
            ->setAmount($this->moneyParser->parse($response->getAmount(), $response->getCurrency()))
64
            ->setTransactionReference($response->getTransactionReference())
65
            ->setTransactionId($response->getTransactionId())
66
            ->setPayer($response->getPayer())
67
            ->setTime(new \DateTime($response->getTime()));
68
    }
69
}
70

src/merchants/paxum/PaxumMerchant.php 1 location

@@ 24-78 (lines=55) @@
21
 *
22
 * @author Dmytro Naumenko <[email protected]>
23
 */
24
class PaxumMerchant extends AbstractMerchant
25
{
26
    /**
27
     * @var Gateway
28
     */
29
    protected $gateway;
30
31
    protected function createGateway()
32
    {
33
        return $this->gatewayFactory->build('Paxum', [
34
            'purse' => $this->credentials->getPurse(),
35
            'secret'  => $this->credentials->getKey1(),
36
        ]);
37
    }
38
39
    /**
40
     * @param InvoiceInterface $invoice
41
     * @return RedirectPurchaseResponse
42
     */
43
    public function requestPurchase(InvoiceInterface $invoice)
44
    {
45
        /**
46
         * @var \Omnipay\Paxum\Message\PurchaseResponse
47
         */
48
        $response = $this->gateway->purchase([
49
            'transactionId' => $invoice->getId(),
50
            'description' => $invoice->getDescription(),
51
            'amount' => $this->moneyFormatter->format($invoice->getAmount()),
52
            'currency' => $invoice->getCurrency()->getCode(),
53
            'returnUrl' => $invoice->getReturnUrl(),
54
            'notifyUrl' => $invoice->getNotifyUrl(),
55
            'cancelUrl' => $invoice->getCancelUrl(),
56
        ])->send();
57
58
        return new RedirectPurchaseResponse($response->getRedirectUrl(), $response->getRedirectData());
59
    }
60
61
    /**
62
     * @param array $data
63
     * @return CompletePurchaseResponse
64
     */
65
    public function completePurchase($data)
66
    {
67
        /** @var \Omnipay\Paxum\Message\CompletePurchaseResponse $response */
68
        $response = $this->gateway->completePurchase($data)->send();
69
70
        return (new CompletePurchaseResponse())
71
            ->setIsSuccessful($response->isSuccessful())
72
            ->setAmount($this->moneyParser->parse($response->getAmount(), $response->getCurrency()))
73
            ->setTransactionReference($response->getTransactionReference())
74
            ->setTransactionId($response->getTransactionId())
75
            ->setPayer($response->getPayer())
76
            ->setTime(new \DateTime($response->getTime()));
77
    }
78
}
79

src/merchants/robokassa/RoboKassaMerchant.php 1 location

@@ 24-77 (lines=54) @@
21
 *
22
 * @author Dmytro Naumenko <[email protected]>
23
 */
24
class RoboKassaMerchant extends AbstractMerchant
25
{
26
    /**
27
     * @var Gateway
28
     */
29
    protected $gateway;
30
31
    protected function createGateway()
32
    {
33
        return $this->gatewayFactory->build('RoboKassa', [
34
            'purse' => $this->credentials->getPurse(),
35
            'secretKey' => $this->credentials->getKey1(),
36
            'secretKey2' => $this->credentials->getKey2(),
37
        ]);
38
    }
39
40
    /**
41
     * @param InvoiceInterface $invoice
42
     * @return RedirectPurchaseResponse
43
     */
44
    public function requestPurchase(InvoiceInterface $invoice)
45
    {
46
        /**
47
         * @var \Omnipay\RoboKassa\Message\PurchaseResponse
48
         */
49
        $response = $this->gateway->purchase([
50
            'amount' => $this->moneyFormatter->format($invoice->getAmount()),
51
            'transaction_id' => $invoice->getId(),
52
            'description' => $invoice->getDescription(),
53
            'currency' => $invoice->getCurrency()->getCode(),
54
            'client' => $invoice->getClient(),
55
        ])->send();
56
57
        return new RedirectPurchaseResponse($response->getRedirectUrl(), $response->getRedirectData());
58
    }
59
60
    /**
61
     * @param array $data
62
     * @return CompletePurchaseResponse
63
     */
64
    public function completePurchase($data)
65
    {
66
        /** @var \Omnipay\RoboKassa\Message\CompletePurchaseResponse $response */
67
        $response = $this->gateway->completePurchase($data)->send();
68
69
        return (new CompletePurchaseResponse())
70
            ->setIsSuccessful($response->isSuccessful())
71
            ->setAmount($this->moneyParser->parse($response->getAmount(), $response->getCurrency()))
72
            ->setTransactionReference($response->getTransactionReference())
73
            ->setTransactionId($response->getTransactionId())
74
            ->setPayer($response->getPayer())
75
            ->setTime((new \DateTime())->setTimezone(new \DateTimeZone('UTC')));
76
    }
77
}
78