77 lines
2.3 KiB
PHP
77 lines
2.3 KiB
PHP
<?php
|
|
|
|
/** Dependencies: `composer require dodo-it/omnipay-wspay:dev-master */
|
|
class WsPay extends \KupShop\OrderingBundle\OmniPay
|
|
{
|
|
public static $name = 'WsPay platební brána';
|
|
|
|
public $class = 'WsPay';
|
|
|
|
public $method;
|
|
|
|
protected $pay_method = Payment::METHOD_COD;
|
|
|
|
public static function getOmnipayName(): string
|
|
{
|
|
return 'WsPay';
|
|
}
|
|
|
|
public static function getSettingsConfiguration(): array
|
|
{
|
|
return [
|
|
'fields' => [
|
|
'shopID' => [
|
|
'title' => 'Shop ID',
|
|
'type' => 'text',
|
|
],
|
|
'secretKey' => [
|
|
'title' => 'Secret key',
|
|
'type' => 'text',
|
|
],
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param Omnipay\WsPay\Gateway $gateway
|
|
*/
|
|
public function configureGateway(Omnipay\Common\GatewayInterface $gateway, Order $order): Omnipay\Common\GatewayInterface
|
|
{
|
|
$gateway->setTestMode(false);
|
|
if (isDevelopment()) {
|
|
$gateway->setTestMode(true);
|
|
}
|
|
|
|
$returnUrl = $this->getGenericPaymentUrl(5);
|
|
|
|
$totalAmount = str_replace('.', ',', $order->total_price->printFloatValue(2));
|
|
|
|
$gateway
|
|
->setShopId($this->config['shopID'])
|
|
->setSecretKey($this->config['secretKey'])
|
|
->setShoppingCartId($order->order_no)
|
|
->setSignature($this->config['shopID'], $this->config['secretKey'], $order->order_no, $totalAmount)
|
|
->setTotalAmount($totalAmount)
|
|
->setCurrency($order->getCurrency())
|
|
->setReturnUrl($returnUrl)
|
|
->setReturnErrorURL($returnUrl)
|
|
->setCancelURL($returnUrl)
|
|
->setLang($order->getLanguage())
|
|
->setCustomerEmail($this->order->invoice_email)
|
|
->setCustomerFirstName($this->order->invoice_name)
|
|
->setCustomerLastName($this->order->invoice_surname)
|
|
->setCustomerCountry($this->order->invoice_country)
|
|
->setCustomerCity($this->order->invoice_city)
|
|
->setCustomerAddress($this->order->invoice_street)
|
|
->setCustomerZIP($this->order->invoice_zip)
|
|
->setCustomerPhone($this->order->invoice_phone);
|
|
|
|
return $gateway;
|
|
}
|
|
|
|
public function hasOnlinePayment()
|
|
{
|
|
return true;
|
|
}
|
|
}
|