This repository has been archived by the owner on Feb 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Add JavaScript code example #35
Merged
+39
−9
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
# CH-Payments | ||
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. | ||
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. | ||
The administration panel (for now) is only available for board members. | ||
They can create products to generate the keys required. | ||
|
||
# Code examples | ||
No idea how to code, but still want to sell tickets on your CH site? | ||
Use one of these code examples to get going. | ||
No idea how to code, but still want to sell tickets on your CH site? | ||
Use one of these code examples to get going. | ||
|
||
#### Python 3.5 | ||
```python | ||
|
@@ -31,23 +31,53 @@ print(response.json()) | |
``` | ||
|
||
#### JavaScript | ||
[Code example required](https://github.com/WISVCH/payments/issues/6) | ||
|
||
The full workflow is as follows. | ||
|
||
```js | ||
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+. | ||
|
||
#### PHP | ||
[Code example required](https://github.com/WISVCH/payments/issues/6) | ||
|
||
# HootHub | ||
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. | ||
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. | ||
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. | ||
|
||
# Running | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a note that fetch is not supported everywhere yet?