Skip to content

Commit

Permalink
Separate Twisto and PayPo, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
regdos committed Apr 25, 2022
1 parent 6f1ded6 commit 051e8cb
Show file tree
Hide file tree
Showing 17 changed files with 303 additions and 237 deletions.
6 changes: 4 additions & 2 deletions README.EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ The plugin offers the following payment methods:
| 4 | PayU - secure form | a secure form collecting credit, debit or prepaid card data will be displayed
| 5 | PayU - Blik | payer will be redirected to Blik's page
| 6 | PayU - installments | payer will be redirected to installment payment form
| 7 | PayU - Twisto | payer will be redirected to Twisto payment form
| 8 | PayU - PayPo | payer will be redirected to PayPo payment form

#### Payment method remarks

* Methods `PayU - standard` and `PayU - bank list` enable payments of any type and differ only with the way the payment type is chosen. **Should not be configured both at once**.
* Methods `PayU - payment card` and `PayU - secure form` enable card payments and differ only with the way the card data is entered. **Should not be configured both at once**.
* In case `PayU - bank list` method is switched on, the following payment types are removed from the list: cards if `PayU - payment card` or `PayU - secure form` is on, Blik if `PayU - Blik` is on, installments if `PayU - installments` is on.
* In case `PayU - bank list` method is switched on, the following payment types are removed from the list: cards if `PayU - payment card` or `PayU - secure form` is on, Blik if `PayU - Blik` is on, installments if `PayU - installments` is on, installments if `PayU - Twisto` is on, PayPo if `PayU - PayPo` is on.
* `PayU - secure form` method requires the shop to be available via HTTPS (for local tests, the address should be http://localhost)
* Even if `PayU - payment card`, `PayU - secure form`, `PayU - Blik` and `PayU - installments` are on, they may be not visible in case they are not configured on your POS in PayU system or if the amount is outside min-max range for the given payment type.
* Even if `PayU - payment card`, `PayU - secure form`, `PayU - Blik`, `PayU - installments`, `PayU - Twisto` and `PayU - PayPo` are on, they may be not visible in case they are not configured on your POS in PayU system or if the amount is outside min-max range for the given payment type.

## Configuration
#### Global configuration
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ Skorzystaj z [automatycznej instalacji oraz aktywacji](https://wordpress.org/sup
## Metody płatności
Wtyczka udostępnia następujące metody płatności:

| Lp | Metoda | Opis
| :---: | ------ | ---
| 1 | PayU - standard | Płacący zostanie przekierowany na stronę PayU gdzie wybierze typ płatności (z listy typów dostępnych na punkcie płatności)
| 2 | PayU - lista banków | Wyświetlana jest lista typów płatności, a płacący w zależności od wybranego typu zostanie przekierowany do banku lub na stronę PayU
| 3 | PayU - karta płatnicza | Płacący zostanie przekierowany na stronę PayU gdzie wprowadzi dane karty (kredytowej, debetowej lub prepaid)
| 4 | PayU - secure form | Wyświetlany jest formularz wprowadzania danych karty
| 5 | PayU - Blik | Płacący zostanie przekierowany na stronę Blik
| 6 | PayU - raty | Płacący zostanie przekierowany na stronę formularza płatności ratalnej
| Lp | Metoda | Opis
|:--:| ------ | ---
| 1 | PayU - standard | Płacący zostanie przekierowany na stronę PayU gdzie wybierze typ płatności (z listy typów dostępnych na punkcie płatności)
| 2 | PayU - lista banków | Wyświetlana jest lista typów płatności, a płacący w zależności od wybranego typu zostanie przekierowany do banku lub na stronę PayU
| 3 | PayU - karta płatnicza | Płacący zostanie przekierowany na stronę PayU gdzie wprowadzi dane karty (kredytowej, debetowej lub prepaid)
| 4 | PayU - secure form | Wyświetlany jest formularz wprowadzania danych karty
| 5 | PayU - Blik | Płacący zostanie przekierowany na stronę Blik
| 6 | PayU - raty | Płacący zostanie przekierowany na stronę formularza płatności ratalnej
| 7 | PayU - Twisto | Płacący zostanie przekierowany na stronę formularza płatności Twisto
| 7 | PayU - PayPo | Płacący zostanie przekierowany na stronę formularza płatności PayPo

#### Uwagi do metod płatności

* Metody `PayU - standard` i `PayU - lista banków` umożliwiają płatność dowolnym typem płatności, a różnią się tylko miejscem jego wyboru. **Nie powinny być razem włączone**.
* Metody `PayU - karta płatnicza` i `PayU - secure form` umożliwiają płatność kartą, a różnią się tylko miejscem wprowadzenia danych karty. **Nie powinny być razem włączone**.
* W przypadku gdy jest włączona metoda `PayU - lista banków` z listy dostępnych typów płatności usuwane są: karty, gdy włączona jest metoda `PayU - karta kredytowa` lub `PayU - secure form`, Blik, gdy włączona jest metoda `PayU - blik`, raty gdy włączona jest metoda `PayU - raty`.
* W przypadku gdy jest włączona metoda `PayU - lista banków` z listy dostępnych typów płatności usuwane są: karty, gdy włączona jest metoda `PayU - karta kredytowa` lub `PayU - secure form`, Blik, gdy włączona jest metoda `PayU - blik`, raty gdy włączona jest metoda `PayU - raty`, Twisto gdy włączona jest metoda `PayU - Twisto`, PayPo gdy włączona jest metoda `PayU - PayPo`.
* Metoda `PayU - secure form` wymaga aby sklep był dostępny za pomocą połączenia HTTPS (przy testach lokalnych adres strony powinien być http://localhost)
* Pomimo włączenia metod `PayU - karta kredytowa`, `PayU - secure form`, `PayU - blik` i `PayU - raty` mogą się one nie pokazać płącącemu, jeśli dany typ płatności nie jest włączony na punkcie płatności lub jeśli kwota nie mieści się między kwotą minimalną i maksymalną dla danego typu.
* Pomimo włączenia metod `PayU - karta kredytowa`, `PayU - secure form`, `PayU - blik`, `PayU - raty`, `PayU - Twisto` i `PayU - PayPo` mogą się one nie pokazać płacącemu, jeśli dany typ płatności nie jest włączony na punkcie płatności lub jeśli kwota nie mieści się między kwotą minimalną i maksymalną dla danego typu.

## Konfiguracja
#### Konfiguracja globalna
Expand Down
16 changes: 16 additions & 0 deletions assets/images/paypo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions assets/images/twisto-pl.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 2 additions & 40 deletions includes/WC_Gateway_PayuBlik.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,9 @@ function __construct()
}
}

/**
* @return bool
*/
public function try_retrieve_banks()
{
$response = $this->get_payu_response();
if (isset($response) && $response->getStatus() === 'SUCCESS') {
$payMethods = $response->getResponse();

return $payMethods->payByLinks && $this->process_pay_methods($payMethods->payByLinks);
}

return false;
}

/**
* @return null
*/
public function payment_fields()
{
if ($this->description) {
echo wpautop(wp_kses_post($this->description));
}
$response = $this->get_payu_response();
if (isset($response)
&& $response->getStatus() === 'SUCCESS'
&& $this->retrieve_methods($response)
) {
$this->agreements_field();
}
}

/**
* @param OpenPayU_Result $response
*
* @return bool
*/
function retrieve_methods($response)
{
$payMethods = $response->getResponse();

return $payMethods->payByLinks && $this->process_pay_methods($payMethods->payByLinks);
parent::payment_fields();
$this->agreements_field();
}
}
27 changes: 3 additions & 24 deletions includes/WC_Gateway_PayuCreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,9 @@ function __construct()
}
}

