You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://github.com/codespaces/new/adyen-examples/adyen-php-online-payments?ref=main&devcontainer_path=.devcontainer%2Fdevcontainer.json)
This repository includes examples of PCI-compliant UI integrations for online payments with Adyen. Within this demo app, you'll find a simplified version of an e-commerce website, complete with commented code to highlight key features and concepts of Adyen's API. Check out the underlying code to see how you can integrate Adyen to give your shoppers the option to pay with their preferred payment methods, all in a seamless checkout experience.
[Online payments](https://docs.adyen.com/online-payments)**Laravel 9** demos of the following client-side integrations are currently available in this repository:
15
15
@@ -26,14 +26,57 @@ This repository includes examples of PCI-compliant UI integrations for online pa
26
26
- SEPA Direct Debit
27
27
- SOFORT
28
28
29
-
30
29
Each demo leverages Adyen's API Library for PHP ([GitHub](https://github.com/Adyen/adyen-php-api-library) | [Docs](https://docs.adyen.com/development-resources/libraries#php)).
31
30
32
31
## Requirements
33
32
34
33
PHP 8.0.0+
35
34
36
-
## Installation
35
+
## Quick Start with GitHub Codespaces
36
+
37
+
This repository is configured to work with [GitHub Codespaces](https://github.com/features/codespaces). Click the badge above to launch a Codespace with all dependencies pre-installed.
38
+
39
+
For detailed setup instructions, see the [GitHub Codespaces Instructions](https://github.com/adyen-examples/.github/blob/main/pages/codespaces-instructions.md).
40
+
41
+
### Prerequisites
42
+
43
+
Before running any example, you'll need to set up the following environment variables in your Codespace:
44
+
45
+
-`ADYEN_API_KEY` - Your Adyen API key
46
+
-`ADYEN_CLIENT_KEY` - Your Adyen client key
47
+
-`ADYEN_MERCHANT_ACCOUNT` - Your Adyen merchant account
48
+
-`ADYEN_HMAC_KEY` - Your Adyen HMAC key for webhook validation
49
+
50
+
### Setting Environment Variables
51
+
52
+
You can set environment variables using one of the following methods:
53
+
54
+
**Option 1: Create a `.env` file in the project root**
55
+
56
+
```bash
57
+
ADYEN_API_KEY="your_api_key"
58
+
ADYEN_CLIENT_KEY="your_client_key"
59
+
ADYEN_MERCHANT_ACCOUNT="your_merchant_account"
60
+
ADYEN_HMAC_KEY="your_hmac_key"
61
+
```
62
+
63
+
**Option 2: Use Codespace secrets**
64
+
65
+
1. Open your Codespace
66
+
2. Go to Settings → Secrets and variables → Codespaces
67
+
3. Add each required environment variable
68
+
4. Restart your Codespace for changes to take effect
1.Create a `./.env` file with your [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) - Remember to add `http://localhost:8080` as an origin for client key, and merchant account name (all credentials are in string format):
53
96
54
-
2. Set environment variables for the required configuration ([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), and merchant account name)
4. Visit [http://localhost:8080/](http://localhost:8080/) (**./resources/views/pages/index.blade.php**) to select an integration type.
113
+
3. Visit [http://localhost:8080/](http://localhost:8080/) to select an integration type.
72
114
73
115
To try out integrations with test card numbers and payment method details, see [Test card numbers](https://docs.adyen.com/development-resources/test-cards/test-card-numbers).
74
116
75
-
## Testing webhooks
117
+
**Note**
76
118
77
-
Webhooks deliver asynchronous notifications and it is important to test them during the setup of your integration. You can find more information about webhooks in [this detailed blog post](https://www.adyen.com/blog/Integrating-webhooks-notifications-with-Adyen-Checkout).
119
+
The demo supports cancellation and refunds, processing the incoming [Adyen webhook notifications](https://docs.adyen.com/development-resources/webhooks). Make sure webhooks are enabled and processed (see below).
78
120
79
-
This sample application provides a simple webhook integration exposed at `/api/webhooks/notifications`. For it to work, you need to:
121
+
# Webhooks
80
122
81
-
1. Provide a way for the Adyen platform to reach your running application
82
-
2. Add a Standard webhook in your Customer Area
123
+
Webhooks deliver asynchronous notifications about the payment status and other events that are important to receive and process.
83
124
84
-
### Making your server reachable
125
+
You can find more information about webhooks in [this blog post](https://www.adyen.com/blog/Integrating-webhooks-notifications-with-Adyen-Checkout).
85
126
86
-
Your endpoint that will consume the incoming webhook must be publicly accessible.
127
+
### Webhook setup
87
128
88
-
There are typically 2 options:
89
-
* deploy on your own cloud provider
90
-
* expose your localhost with tunneling software (i.e. ngrok)
129
+
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`.
91
130
92
-
#### Option 1: cloud deployment
93
-
If you deploy on your cloud provider (or your own public server) the webhook URL will be the URL of the server
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/).
97
132
98
-
#### Option 2: localhost via tunneling software
99
-
If you use a tunneling service like [ngrok](ngrok) the webhook URL will be the generated URL (ie `https://c991-80-113-16-28.ngrok.io`)
133
+
Make sure the webhook is **enabled**, so it can receive notifications.
This demo provides a simple webhook implementation exposed at `/api/webhooks/notifications` that shows you how to receive, validate and consume the webhook payload.
111
138
112
-
**Note:** when restarting ngrok a new URL is generated, make sure to **update the Webhook URL** in the Customer Area
139
+
### Test your webhook
113
140
114
-
### Set up a webhook
141
+
The following webhooks `events` should be enabled:
115
142
116
-
* In the Customer Area go to Developers -> Webhooks and create a new 'Standard notification' webhook.
117
-
* Enter the URL of your application/endpoint (see options [above](#making-your-server-reachable))
118
-
* Define username and password for Basic Authentication
119
-
* Generate the HMAC Key
120
-
* Optionally, in Additional Settings, add the data you want to receive. A good example is 'Payment Account Reference'.
121
-
* Make sure the webhook is **Enabled** (therefore it can receive the notifications)
143
+
***AUTHORISATION**
122
144
123
-
That's it! Every time you perform a new payment, your application will receive a notification from the Adyen platform.
145
+
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).
0 commit comments