Skip to content

Commit

Permalink
Merge branch 'feature/GPY025-17-new-payments' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasZeman22 committed Dec 6, 2024
2 parents ea4e08a + 29b5ccf commit 5fa9bca
Show file tree
Hide file tree
Showing 21 changed files with 236 additions and 112 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"php": ">=7.1",
"gopay/payments-sdk-php": "^1.4",
"gopay/payments-sdk-php": "^1.10.1",
"guzzlehttp/guzzle": "^7.7.0"
},
"require-dev": {
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions includes/class-gopay-gateway-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ public static function supported_payment_methods(): array {
'GPAY' => array( 'label' => __( 'Google Pay', 'gopay-gateway' ) ),
'APPLE_PAY' => array( 'label' => __( 'Apple Pay', 'gopay-gateway' ) ),
'GOPAY' => array( 'label' => __( 'GoPay wallet', 'gopay-gateway' ) ),
'TWISTO' => array( 'label' => __( 'Twisto', 'gopay-gateway' ) ),
'SKIPPAY' => array( 'label' => __( 'Skip Pay', 'gopay-gateway' ) ),
'PAYPAL' => array( 'label' => __( 'PayPal wallet', 'gopay-gateway' ) ),
'MPAYMENT' => array( 'label' => __( 'mPlatba (mobile payment)', 'gopay-gateway' ) ),
'PRSMS' => array( 'label' => __( 'Premium SMS', 'gopay-gateway' ) ),
Expand Down
12 changes: 6 additions & 6 deletions includes/class-gopay-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,12 @@ public function payment_fields() {
$selected_banks = $this->get_option( 'enable_banks', array() );

// Intersection of all selected and the supported by the currency.
$payment_methods = array_intersect_key(
$supported_payment_methods,
array_flip(
$selected_payment_methods
)
);
$payment_methods = array();
foreach ( $selected_payment_methods as $method ) {
if ( isset($supported_payment_methods[$method]) ) {
$payment_methods[$method] = $supported_payment_methods[$method];
}
}
$banks = array_intersect_key( $supported_banks, array_flip( $selected_banks ) );

// Check if subscription - only card payment is enabled.
Expand Down
2 changes: 2 additions & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'GoPay\\Auth' => $vendorDir . '/gopay/payments-sdk-php/src/Auth.php',
'GoPay\\Config' => $vendorDir . '/gopay/payments-sdk-php/src/Config.php',
'GoPay\\Definition\\Account\\StatementGeneratingFormat' => $vendorDir . '/gopay/payments-sdk-php/src/Definition/Account/StatementGeneratingFormat.php',
'GoPay\\Definition\\Language' => $vendorDir . '/gopay/payments-sdk-php/src/Definition/Language.php',
'GoPay\\Definition\\Payment\\BankSwiftCode' => $vendorDir . '/gopay/payments-sdk-php/src/Definition/Payment/BankSwiftCode.php',
'GoPay\\Definition\\Payment\\BnplType' => $vendorDir . '/gopay/payments-sdk-php/src/Definition/Payment/BnplType.php',
'GoPay\\Definition\\Payment\\Currency' => $vendorDir . '/gopay/payments-sdk-php/src/Definition/Payment/Currency.php',
'GoPay\\Definition\\Payment\\PaymentInstrument' => $vendorDir . '/gopay/payments-sdk-php/src/Definition/Payment/PaymentInstrument.php',
'GoPay\\Definition\\Payment\\PaymentItemType' => $vendorDir . '/gopay/payments-sdk-php/src/Definition/Payment/PaymentItemType.php',
Expand Down
2 changes: 0 additions & 2 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public static function getLoader()
return self::$loader;
}

require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInit1c4379f75f2119f2e46c041ff07fda8b', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit1c4379f75f2119f2e46c041ff07fda8b', 'loadClassLoader'));
Expand Down
2 changes: 2 additions & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ class ComposerStaticInit1c4379f75f2119f2e46c041ff07fda8b
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'GoPay\\Auth' => __DIR__ . '/..' . '/gopay/payments-sdk-php/src/Auth.php',
'GoPay\\Config' => __DIR__ . '/..' . '/gopay/payments-sdk-php/src/Config.php',
'GoPay\\Definition\\Account\\StatementGeneratingFormat' => __DIR__ . '/..' . '/gopay/payments-sdk-php/src/Definition/Account/StatementGeneratingFormat.php',
'GoPay\\Definition\\Language' => __DIR__ . '/..' . '/gopay/payments-sdk-php/src/Definition/Language.php',
'GoPay\\Definition\\Payment\\BankSwiftCode' => __DIR__ . '/..' . '/gopay/payments-sdk-php/src/Definition/Payment/BankSwiftCode.php',
'GoPay\\Definition\\Payment\\BnplType' => __DIR__ . '/..' . '/gopay/payments-sdk-php/src/Definition/Payment/BnplType.php',
'GoPay\\Definition\\Payment\\Currency' => __DIR__ . '/..' . '/gopay/payments-sdk-php/src/Definition/Payment/Currency.php',
'GoPay\\Definition\\Payment\\PaymentInstrument' => __DIR__ . '/..' . '/gopay/payments-sdk-php/src/Definition/Payment/PaymentInstrument.php',
'GoPay\\Definition\\Payment\\PaymentItemType' => __DIR__ . '/..' . '/gopay/payments-sdk-php/src/Definition/Payment/PaymentItemType.php',
Expand Down
14 changes: 7 additions & 7 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@
},
{
"name": "gopay/payments-sdk-php",
"version": "v1.7.3",
"version_normalized": "1.7.3.0",
"version": "1.10.1",
"version_normalized": "1.10.1.0",
"source": {
"type": "git",
"url": "https://github.com/gopaycommunity/gopay-php-api.git",
"reference": "2643a053c66ab82efda019154a0c63c156452f48"
"reference": "c9382b0c6457a1ce55453b7ccd1099390e75bfdc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/gopaycommunity/gopay-php-api/zipball/2643a053c66ab82efda019154a0c63c156452f48",
"reference": "2643a053c66ab82efda019154a0c63c156452f48",
"url": "https://api.github.com/repos/gopaycommunity/gopay-php-api/zipball/c9382b0c6457a1ce55453b7ccd1099390e75bfdc",
"reference": "c9382b0c6457a1ce55453b7ccd1099390e75bfdc",
"shasum": ""
},
"require": {
Expand All @@ -104,7 +104,7 @@
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "9.3.7"
},
"time": "2023-09-20T12:02:41+00:00",
"time": "2024-09-24T07:45:10+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
Expand Down Expand Up @@ -138,7 +138,7 @@
],
"support": {
"issues": "https://github.com/gopaycommunity/gopay-php-api/issues",
"source": "https://github.com/gopaycommunity/gopay-php-api/tree/v1.7.3"
"source": "https://github.com/gopaycommunity/gopay-php-api/tree/1.10.1"
},
"install-path": "../gopay/payments-sdk-php"
},
Expand Down
18 changes: 9 additions & 9 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-feature/php-version-upgrade',
'version' => 'dev-feature/php-version-upgrade',
'reference' => '1d0be9d9e92cf922e0c39933a49fed2fb91589a7',
'pretty_version' => 'dev-feature/GPY025-17-new-payments',
'version' => 'dev-feature/GPY025-17-new-payments',
'reference' => 'cb5fe58376c18efde86403482a406bc4449f9156',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev' => true,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-feature/php-version-upgrade',
'version' => 'dev-feature/php-version-upgrade',
'reference' => '1d0be9d9e92cf922e0c39933a49fed2fb91589a7',
'pretty_version' => 'dev-feature/GPY025-17-new-payments',
'version' => 'dev-feature/GPY025-17-new-payments',
'reference' => 'cb5fe58376c18efde86403482a406bc4449f9156',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -29,9 +29,9 @@
'dev_requirement' => true,
),
'gopay/payments-sdk-php' => array(
'pretty_version' => 'v1.7.3',
'version' => '1.7.3.0',
'reference' => '2643a053c66ab82efda019154a0c63c156452f48',
'pretty_version' => '1.10.1',
'version' => '1.10.1.0',
'reference' => 'c9382b0c6457a1ce55453b7ccd1099390e75bfdc',
'type' => 'library',
'install_path' => __DIR__ . '/../gopay/payments-sdk-php',
'aliases' => array(),
Expand Down
33 changes: 0 additions & 33 deletions vendor/composer/platform_check.php

This file was deleted.

1 change: 1 addition & 0 deletions vendor/gopay/payments-sdk-php/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# IDE
/nbproject/
.idea
/gopay-php-api.iml

# APP
/vendor/
Expand Down
20 changes: 6 additions & 14 deletions vendor/gopay/payments-sdk-php/factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

namespace GoPay;

function payments(array $userConfig, array $userServices = [])
function payments(array|Config $userConfig, array $userServices = [])
{
$config = $userConfig + [
'scope' => Definition\TokenScope::ALL,
'language' => Definition\Language::ENGLISH,
'timeout' => 30
];
$config = Config::parseUserConfig($userConfig);
$services = $userServices + [
'cache' => new Token\InMemoryTokenCache,
'logger' => new Http\Log\NullLogger
Expand All @@ -21,17 +17,13 @@ function payments(array $userConfig, array $userServices = [])

/**
* @deprecated Supercash payments are no longer supported
* @param array $userConfig
* @param array|Config $userConfig
* @param array $userServices
* @return PaymentsSupercash
*/
function paymentsSupercash(array $userConfig, array $userServices = [])
function paymentsSupercash(array|Config $userConfig, array $userServices = [])
{
$config = $userConfig + [
'scope' => Definition\TokenScope::ALL,
'language' => Definition\Language::ENGLISH,
'timeout' => 30
];
$config = Config::parseUserConfig($userConfig);
$services = $userServices + [
'cache' => new Token\InMemoryTokenCache,
'logger' => new Http\Log\NullLogger
Expand All @@ -45,7 +37,7 @@ function paymentsSupercash(array $userConfig, array $userServices = [])
/** Symfony container needs class for factory :( */
class Api
{
public static function payments(array $config, array $services = [])
public static function payments(array|Config $config, array $services = [])
{
return payments($config, $services);
}
Expand Down
111 changes: 111 additions & 0 deletions vendor/gopay/payments-sdk-php/src/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

namespace GoPay;

use GoPay\Definition\Language;
use GoPay\Definition\TokenScope;

class Config
{
/**
* @param string|null $clientId {@see https://doc.gopay.com/#access-token}
* @param string|null $clientSecret {@see https://doc.gopay.com/#access-token}
* @param string|null $goid Default GoPay account used in `createPayment` if `target` is not specified.
* @param string|null $gatewayUrl {@see https://help.gopay.com/en/knowledge-base/integration-of-payment-gateway/integration-of-payment-gateway-1/how-do-i-integrate-the-payment-gateway}
*/
public function __construct(
public ?string $clientId = null,
public ?string $clientSecret = null,
public ?string $goid = null,
public ?string $gatewayUrl = null,
public ?string $customUserAgent = null,
) {
}

/**
* {@see https://doc.gopay.com/#access-token}
*
* @var string
*/
public string $scope = TokenScope::ALL;

/**
* Language used in `createPayment` if `lang` is not specified + used for
* {@see https://doc.gopay.com/#errors localization of errors}.
*
* @var string
*/
public string $language = Language::ENGLISH;

/**
* Browser timeout in seconds.
*
* @var int
*/
public int $timeout = 30;

/**
* @param array|Config $userConfig
* @param bool $defaultArrayValues
* @return array
*/
public static function parseUserConfig(array|Config $userConfig, bool $defaultArrayValues = true): array
{
if (is_array($userConfig)) {
if ($defaultArrayValues) {
return $userConfig + [
'scope' => TokenScope::ALL,
'language' => Language::ENGLISH,
'timeout' => 30
];
}

return $userConfig;
} else {
return $userConfig->toArray();
}
}

/**
* @param array $arr
* @return Config
*/
public static function fromArray(array $arr): Config
{
$config = new Config();

$config->goid = $arr['goid'] ?? null;
$config->clientId = $arr['clientId'] ?? null;
$config->clientSecret = $arr['clientSecret'] ?? null;
$config->gatewayUrl = $arr['gatewayUrl'] ?? null;

// Properties with default values are set only if their value is provided
if (isset($arr['scope'])) {
$config->scope = $arr['scope'];
}
if (isset($arr['language'])) {
$config->language = $arr['language'];
}
if (isset($arr['timeout'])) {
$config->timeout = $arr['timeout'];
}

return $config;
}

/**
* @return array
*/
public function toArray(): array
{
return [
'goid' => $this->goid,
'clientId' => $this->clientId,
'clientSecret' => $this->clientSecret,
'gatewayUrl' => $this->gatewayUrl,
'scope' => $this->scope,
'language' => $this->language,
'timeout' => $this->timeout,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace GoPay\Definition\Payment;

class BnplType
{
const DEFERRED_PAYMENT = 'DEFERRED_PAYMENT';
const PAY_IN_THREE = 'PAY_IN_THREE';
}
Loading

0 comments on commit 5fa9bca

Please sign in to comment.