Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Adyen.Web Dropin/Components V6 #352

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/e2e-checkout-advanced.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,30 @@ on:
- 'checkout-example-advanced/**'

jobs:
# e2e testing with Adyen.Web Drop-in/Components v5 (see /_archive/v5 folder)
checkout-advanced-v5:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x checkout-example-advanced/_archive/v5/gradlew
- name: Build checkout-example-advanced/v5 with Gradle
run: cd checkout-example-advanced/_archive/v5; ./gradlew build
- name: Build checkout-example-advanced image
run: docker build -t checkout-example-advanced-v5:latest -f ./checkout-example-advanced/_archive/v5/Dockerfile ./checkout-example-advanced/_archive/v5
- name: Start checkout-example-advanced container
run: docker run --rm -d --name checkout-example-advanced-v5 -p 8080:8080 -e ADYEN_API_KEY="${{ secrets.ADYEN_API_KEY }}" -e ADYEN_MERCHANT_ACCOUNT=${{ secrets.ADYEN_MERCHANT_ACCOUNT }} -e ADYEN_CLIENT_KEY=${{ secrets.ADYEN_CLIENT_KEY }} -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} checkout-example-advanced-v5:latest
- name: Run testing suite
run: docker run --rm --name adyen-testing-suite -e PLAYWRIGHT_FOLDERNAME=advanced-checkout/v5 -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} --network host ghcr.io/adyen-examples/adyen-testing-suite:main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting PLAYWRIGHT_FOLDERNAME=advanced-checkout/v5 is correct, but the E2E testing for Advanced Flow needs to be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one has been updated, I've added the v6 e2e tests in the same e2e-checkout-advanced.yml-file


checkout-advanced:
# e2e testing with Adyen.Web Drop-in/Components v6
checkout-advanced-v6:
runs-on: ubuntu-latest
steps:
- name: Checkout project
Expand All @@ -33,3 +55,4 @@ jobs:
run: docker run --rm -d --name checkout-example-advanced -p 8080:8080 -e ADYEN_API_KEY="${{ secrets.ADYEN_API_KEY }}" -e ADYEN_MERCHANT_ACCOUNT=${{ secrets.ADYEN_MERCHANT_ACCOUNT }} -e ADYEN_CLIENT_KEY=${{ secrets.ADYEN_CLIENT_KEY }} -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} checkout-example-advanced:latest
- name: Run testing suite
run: docker run --rm --name adyen-testing-suite -e PLAYWRIGHT_FOLDERNAME=advanced-checkout -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} --network host ghcr.io/adyen-examples/adyen-testing-suite:main

