Skip to content

Commit

Permalink
Merge branch 'release/4.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Jan 11, 2022
2 parents 70c8c9e + 7c2422b commit 142cfa0
Show file tree
Hide file tree
Showing 39 changed files with 393 additions and 278 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -285,32 +285,3 @@ jobs:
run: |
composer run-script coveralls
bash <(curl -s https://codecov.io/bash)
es-sass-linting:
name: Scripts and Styles

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

# https://github.com/actions/cache/blob/master/examples.md#macos-and-ubuntu
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v1
with:
node-version: '12'

- name: Install Node packages
run: npm install

- name: ESLint
run: npm run-script eslint

- name: Sass Lint
run: npm run-script sass-lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@

# WordPress
/wordpress/
/wp-content/
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [4.0.0] - 2022-01-11
### Changed
- Updated to https://github.com/pronamic/wp-pay-core/releases/tag/4.0.0.
- Improved credit card support.

## [3.0.0] - 2021-08-05
- Updated to `pronamic/wp-pay-core` version `3.0.0`.
- Updated to `pronamic/wp-money` version `2.0.0`.
Expand Down Expand Up @@ -69,8 +74,9 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0 - 2015-01-19
- First release.

[unreleased]: https://github.com/wp-pay-gateways/multisafepay/compare/3.0.0...HEAD
[3.0.0]: https://github.com/wp-pay-gateways/multisafepay/compare/3.0.0...3.0.0
[unreleased]: https://github.com/wp-pay-gateways/multisafepay/compare/4.0.0...HEAD
[4.0.0]: https://github.com/wp-pay-gateways/multisafepay/compare/3.0.0...4.0.0
[3.0.0]: https://github.com/wp-pay-gateways/multisafepay/compare/2.1.3...3.0.0
[2.1.3]: https://github.com/wp-pay-gateways/multisafepay/compare/2.1.2...2.1.3
[2.1.2]: https://github.com/wp-pay-gateways/multisafepay/compare/2.1.1...2.1.2
[2.1.1]: https://github.com/wp-pay-gateways/multisafepay/compare/2.1.0...2.1.1
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"require": {
"php": ">=5.6.20",
"ext-simplexml": "*",
"wp-pay/core": "^3.0"
"wp-pay/core": "^4.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
Expand All @@ -44,7 +44,8 @@
"phpunit/phpunit": "^5.7 || ^6.0",
"pronamic/wp-coding-standards": "^1.0",
"roots/wordpress": "^5.8",
"wp-phpunit/wp-phpunit": "^5.8"
"wp-phpunit/wp-phpunit": "^5.8",
"yoast/phpunit-polyfills": "^1.0"
},
"scripts": {
"coveralls": "vendor/bin/php-coveralls -v",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "multisafepay",
"version": "3.0.0",
"version": "4.0.0",
"description": "MultiSafepay driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Title: MultiSafepay Connect client
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Title: MultiSafepay config
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
2 changes: 1 addition & 1 deletion src/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Title: MultiSafepay Connect customer
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
98 changes: 62 additions & 36 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Title: MultiSafepay Connect gateway
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down Expand Up @@ -61,6 +61,7 @@ public function __construct( Config $config ) {
* Get iDEAL issuers
*
* @see Core_Gateway::get_issuers()
* @return array<array<string,array>>
* @since 1.2.0
*/
public function get_issuers() {
Expand All @@ -87,14 +88,17 @@ public function get_issuers() {
* Get credit card issuers
*
* @see Core_Gateway::get_credit_card_issuers()
* @return array<array<string,array>>
*/
public function get_credit_card_issuers() {
$groups[] = array(
'options' => array(
Methods::AMEX => _x( 'AMEX', 'Payment method name', 'pronamic_ideal' ),
Methods::MAESTRO => _x( 'Maestro', 'Payment method name', 'pronamic_ideal' ),
Methods::MASTERCARD => _x( 'MASTER', 'Payment method name', 'pronamic_ideal' ),
Methods::VISA => _x( 'VISA', 'Payment method name', 'pronamic_ideal' ),
// Get active card issuers.
$issuers = \array_intersect_key( $this->get_gateways(), Methods::get_cards() );

sort( $issuers );

$groups = array(
array(
'options' => $issuers,
),
);

Expand All @@ -105,40 +109,28 @@ public function get_credit_card_issuers() {
* Get payment methods
*
* @see Core_Gateway::get_payment_methods()
* @return array<string>
*/
public function get_available_payment_methods() {
$payment_methods = array();

// Merchant.
$merchant = new Merchant();
$merchant->account = $this->config->account_id;
$merchant->site_id = $this->config->site_id;
$merchant->site_secure_code = $this->config->site_code;

// Customer.
$customer = new Customer();

// Get gateways.
try {
$result = $this->client->get_gateways( $merchant, $customer );
} catch ( \Exception $e ) {
$error = new \WP_Error( 'multisafepay_error', $e->getMessage() );

$this->set_error( $error );

return $payment_methods;
}
$gateways = $this->get_gateways();

if ( false === $result ) {
return $payment_methods;
}

foreach ( $result as $method => $title ) {
foreach ( $gateways as $method => $title ) {
$payment_method = Methods::transform_gateway_method( $method );

if ( $payment_method ) {
$payment_methods[] = $payment_method;
// Handle cards, as no general method for credit cards is returned by gateway.
if ( null === $payment_method && \array_key_exists( $method, Methods::get_cards() ) ) {
$payment_method = PaymentMethods::CREDIT_CARD;
}

// Check valid payment method.
if ( null === $payment_method ) {
continue;
}

// Add available payment method.
$payment_methods[] = $payment_method;
}

return $payment_methods;
Expand All @@ -148,6 +140,7 @@ public function get_available_payment_methods() {
* Get supported payment methods
*
* @see Core_Gateway::get_supported_payment_methods()
* @return array<string>
*/
public function get_supported_payment_methods() {
return array(
Expand All @@ -174,7 +167,7 @@ public function get_supported_payment_methods() {
* @param Payment $payment Payment object.
*/
public function start( Payment $payment ) {
$payment_method = $payment->get_method();
$payment_method = $payment->get_payment_method();

$transaction_description = $payment->get_description();

Expand Down Expand Up @@ -220,7 +213,7 @@ public function start( Payment $payment ) {
case PaymentMethods::IDEAL:
$transaction->gateway = Methods::IDEAL;

$issuer = $payment->get_issuer();
$issuer = $payment->get_meta( 'issuer' );

if ( empty( $issuer ) ) {
$message = new RedirectTransactionRequestMessage( $merchant, $customer, $transaction );
Expand All @@ -236,7 +229,7 @@ public function start( Payment $payment ) {
case PaymentMethods::CREDIT_CARD:
$gateway = Methods::transform( $payment_method );

$issuer = $payment->get_issuer();
$issuer = $payment->get_meta( 'issuer' );

if ( empty( $issuer ) ) {
if ( $gateway ) {
Expand Down Expand Up @@ -338,4 +331,37 @@ public function update_status( Payment $payment ) {
$consumer_bank_details->set_bic( $result->payment_details->account_bic );
$consumer_bank_details->set_account_number( $result->payment_details->account_id );
}

/**
* Get gateways.
*
* @return array<string, string>
*/
private function get_gateways() {
// Merchant.
$merchant = new Merchant();
$merchant->account = $this->config->account_id;
$merchant->site_id = $this->config->site_id;
$merchant->site_secure_code = $this->config->site_code;

// Customer.
$customer = new Customer();

// Get gateways.
$gateways = array();

try {
$result = $this->client->get_gateways( $merchant, $customer );

if ( false !== $result ) {
$gateways = $result;
}
} catch ( \Exception $e ) {
$error = new \WP_Error( 'multisafepay_error', $e->getMessage() );

$this->set_error( $error );
}

return $gateways;
}
}
2 changes: 1 addition & 1 deletion src/GatewayInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Title: MultiSafepay Connect gateway info
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
16 changes: 10 additions & 6 deletions src/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Title: MultiSafepay Connect integration
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down Expand Up @@ -49,10 +49,15 @@ public function __construct( $args = array() ) {
}
}

/**
* Get settings fields.
*
* @return array
*/
public function get_settings_fields() {
$fields = array();

// Account ID
// Account ID.
$fields[] = array(
'section' => 'general',
'filter' => FILTER_SANITIZE_STRING,
Expand All @@ -68,7 +73,7 @@ public function get_settings_fields() {
),
);

// Site ID
// Site ID.
$fields[] = array(
'section' => 'general',
'filter' => FILTER_SANITIZE_STRING,
Expand All @@ -84,7 +89,7 @@ public function get_settings_fields() {
),
);

// Site Security Code
// Site Security Code.
$fields[] = array(
'section' => 'general',
'filter' => FILTER_SANITIZE_STRING,
Expand All @@ -106,8 +111,7 @@ public function get_settings_fields() {
/**
* Get config.
*
* @param $post_id
*
* @param int $post_id Gateway configuration post ID.
* @return Config
*/
public function get_config( $post_id ) {
Expand Down
2 changes: 1 addition & 1 deletion src/Merchant.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Title: MultiSafepay Connect merchant
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
Loading

0 comments on commit 142cfa0

Please sign in to comment.