Welcome to CH Payments, a simple paymentprovider wrapper for stuff you want CH to get money for. Payments makes it easy to create products, and implement it in your own website. No hassle with keys, accounts and webhooks, just a single call to initiate a payment.
Below you can find some ready-to-use code examples for your website.
The administration panel (for now) is only available for board members. They can create products to generate the keys required.
CH Payments has an API containing the following endpoints.
Requesting a payment url.
name (required) |
string | The name of the customer |
email (required) |
string | The email of the customer for the order confirmation. |
productKeys (required) |
array | Array of CH Payments products keys of the products the customer wants to order |
returnUrl |
string | The URL the customer will be redirected to after the payment process. Default: https://ch.tudelft.nl/ |
method |
string | Payment method selection. Possible values: IDEAL , SOFORT . Default: IDEAL |
mailConfirmation |
boolean | Flag if CH Payments should send a Order confirmation email. Default: true |
webhookURl |
string | Set the webhook URL, where CH Payments will send order status updates to. See section Webhook call. |
201 CREATED
- Order has been successfully created
{
"url": "<mollie-url>",
"publicReference": "1073dc09-1b53-427f-ad3f-21b1057dd254",
"status": "WAITING"
}
500 INTERNAL_SERVER_ERROR
- Something went wrong
{
"timestamp": 1537533514873,
"status": 500,
"error": "Internal Server Error",
"exception": "<exception>",
"message": "<error-message>",
"path": "/payments/api/orders"
}
Get the status of an order.
200 OK
- Successful
{
"url": "<mollie-url>",
"publicReference": "1073dc09-1b53-427f-ad3f-21b1057dd254",
"status": "WAITING"
}
500
- Something went wrong
{
"timestamp": 1537533514873,
"status": 500,
"error": "Internal Server Error",
"exception": "<exception>",
"message": "<error-message>",
"path": "/payments/api/orders"
}
The call CH Payments makes about an order status update.
{
"message": "OrderStatus update!",
"publicReference": "1073dc09-1b53-427f-ad3f-21b1057dd254"
}
No idea how to code, but still want to sell tickets on your CH site? Use one of these code examples to get going.
import requests
url = "http://localhost:9000/api/orders"
payload = {
'name': 'Thomas Ticket',
'email': '[email protected]',
'returnUrl': 'https://www.ch.tudelft.nl/payments/ordercompleted',
'productKeys': ['e44685c5-a360-467c-960d-29843a101bb1', '879941f4-43d1-4ff2-ad66-cbdf3b141cab']
}
response = requests.post(url, json=payload)
print(response.json())
The full workflow is as follows.
async function main() {
const productsRequest = await fetch('http://localhost:9000/api/products/SYMPOSIUM/2016');
const products = await productsRequest.json();
const orderRequest = await fetch('http://localhost:9000/api/orders', {
method: 'POST',
headers: {'Content-Type':'application/json'},
body: JSON.stringify({
name: 'Thomas Ticket',
email: '[email protected]',
returnUrl: 'https://www.ch.tudelft.nl/payments/ordercompleted',
productKeys: products.map(p => p.key)
})
});
const order = await orderRequest.json();
console.log(`You should redirect the user to url ${order.url}`);
// After that you can obtain the order status with:
const statusRequest = await fetch(`http://localhost:9000/api/orders/${order.publicReference}`);
const status = await statusRequest.json();
console.log(`The order status is right now ${status.status}`);
}
main();
(You can copy-paste this snippet into the Dev console of your browser to try it out. It requires Chrome 55+.
$url = 'http://localhost:9000/api/orders';
$data = [
'name' => "Thomas Ticket",
'email' => "[email protected]",
'returnUrl' => "<return-url>",
'productKeys' => [ "<product-key>", "<product-key>" ],
'method' => 'CREDIT_CARD' // options: IDEAL, CREDIT_CARD, SOFORT, PAYPAL
];
$options = [
'http' => [
'header' => [
"Content-Type:application/json",
],
'method' => "POST",
'content' => json_encode( $data ),
],
];
$response = json_decode( file_get_contents( $url, false, stream_context_create( $options ) ) );
This project currently is quite minimal, and offers lots of opportunities for great features built by you! Check out the issue page for HootHub issues, and start earning Uilenballen.
First, pick an issue and self-assign it. Make your changes in a new branch, with the following naming convention:
- Fixing a bug? > "fix-description_of_bug"
- Implementing a new feature? > "feature-description_of_feature"
Once you're satisfied with your changes, create a pull request and give it the label "Ready for review". You can assign someone in specific or wait for someone to pick it up. Make sure to include tests and documentation. If Travis isn't happy, we're not happy.
- Import the project into IntelliJ IDEA, we really recommend using IntelliJ IDEA Ultimate Edition, since it includes all the support for Spring. You could use another IDE, but we do not recommend this
- Make sure you have installed the
Lombok Plugin
- Enable annotation processing, this can be enabled in
Settings > Build, Execution, Deployment > Compiler > Annotation Processors
. Here you have to check the checkmark that saysEnable Annotation Processors
- Copy
config/application.properties.sample
toconfig/application.properties
.
You should change:
payments.molliekey
andpayments.returnUrl
to their respective keys if you have those- Add the group that you are a part of to the
payments.admin.groups
- Right click the
Application
class (src -> main -> java -> ch.wisv.payments
) and chooseRun
. Terminate the process (you don't have to wait for it to finish starting). Now go to the Run/Debug Configuration windowRun -> Edit Configurations
choose theSpring Boot
configuration calledApplication
. Enable the dev profile for this configuration by enteringdev
in theActive Profiles
box.
It is also possible to run without IntelliJ. This can be done by performing all the previous instructions 1-4
, after this run the ./gradlew dev
command.
To generate a runnable JAR file, make sure that you have followed all the instructions under the run section. When you have done so, run ./gradlew build
. This command will run all tests, and create a runnable JAR file in the ./build
folder. You could also run Build
from the gradle view in IntelliJ IDEA.
To run a docker container with payments issue the following commands:
./gradlew build
docker build -t payments
docker run -e "SPRING_PROFILES_ACTIVE=production"
-e "SPRING_MAIL_HOST=localhost" -e "SPRING_MAIL_PORT=1025"
-e "PAYMENTS_MAIL_SENDER=${MAIL_SENDER}" -e "SPRING_DATASOURCE_URL=jdbc:hsqldb:mem:payments"
-e "SPRING_DATASOURCE_USERNAME=sa" -e "SPRING_DATASOURCE_PASSWORD="
-e "PAYMENTS_MOLLIEKEY=${FILL_MOLLIEKEY_HERE}"
-e "PAYMENTS_ADMIN_GROUPS=chbeheer,bestuur,hoothub,${SOME_GROUP_YOU_ARE_IN}"
-e "PAYMENTS_ADMIN_USERNAME=${SOME_USERNAME}" -e "PAYMENTS_ADMIN_PASSWORD=${SOME_PASSWORD}"
-p 8080:8080 payments:latest
To run the container in a production environment, use the following configuration. If you are starting for the first time without an existing database present, please add -e "SPRING_JPA_HIBERNATE_DDL_AUTO=create"
to generate the database.
docker run -e "SPRING_PROFILES_ACTIVE=production"
-e "SPRING_MAIL_HOST=localhost" -e "SPRING_MAIL_PORT=1025"
-e "PAYMENTS_MAIL_SENDER=${MAIL_SENDER}" -e "SPRING_DATASOURCE_URL=jdbc:postgresql://${DATABASE_LOCATION}"
-e "SPRING_DATASOURCE_USERNAME=${DATABASE_USERNAME}" -e "SPRING_DATASOURCE_PASSWORD=${DATABASE_PASSWORD}"
-e "PAYMENTS_MOLLIEKEY=${MOLLIE_KEY}" -e "PAYMENTS_ADMIN_GROUPS=chbeheer,bestuur,hoothub,${GROUP_YOU_ARE_IN}"
-e "PAYMENTS_ADMIN_USERNAME=${ADMINISTRATOR_USERNAME}" -e "PAYMENTS_ADMIN_PASSWORD=${ADMINISTRATOR_PASSWORD}"
-p 8080:8080 payments:latest