Skip to content

Commit

Permalink
Merge branch 'release/2.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Apr 3, 2020
2 parents f7e393d + b565355 commit a583832
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 4 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Expand Up @@ -7,6 +7,10 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [2.1.2] - 2020-04-03
- Fixed install issues on some specific WordPress installations.
- Add initial Apple Pay support.

## [2.1.1] - 2020-03-19
- Force a specific collate to fix "Illegal mix of collations" error.

Expand Down Expand Up @@ -141,7 +145,8 @@ 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/mollie/compare/2.1.1...HEAD
[unreleased]: https://github.com/wp-pay-gateways/mollie/compare/2.1.2...HEAD
[2.1.2]: https://github.com/wp-pay-gateways/mollie/compare/2.1.1...2.1.2
[2.1.1]: https://github.com/wp-pay-gateways/mollie/compare/2.1.0...2.1.1
[2.1.0]: https://github.com/wp-pay-gateways/mollie/compare/2.0.10...2.1.0
[2.0.10]: https://github.com/wp-pay-gateways/mollie/compare/2.0.9...2.0.10
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "mollie",
"version": "2.1.1",
"version": "2.1.2",
"description": "Mollie driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
4 changes: 3 additions & 1 deletion src/Client.php
Expand Up @@ -223,7 +223,9 @@ public function get_issuers() {
* @throws \Exception Throws exception for methods on failed request or invalid response.
*/
public function get_payment_methods( $sequence_type = '' ) {
$data = array();
$data = array(
'includeWallets' => Methods::APPLE_PAY,
);

if ( '' !== $sequence_type ) {
$data['sequenceType'] = $sequence_type;
Expand Down
1 change: 1 addition & 0 deletions src/Gateway.php
Expand Up @@ -201,6 +201,7 @@ public function get_available_payment_methods() {
*/
public function get_supported_payment_methods() {
return array(
PaymentMethods::APPLE_PAY,
PaymentMethods::BANCONTACT,
PaymentMethods::BANK_TRANSFER,
PaymentMethods::BELFIUS,
Expand Down
36 changes: 35 additions & 1 deletion src/Install.php
Expand Up @@ -266,6 +266,18 @@ private function add_foreign_keys() {
private function add_foreign_key( $item ) {
global $wpdb;

/**
* Suppress errors.
*
* We suppress errors because adding foreign keys to for example
* a `$wpdb->users` MyISAM table will trigger the following error:
*
* "Error in query (1005): Can't create table '●●●●●●●●. # Sql-●●●●●●●●●●' (errno: 150)"
*
* @link https://github.com/WordPress/WordPress/blob/5.3/wp-includes/wp-db.php#L1544-L1559
*/
$suppress_errors = $wpdb->suppress_errors( true );

/**
* Check if foreign key exists
*
Expand Down Expand Up @@ -303,6 +315,8 @@ private function add_foreign_key( $item ) {
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query is prepared.
$result = $wpdb->query( $item->query );

$wpdb->suppress_errors( $suppress_errors );

if ( false === $result ) {
throw new \Exception(
\sprintf(
Expand All @@ -313,6 +327,8 @@ private function add_foreign_key( $item ) {
);
}
}

$wpdb->suppress_errors( $suppress_errors );
}

/**
Expand Down Expand Up @@ -356,6 +372,24 @@ private function convert_user_meta() {
);
}

/**
* Collate caluse.
*
* Force a specific collate to fix:
* "Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and
* (utf8mb4_unicode_520_ci,IMPLICIT) for operation '='. ".
*
* @link https://dev.mysql.com/doc/refman/8.0/en/charset-collate.html
*/
$collate_clause = '';

if ( ! empty( $wpdb->collate ) ) {
$collate_clause = \sprintf(
'COLLATE %s',
$wpdb->collate
);
}

$query = "
INSERT IGNORE INTO $wpdb->pronamic_pay_mollie_customer_users (
customer_id,
Expand All @@ -368,7 +402,7 @@ private function convert_user_meta() {
$wpdb->pronamic_pay_mollie_customers AS mollie_customer
INNER JOIN
$wpdb->usermeta AS wp_user_meta
ON wp_user_meta.meta_value = mollie_customer.mollie_id COLLATE $wpdb->collate
ON wp_user_meta.meta_value = mollie_customer.mollie_id $collate_clause
INNER JOIN
$wpdb->users AS wp_user
ON wp_user_meta.user_id = wp_user.ID
Expand Down
8 changes: 8 additions & 0 deletions src/Methods.php
Expand Up @@ -23,6 +23,13 @@
* @since 1.0.0
*/
class Methods {
/**
* Constant for the Apple Pay method.
*
* @var string
*/
const APPLE_PAY = 'applepay';

/**
* Constant for the Bancontact method.
*
Expand Down Expand Up @@ -126,6 +133,7 @@ class Methods {
* @var array<string>
*/
private static $map = array(
PaymentMethods::APPLE_PAY => self::APPLE_PAY,
PaymentMethods::BANCONTACT => self::BANCONTACT,
PaymentMethods::BANK_TRANSFER => self::BANKTRANSFER,
PaymentMethods::CREDIT_CARD => self::CREDITCARD,
Expand Down

0 comments on commit a583832

Please sign in to comment.