/**
* @return bool
*/
public function try_retrieve_banks()
public function payment_fields()
{
$response = $this->get_payu_response();
if (isset($response) && $response->getStatus() === 'SUCCESS') {
$payMethods = $response->getResponse();

return $payMethods->payByLinks && $this->process_pay_methods($payMethods->payByLinks);
}

return false;
}

/**
* @param OpenPayU_Result $response
*
* @return bool
*/
function retrieve_methods($response)
{
$payMethods = $response->getResponse();

return $payMethods->payByLinks && $this->process_pay_methods($payMethods->payByLinks);
parent::payment_fields();
$this->agreements_field();
}
}
42 changes: 2 additions & 40 deletions includes/WC_Gateway_PayuInstallments.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,9 @@ function __construct()
}
}

/**
* @return bool
*/
public function try_retrieve_banks()
{
$response = $this->get_payu_response();
if (isset($response) && $response->getStatus() === 'SUCCESS') {
$payMethods = $response->getResponse();

return $payMethods->payByLinks && $this->process_pay_methods($payMethods->payByLinks);
}

return false;
}

/**
* @return null
*/
public function payment_fields()
{
if ($this->description) {
echo wpautop(wp_kses_post($this->description));
}
$response = $this->get_payu_response();
if (isset($response)
&& $response->getStatus() === 'SUCCESS'
&& $this->retrieve_methods($response)
) {
$this->agreements_field();
}
}

