Skip to content

Commit

Permalink
Add branding by client country (#20)
Browse files Browse the repository at this point in the history
## [3.8.0 (2022-07-05)](3.7.6...3.8.0)

### Added

- Add branding by client country (it's defined in PS).
- Add modifiers support: UY.

### Removed

- Remove currency validation, now it depends from response of WC.
- Remove payments methods enable, now it depends from configurations in WC.
- Remove connection type configuration, only supports REST messages (using JSON).
  • Loading branch information
freddiegar authored Jul 5, 2023
1 parent 45e4cfa commit ab273c1
Show file tree
Hide file tree
Showing 29 changed files with 516 additions and 527 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [3.8.0 (2022-07-05)](https://github.com/placetopay/prestashop-placetopay/compare/3.7.6...3.8.0)

### Added

- Add branding by client country (it's defined in PS).
- Add modifiers support: UY.

### Removed

- Remove currency validation, now it depends from response of WC.
- Remove payments methods enable, now it depends from configurations in WC.
- Remove connection type configuration, only supports REST messages (using JSON).

## [3.7.6 (2022-05-30)](https://github.com/placetopay/prestashop-placetopay/compare/3.7.5...3.7.6)

### Fixed
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ cd /var/www/html/modules/placetopaypayment \
| 301 | Customer was not loaded |
| 302 | Address was not loaded |
| 303 | Currency was not loaded |
| 304 | Currency is not supported by PlacetoPay |
| 401 | Create payment PlacetoPay failed |
| 501 | Payload notification PlacetoPay was not valid |
| 601 | Update status payment PlacetoPay fail |
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"require": {
"php": "^7.1",
"ext-curl": "*",
"ext-soap": "*",
"ext-json": "*",
"ext-mbstring": "*",
"dnetix/redirection": "^1.0",
"alejociro/redirection": "^1.0",
"guzzlehttp/guzzle": "~5.3"
},
"license": "MIT",
Expand Down
10 changes: 10 additions & 0 deletions src/Constants/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace PlacetoPay\Constants;

interface Client
{
public const GNT = 'Trgarg';
public const GOU = 'TBH';
public const PTP = 'CynprgbCnl';
}
28 changes: 19 additions & 9 deletions src/Constants/CountryCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,36 @@

namespace PlacetoPay\Constants;

use PlacetoPay\Countries\ChileCountryConfig;
use PlacetoPay\Countries\ColombiaCountryConfig;
use PlacetoPay\Countries\CountryConfig;

/**
* @see https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
*/
interface CountryCode
{
public const BELIZE = 'bz';
public const BELIZE = 'BZ';

public const CHILE = 'CL';

public const CHILE = 'cl';
public const COLOMBIA = 'CO';

public const COLOMBIA = 'co';
public const COSTA_RICA = 'CR';

public const COSTA_RICA = 'cr';
public const ECUADOR = 'EC';

public const ECUADOR = 'ec';
public const HONDURAS = 'HN';

public const HONDURAS = 'hn';
public const PANAMA = 'PA';

public const PANAMA = 'pa';
public const PUERTO_RICO = 'PR';

public const PUERTO_RICO = 'pr';
public const URUGUAY = 'UY';

public const URUGUAY = 'uy';
public const COUNTRIES_CLIENT = [
ChileCountryConfig::class,
ColombiaCountryConfig::class,
CountryConfig::class
];
}
18 changes: 18 additions & 0 deletions src/Constants/Discount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace PlacetoPay\Constants;

interface Discount
{
public const UY_IVA_REFUND = '17934';

public const UY_IMESI_REFUND = '18083';

public const UY_FINANCIAL_INCLUSION = '19210';

public const UY_AFAM_REFUND = '18910';

public const UY_TAX_REFUND = '18999';

public const UY_NONE = '0';
}
117 changes: 0 additions & 117 deletions src/Constants/PaymentMethod.php

This file was deleted.

4 changes: 3 additions & 1 deletion src/Constants/PaymentUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PlacetoPay\Countries\BelizeCountryConfig;
use PlacetoPay\Countries\ChileCountryConfig;
use PlacetoPay\Countries\ColombiaCountryConfig;
use PlacetoPay\Countries\CountryConfig;
use PlacetoPay\Countries\CountryConfigInterface;
use PlacetoPay\Countries\EcuadorCountryConfig;
Expand All @@ -18,6 +19,7 @@ abstract class PaymentUrl
HondurasCountryConfig::class,
BelizeCountryConfig::class,
UruguayCountryConfig::class,
ColombiaCountryConfig::class,
CountryConfig::class
];
public static function getEndpointsTo(string $countryCode): array
Expand All @@ -28,7 +30,7 @@ public static function getEndpointsTo(string $countryCode): array
continue;
}

return $config::getEndpoints();
return $config::getEndpoints($countryCode);
}

return [];
Expand Down
4 changes: 2 additions & 2 deletions src/Countries/BelizeCountryConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public static function resolve(string $countryCode): bool
return CountryCode::BELIZE === $countryCode;
}