1 change: 0 additions & 1 deletion checkout-example-advanced/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
FROM amazoncorretto:17-alpine-jdk
MAINTAINER jlengrand
COPY build/libs/adyen-java-spring-online-payments-checkout-advanced-0.0.1-SNAPSHOT.jar adyen-java-spring-online-payments-checkout-advanced-0.0.1-SNAPSHOT.jar
Kwok-he-Chu marked this conversation as resolved.
Show resolved Hide resolved
ENTRYPOINT ["java","-jar","/adyen-java-spring-online-payments-checkout-advanced-0.0.1-SNAPSHOT.jar"]
3 changes: 3 additions & 0 deletions checkout-example-advanced/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Adyen [Online Payments](https://docs.adyen.com/online-payments) Integration Demo - Advanced Flow

Checkout advanced sample application using `Adyen.Web Drop-in/Components v6.x.x`, (see [folder /_archive/v5](./_archive/v5) to access the previous version using `Adyen.Web Drop-in/Components v5.x.x`).


[![Java CI with Gradle](https://github.com/adyen-examples/adyen-java-spring-online-payments/actions/workflows/build-checkout-advanced.yml/badge.svg)](https://github.com/adyen-examples/adyen-java-spring-online-payments/actions/workflows/build-checkout-advanced.yml)
[![E2E (Playwright)](https://github.com/adyen-examples/adyen-java-spring-online-payments/actions/workflows/e2e-checkout-advanced.yml/badge.svg)](https://github.com/adyen-examples/adyen-java-spring-online-payments/actions/workflows/e2e-checkout-advanced.yml)

Expand Down
42 changes: 42 additions & 0 deletions checkout-example-advanced/_archive/v5/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
3 changes: 3 additions & 0 deletions checkout-example-advanced/_archive/v5/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM amazoncorretto:17-alpine-jdk
COPY build/libs/adyen-java-spring-online-payments-checkout-advanced-0.0.1-SNAPSHOT.jar adyen-java-spring-online-payments-checkout-advanced-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/adyen-java-spring-online-payments-checkout-advanced-0.0.1-SNAPSHOT.jar"]
106 changes: 106 additions & 0 deletions checkout-example-advanced/_archive/v5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Sample app with Adyen Adyen Web 5.68.0.

This folder contains the **previous version** of the sample application that uses **Adyen Web 5.68.x**.

**Check the root folder of the repository to use the latest version of Adyen Web/Components 6.x.x**

# Adyen [Online Payments](https://docs.adyen.com/online-payments) Integration Demo - Advanced Flow

[![Java CI with Gradle](https://github.com/adyen-examples/adyen-java-spring-online-payments/actions/workflows/build-checkout-advanced.yml/badge.svg)](https://github.com/adyen-examples/adyen-java-spring-online-payments/actions/workflows/build-checkout-advanced.yml)
[![E2E (Playwright)](https://github.com/adyen-examples/adyen-java-spring-online-payments/actions/workflows/e2e-checkout-advanced.yml/badge.svg)](https://github.com/adyen-examples/adyen-java-spring-online-payments/actions/workflows/e2e-checkout-advanced.yml)

## Run demo in one-click

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/adyen-examples/adyen-java-spring-online-payments/tree/main/checkout-example-advanced)
 [First time with Gitpod?](https://github.com/adyen-examples/.github/blob/main/pages/gitpod-get-started.md)

## Description
This repository showcases a PCI-compliant integration of the **Advanced Flow**. Explore this simplified e-commerce demo to discover the code, libraries and configuration you need to enable various payment options in your checkout experience.

It includes a **Java + Spring Boot + Thymeleaf** application that supports [Adyen Drop-in and Components](https://docs.adyen.com/online-payments/build-your-integration)
(ACH, Alipay, Cards, Dotpay, iDEAL, Klarna, PayPal, etc..) using the Adyen's API Library for Java ([GitHub](https://github.com/Adyen/adyen-java-api-library)).


> **Note:**
For a simpler flow using `/sessions`, check out the demo in the [`checkout-example`](../checkout-example) folder.

![Card checkout demo](src/main/resources/static/images/cardcheckout.gif)


## Requirements

- [Adyen API Credentials](https://docs.adyen.com/development-resources/api-credentials/)
- Java 17
- Network access to Maven central

## 1. Installation

```
git clone https://github.com/adyen-examples/adyen-java-spring-online-payments.git
```

## 2. Set the environment variables
* [API key](https://docs.adyen.com/user-management/how-to-get-the-api-key)
* [Client Key](https://docs.adyen.com/user-management/client-side-authentication)
* [Merchant Account](https://docs.adyen.com/account/account-structure)
* [HMAC Key](https://docs.adyen.com/development-resources/webhooks/verify-hmac-signatures)

On Linux/Mac/Windows export/set the environment variables.
```shell
export ADYEN_API_KEY=yourAdyenApiKey
export ADYEN_MERCHANT_ACCOUNT=yourAdyenMerchantAccount
export ADYEN_CLIENT_KEY=yourAdyenClientKey
export ADYEN_HMAC_KEY=yourHmacKey
```

Alternatively, it's possible to define the variables in the `application.properties`.
```txt
ADYEN_API_KEY=yourAdyenApiKey
ADYEN_MERCHANT_ACCOUNT=yourAdyenMerchantAccount
ADYEN_CLIENT_KEY=yourAdyenClientKey
ADYEN_HMAC_KEY=yourHmacKey
```

## 3. Configure allowed origins (CORS)

It is required to specify the domain or URL of the web applications that will make requests to Adyen.

In the Customer Area add `http://localhost:8080` in the list of Allowed Origins associated with the Client Key.

## 4. Run the application

```
cd checkout-example

./gradlew bootRun
```

Visit [http://localhost:8080/](http://localhost:8080/) to choose an integration type.

Try out the different payment methods with our [test card numbers](https://docs.adyen.com/development-resources/test-cards/test-card-numbers) and other payment method details.

# Webhooks

Webhooks deliver asynchronous notifications about the payment status and other events that are important to receive and process.
You can find more information about webhooks in [this blog post](https://www.adyen.com/knowledge-hub/consuming-webhooks).

### Webhook setup

In the Customer Area under the `Developers → Webhooks` section, [create](https://docs.adyen.com/development-resources/webhooks/#set-up-webhooks-in-your-customer-area) a new `Standard webhook`.

A good practice is to set up basic authentication, copy the generated HMAC Key and set it as an environment variable. The application will use this to verify the [HMAC signatures](https://docs.adyen.com/development-resources/webhooks/verify-hmac-signatures/).

Make sure the webhook is **enabled**, so it can receive notifications.

### Expose an endpoint

This demo provides a simple webhook implementation exposed at `/api/webhooks/notifications` that shows you how to receive, validate and consume the webhook payload.

### Test your webhook

The following webhooks `events` should be enabled:
* **AUTHORISATION**


To make sure that the Adyen platform can reach your application, we have written a [Webhooks Testing Guide](https://github.com/adyen-examples/.github/blob/main/pages/webhooks-testing.md)
that explores several options on how you can easily achieve this (e.g. running on localhost or cloud).
34 changes: 34 additions & 0 deletions checkout-example-advanced/_archive/v5/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
id 'org.springframework.boot' version '3.3.4'
id 'io.spring.dependency-management' version '1.1.6'

id 'java'
}

group = 'com.adyen'
version = '0.0.1-SNAPSHOT'

sourceCompatibility = 17
targetCompatibility = 17

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
implementation 'com.adyen:adyen-java-api-library:32.0.0'

developmentOnly 'org.springframework.boot:spring-boot-devtools'

testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}

}

test {
useJUnitPlatform()
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Mon May 22 09:48:27 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading