Skip to content

Commit

Permalink
Merge branch 'release/1.0.2'
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.json
  • Loading branch information
remcotolsma committed Aug 27, 2019
2 parents 83a5574 + 742e93f commit 8e0143d
Show file tree
Hide file tree
Showing 22 changed files with 388 additions and 407 deletions.
3 changes: 2 additions & 1 deletion .scrutinizer.yml
@@ -1,10 +1,11 @@
build:
environment:
php: 7.3.0
variables:
WP_TESTS_DB_NAME: 'wp_phpunit_tests'
WP_TESTS_DB_USER: 'root'
WP_TESTS_DB_PASS: ''
WP_TESTS_DB_HOST: 'localhost'
WP_TESTS_DB_HOST: '127.0.0.1'
project_setup:
before:
- mysql -e "CREATE DATABASE wp_phpunit_tests"
Expand Down
4 changes: 3 additions & 1 deletion .travis.yml
Expand Up @@ -18,7 +18,9 @@ env:
jobs:
include:
- php: 7.3
env: WP_VERSION=^5.1 COVERAGE=1 PHPCS=1 PHPSTAN=1 PSALM=1 SYMFONY_SECURITY_CHECK=1
env: WP_VERSION=^5.2 COVERAGE=1 PHPCS=1 PHPSTAN=1 PSALM=1 SYMFONY_SECURITY_CHECK=1
- php: 7.3
env: WP_VERSION=^5.1
- php: 7.3
env: WP_VERSION=^5.0
- php: 7.2
Expand Down
10 changes: 8 additions & 2 deletions CHANGELOG.md
Expand Up @@ -7,12 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased][unreleased]
-

## 1.0.1 - 2019-05-14
## [1.0.2] - 2019-08-27
- Set country from billing address.
- Added action `pronamic_pay_adyen_checkout_head`.
- Added `pronamic_pay_adyen_config_object` filter and improved documentation.

## [1.0.1] - 2019-05-14
- Remove path from origin URL in payment session request.
- Fix API live URL prefix setting not saved.

## 1.0.0 - 2019-03-28
- First release.

[unreleased]: https://github.com/wp-pay-gateways/adyen/compare/1.0.1...HEAD
[unreleased]: https://github.com/wp-pay-gateways/adyen/compare/1.0.2...HEAD
[1.0.2]: https://github.com/wp-pay-gateways/adyen/compare/1.0.1...1.0.2
[1.0.1]: https://github.com/wp-pay-gateways/adyen/compare/1.0.0...1.0.1
64 changes: 63 additions & 1 deletion README.md
Expand Up @@ -28,6 +28,59 @@ The WordPress REST API Adyen notifications endpoint can be tested with for examp
curl --request POST --user username:password http://pay.test/wp-json/pronamic-pay/adyen/v1/notifications
```

## WordPress Filters

### pronamic_pay_adyen_checkout_head

```php
add_action( 'pronamic_pay_adyen_checkout_head', 'custom_adyen_checkout_head', 15 );

function custom_adyen_checkout_head() {
wp_register_style(
'custom-adyen-checkout-style',
get_stylesheet_directory_uri() . '/css/adyen-checkout.css',
array(),
'1.0.0'
);

wp_print_styles( 'custom-adyen-checkout-style' );
}
```

### pronamic_pay_adyen_config_object

```php
add_filter( 'pronamic_pay_adyen_config_object', 'custom_adyen_config_object', 15 );