public static function getEndpoints(): array
public static function getEndpoints(string $client): array
{
return array_merge(parent::getEndpoints(), [
return array_merge(parent::getEndpoints($client), [
Environment::PRODUCTION => 'https://abgateway.atlabank.com'
]);
}
Expand Down
12 changes: 10 additions & 2 deletions src/Countries/ChileCountryConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PlacetoPay\Countries;

use PlacetoPay\Constants\Client;
use PlacetoPay\Constants\CountryCode;
use PlacetoPay\Constants\Environment;

Expand All @@ -12,12 +13,19 @@ public static function resolve(string $countryCode): bool
return CountryCode::CHILE === $countryCode;
}

public static function getEndpoints(): array
public static function getEndpoints(string $client): array
{
return array_merge(parent::getEndpoints(), [
return array_merge(parent::getEndpoints($client), [
Environment::PRODUCTION => unmaskString('uggcf://purpxbhg.trgarg.py'),
Environment::TEST => unmaskString('uggcf://purpxbhg.grfg.trgarg.py'),
Environment::DEVELOPMENT => 'https://checkout-cl.placetopay.dev',
]);
}

public static function getClient(): array
{
return [
unmaskString(Client::GNT) => unmaskString(Client::GNT)
];
}
}
35 changes: 35 additions & 0 deletions src/Countries/ColombiaCountryConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace PlacetoPay\Countries;

use PlacetoPay\Constants\Client;
use PlacetoPay\Constants\CountryCode;
use PlacetoPay\Constants\Environment;

class ColombiaCountryConfig extends CountryConfig
{
public static function resolve(string $countryCode): bool
{
return CountryCode::COLOMBIA === $countryCode;
}

public static function getEndpoints(string $client): array
{
if ($client === unmaskString(Client::GOU)) {
return array_merge(parent::getEndpoints($client), [
Environment::PRODUCTION => unmaskString('uggcf://purpxbhg.tbhcntbf.pbz.pb'),
Environment::TEST => unmaskString('uggcf://purpxbhg.grfg.tbhcntbf.pbz.pb'),
]);
}

return parent::getEndpoints($client);
}

public static function getClient(): array
{
return [
unmaskString(Client::PTP) => unmaskString(Client::PTP),
unmaskString(Client::GOU) => unmaskString(Client::GOU),
];
}
}
10 changes: 9 additions & 1 deletion src/Countries/CountryConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PlacetoPay\Countries;

use PlacetoPay\Constants\Client;
use PlacetoPay\Constants\Environment;
use PlacetoPay\Payments\Model\Adminhtml\Source\Mode;

Expand All @@ -12,12 +13,19 @@ public static function resolve(string $countryCode): bool
return true;
}

public static function getEndpoints(): array
public static function getEndpoints(string $client): array
{
return [
Environment::PRODUCTION => 'https://checkout.placetopay.com',
Environment::TEST => 'https://checkout-test.placetopay.com',
Environment::DEVELOPMENT => 'https://checkout-co.placetopay.dev',
];
}

public static function getClient(): array
{
return [
unmaskString(Client::PTP) => unmaskString(Client::PTP)
];
}
}
4 changes: 3 additions & 1 deletion src/Countries/CountryConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
interface CountryConfigInterface
{
public static function resolve(string $countryCode): bool;
public static function getEndpoints(): array;
public static function getEndpoints(string $client): array;
public static function getClient(): array;

}
4 changes: 2 additions & 2 deletions src/Countries/EcuadorCountryConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public static function resolve(string $countryCode): bool
return CountryCode::ECUADOR === $countryCode;
}

public static function getEndpoints(): array
public static function getEndpoints(string $client): array
{
return array_merge(parent::getEndpoints(), [
return array_merge(parent::getEndpoints($client), [
Environment::PRODUCTION => 'https://checkout.placetopay.ec',
Environment::TEST => 'https://checkout-test.placetopay.ec',
Environment::DEVELOPMENT => 'https://checkout-ec.placetopay.dev',
Expand Down
Loading

0 comments on commit ab273c1

Please sign in to comment.