diff --git a/CHANGELOG.md b/CHANGELOG.md index 4459af5..420f45b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. @@ -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 diff --git a/package.json b/package.json index 373a23c..8b41e8f 100644 --- a/package.json +++ b/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", diff --git a/src/Client.php b/src/Client.php index 973679c..bc2f163 100644 --- a/src/Client.php +++ b/src/Client.php @@ -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; diff --git a/src/Gateway.php b/src/Gateway.php index 162f4b5..bb1c7af 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -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, diff --git a/src/Install.php b/src/Install.php index 18d9d49..c971443 100644 --- a/src/Install.php +++ b/src/Install.php @@ -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 * @@ -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( @@ -313,6 +327,8 @@ private function add_foreign_key( $item ) { ); } } + + $wpdb->suppress_errors( $suppress_errors ); } /** @@ -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, @@ -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 diff --git a/src/Methods.php b/src/Methods.php index 0eb31aa..744fe53 100644 --- a/src/Methods.php +++ b/src/Methods.php @@ -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. * @@ -126,6 +133,7 @@ class Methods { * @var array */ private static $map = array( + PaymentMethods::APPLE_PAY => self::APPLE_PAY, PaymentMethods::BANCONTACT => self::BANCONTACT, PaymentMethods::BANK_TRANSFER => self::BANKTRANSFER, PaymentMethods::CREDIT_CARD => self::CREDITCARD,