function custom_adyen_config_object( $config_object ) {
$style_object = (object) array(
'base' => (object) array(
'color' => '#000',
'fontSize' => '14px',
'lineHeight' => '14px',
'fontSmoothing' => 'antialiased',
),
'error' => (object) array(
'color' => 'red',
),
'placeholder' => (object) array(
'color' => '#d8d8d8',
),
'validated' => (object) array(
'color' => 'green',
),
);

$config_object->paymentMethods = (object) array(
'card' => (object) array(
'sfStyles' => $style_object,
),
);

return $config_object;
}
```

## Production Environment

**Dashboard URL:** https://ca-live.adyen.com/
Expand All @@ -38,6 +91,15 @@ curl --request POST --user username:password http://pay.test/wp-json/pronamic-pa
**Dashboard URL:** https://ca-test.adyen.com/
**API URL:** https://checkout-test.adyen.com/v41/

## Frequently Asked Questions

### Why do I get the "Unable to instantiate the payment screen" notice?

**Adyen** says on **August 12, 2019**:

> The "Unable to instantiate the payment screen" appears when Adyen doesn't have any available payment methods to display in our SDK.
>
> Bancontact is exclusive to Belgium and I can see you in `/paymentSession​` request, you set `"countryCode" : "NL"​`. Could you try setting this to `BE​`, then you should be able to see BCMC.
## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fwp-pay-gateways%2Fadyen.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fwp-pay-gateways%2Fadyen?ref=badge_large)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fwp-pay-gateways%2Fadyen.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fwp-pay-gateways%2Fadyen?ref=badge_large)
12 changes: 6 additions & 6 deletions composer.json
Expand Up @@ -32,27 +32,27 @@
"sort-packages": true
},
"require": {
"php": ">=5.6.0",
"php": ">=5.6.20",
"ext-intl": "*",
"justinrainbow/json-schema": "^5.2",
"pronamic/wp-money": "^1.2",
"wp-pay/core": "^2.1"
"wp-pay/core": "^2.2"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"overtrue/phplint": "^1.1",
"php-coveralls/php-coveralls": "^2.1",
"phpcompatibility/php-compatibility": "^9.1",
"phpcompatibility/php-compatibility": "^9.2",
"phpcompatibility/phpcompatibility-wp": "^2.0",
"phpmd/phpmd": "^2.6",
"phpunit/phpunit": "^5.7",
"roots/wordpress": "^5.1",
"roots/wordpress": "^5.2",
"squizlabs/php_codesniffer": "^3.4",
"wp-coding-standards/wpcs": "^2.1",
"wp-phpunit/wp-phpunit": "^5.1"
"wp-phpunit/wp-phpunit": "^5.2"
},
"scripts": {
"coveralls": "vendor/bin/coveralls -v",
"coveralls": "vendor/bin/php-coveralls -v",
"phpcbf": "vendor/bin/phpcbf",
"phpcs": "vendor/bin/phpcs -s -v",
"phplint": "vendor/bin/phplint",
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "adyen",
"version": "1.0.1",
"version": "1.0.2",
"description": "Adyen driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
2 changes: 0 additions & 2 deletions phpcs.xml.dist
Expand Up @@ -26,8 +26,6 @@
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>

<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar" />

<exclude name="WordPress.Security.SafeRedirect.wp_redirect_wp_redirect"/>
</rule>

Expand Down
2 changes: 1 addition & 1 deletion pronamic-pay-adyen.php
Expand Up @@ -26,7 +26,7 @@
add_filter(
'pronamic_pay_gateways',
function( $gateways ) {
$gateways[] = '\Pronamic\WordPress\Pay\Gateways\Adyen\Integration';
$gateways[] = new \Pronamic\WordPress\Pay\Gateways\Adyen\Integration();

return $gateways;
}
Expand Down
40 changes: 0 additions & 40 deletions src/ConfigFactory.php

This file was deleted.

87 changes: 71 additions & 16 deletions src/Gateway.php
Expand Up @@ -30,13 +30,6 @@
* @since 1.0.0
*/
class Gateway extends Core_Gateway {
/**
* Slug of this gateway.
*
* @var string
*/
const SLUG = 'adyen';

/**
* Web SDK version.
*
Expand All @@ -62,8 +55,11 @@ public function __construct( Config $config ) {
parent::__construct( $config );

$this->set_method( self::METHOD_HTTP_REDIRECT );
$this->set_slug( self::SLUG );

// Supported features.
$this->supports = array();

// Client.
$this->client = new Client( $config );
}

Expand Down Expand Up @@ -118,6 +114,17 @@ public function start( Payment $payment ) {

$country_code = Locale::getRegion( $locale );

// Set country from billing address.
$billing_address = $payment->get_billing_address();

if ( null !== $billing_address ) {
$country = $billing_address->get_country_code();

if ( ! empty( $country ) ) {
$country_code = $country;
}
}

/*
* API Integration
*
Expand Down Expand Up @@ -183,11 +190,18 @@ public function start( Payment $payment ) {

PaymentRequestHelper::complement( $payment, $payment_session_request );

$origin = sprintf(
'%s://%s',
wp_parse_url( home_url(), PHP_URL_SCHEME ),
wp_parse_url( home_url(), PHP_URL_HOST )
);
// Origin.
$origin = home_url();

$origin_url = wp_parse_url( home_url() );

if ( is_array( $origin_url ) && isset( $origin_url['scheme'], $origin_url['host'] ) ) {
$origin = sprintf(
'%s://%s',
$origin_url['scheme'],
$origin_url['host']
);
}

$payment_session_request->set_origin( $origin );
$payment_session_request->set_sdk_version( self::SDK_VERSION );
Expand Down Expand Up @@ -225,6 +239,10 @@ public function payment_redirect( Payment $payment ) {
return;
}

if ( empty( $payment->config_id ) ) {
return;
}

$url = sprintf(
'https://checkoutshopper-%s.adyen.com/checkoutshopper/assets/js/sdk/checkoutSDK.%s.min.js',
( self::MODE_TEST === $payment->get_mode() ? 'test' : 'live' ),
Expand All @@ -241,19 +259,45 @@ public function payment_redirect( Payment $payment ) {
false
);

/**
* Config object.
*
* @link https://docs.adyen.com/checkout/web-sdk/
* @link https://docs.adyen.com/checkout/web-sdk/customization/settings/
* @link https://docs.adyen.com/checkout/web-sdk/customization/styling/#styling-the-card-fields
*/
$config_object = (object) array(
'context' => ( self::MODE_TEST === $payment->get_mode() ? 'test' : 'live' ),
);

/**
* Filters the Adyen config object.
*
* @link https://github.com/wp-pay-gateways/adyen#pronamic_pay_adyen_config_object
* @link https://docs.adyen.com/checkout/web-sdk/
* @link https://docs.adyen.com/checkout/web-sdk/customization/settings/
* @link https://docs.adyen.com/checkout/web-sdk/customization/styling/#styling-the-card-fields
*
* @param object $config_object Adyen config object.
*
* @since 1.1
*/
$config_object = apply_filters( 'pronamic_pay_adyen_config_object', $config_object );

wp_localize_script(
'pronamic-pay-adyen-checkout',
'pronamicPayAdyenCheckout',
array(
'paymentsResultUrl' => rest_url( Integration::REST_ROUTE_NAMESPACE . '/payments/result/' . $payment->config_id ),
'paymentReturnUrl' => $payment->get_return_url(),
'paymentSession' => $payment_session,
'configObject' => array(
'context' => ( self::MODE_TEST === $payment->get_mode() ? 'test' : 'live' ),
),
'configObject' => $config_object,
)
);

// Add checkout head action.
add_action( 'pronamic_pay_adyen_checkout_head', array( $this, 'checkout_head' ) );

// No cache.
Core_Util::no_cache();

Expand All @@ -262,6 +306,17 @@ public function payment_redirect( Payment $payment ) {
exit;
}

/**
* Checkout head.
*
* @return void
*/
public function checkout_head() {
wp_print_styles( 'pronamic-pay-redirect' );

wp_print_scripts( 'pronamic-pay-adyen-checkout' );
}

/**
* Update status of the specified payment.
*
Expand Down

0 comments on commit 8e0143d

Please sign in to comment.