/**
* @param OpenPayU_Result $response
*
* @return bool
*/
function retrieve_methods($response)
{
$payMethods = $response->getResponse();

return $payMethods->payByLinks && $this->process_pay_methods($payMethods->payByLinks);
parent::payment_fields();
$this->agreements_field();
}
}
19 changes: 10 additions & 9 deletions includes/WC_Gateway_PayuListBanks.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function init_form_fields() {
/**
* @return bool
*/
public function try_retrieve_banks()
protected function try_retrieve_banks()
{
$response = $this->get_payu_response();
if (isset($response) && $response->getStatus() === 'SUCCESS') {
Expand All @@ -38,28 +38,23 @@ public function try_retrieve_banks()
return false;
}

/**
* @return void
*/
public function payment_fields()
{
if ($this->description) {
echo wpautop(wp_kses_post($this->description));
}
parent::payment_fields();

$response = $this->get_payu_response();
if (isset($response) && $response->getStatus() === 'SUCCESS') {
$this->retrieve_methods($response);
$this->agreements_field();
}
}


/**
* @param OpenPayU_Result $response
*
* @return null
*/
function retrieve_methods($response)
private function retrieve_methods($response)
{
$payMethods = $response->getResponse();
$custom_order = '';
Expand Down Expand Up @@ -128,6 +123,12 @@ function process_pay_methods($payMethods, $sort = null)
if ($available_gateway === 'payuinstallments' && $data->enabled === 'yes') {
array_push($this->unset_banks, 'ai');
}
if ($available_gateway === 'payupaypo' && $data->enabled === 'yes') {
array_push($this->unset_banks, 'dpp');
}
if ($available_gateway === 'payutwistopl' && $data->enabled === 'yes') {
array_push($this->unset_banks, 'dpt');
}
}
}
$show_inactive = @get_option('woocommerce_' . $this->id . '_settings')['show_inactive_methods'];
Expand Down
28 changes: 28 additions & 0 deletions includes/WC_Gateway_PayuPaypo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

class WC_Gateway_PayuPaypo extends WC_PayUGateways
{
protected $paytype = 'dpp';

function __construct()
{
parent::__construct('payupaypo');

if ($this->is_enabled()) {
$this->show_terms_info = false;
$this->icon = apply_filters('woocommerce_payu_icon', plugins_url( '/assets/images/paypo.svg', PAYU_PLUGIN_FILE ));

if (!is_admin()) {
if (!$this->try_retrieve_banks()) {
add_filter('woocommerce_available_payment_gateways', [$this, 'unset_gateway']);
}
}
}
}

public function payment_fields()
{
parent::payment_fields();
$this->agreements_field();
}
}
27 changes: 3 additions & 24 deletions includes/WC_Gateway_PayuSecureForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,10 @@ function minicart_checkout_refresh_script()
endif;
}

/**
* @return bool
*/
public function try_retrieve_banks()
{
$response = $this->get_payu_response();
if (isset($response) && $response->getStatus() === 'SUCCESS') {
$payMethods = $response->getResponse();

return $payMethods->payByLinks && $this->process_pay_methods($payMethods->payByLinks);
}

return false;
}

/**
* @return null
*/
public function payment_fields()
{
$this->init_OpenPayU();
if ($this->description) {
// display the description with <p> tags etc.
echo wpautop(wp_kses_post($this->description));
}
parent::payment_fields();

$response = $this->get_payu_response();
if (isset($response) && $response->getStatus() === 'SUCCESS') {
$this->retrieve_methods($response);
Expand All @@ -87,7 +66,7 @@ public function payment_fields()
*
* @return null
*/
function retrieve_methods($response)
private function retrieve_methods($response)
{
$payMethods = $response->getResponse();
if ($payMethods->payByLinks) {
Expand Down
5 changes: 5 additions & 0 deletions includes/WC_Gateway_PayuStandard.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ public function try_retrieve_banks()
return false;
}

public function payment_fields()
{
parent::payment_fields();
$this->agreements_field();
}
}
Loading

0 comments on commit 051e8cb

Please sign in to comment.