Weitere ähnliche Inhalte Mehr von Nordic APIs (20) Kürzlich hochgeladen (20) PayEx Demo – Integration time2. What we have
• A fluffy webshop
• 8 purchasable, adorable, fluffy animals
• Mocked purchase flow
8. TODO: Retrieve POST URL
GET /psp/checkout HTTP/1.1
Authorization: Bearer efee34ef79…461f78f51034ef11
Host: api.payex.com
{
"authorized": true,
"paymentSession": "https://…/…/payment-sessions",
}
9. TODO: Retrieve POST URL
GET /psp/checkout HTTP/1.1
Authorization: Bearer efee34ef79…461f78f51034ef11
Host: api.payex.com
{
"authorized": true,
"paymentSession": "https://…/…/payment-sessions",
}
10. TODO: Perform HTTP POST request
POST /psp/checkout/payment-sessions HTTP/1.1
Authorization: Bearer efee34ef79…461f78f51034ef11
Host: api.payex.com
{
"amount": 199.50,
"vatAmount": 199.50,
"currency": "NOK",
"callbackUrl": "https://merchant.api/callback",
"reference": "order-1234",
"culture": "en-US",
"fees": {
"invoice": {
"amount": 199.50,
"vatAmount": 199.50,
"description": "Sending dead trees is expensive, yo!",
}
}
}
11. TODO: Retrieve ID URL
HTTP/1.1 201 Created
{
"id": "https://api.payex.com/…/payment-sessions/8fe1c93",
"amount": 199.50,
"vatAmount": 199.50,
"currency": "NOK",
"callbackUrl": "https://merchant.api/callback",
"reference": "order-1234",
"culture": "en-US",
"fees": {
"invoice": {
"amount": 199.50,
"vatAmount": 199.50,
"description": "Sending dead trees is expensive, yo!",
}
}
}
12. TODO: Retrieve ID URL
HTTP/1.1 201 Created
{
"id": "https://api.payex.com/…/payment-sessions/8fe1c93",
"amount": 199.50,
"vatAmount": 199.50,
"currency": "NOK",
"callbackUrl": "https://merchant.api/callback",
"reference": "order-1234",
"culture": "en-US",
"fees": {
"invoice": {
"amount": 199.50,
"vatAmount": 199.50,
"description": "Sending dead trees is expensive, yo!",
}
}
}
13. TODO: Add ID URL to Purchase Button
<button type="submit"
disabled>Buy me!</button>
14. TODO: Add ID URL to Purchase Button
<button type="submit"
data-payex-checkout="https://…/payment-sessions/8fe1c93"
disabled>Buy me!</button>
15. TODO: Retrieve Payment URL
GET https://…/…/payment-sessions/8fe1c93 HTTP/1.1
Authorization: Bearer efee34ef79…461f78f51034ef11
Host: api.payex.com
{
"id": "https://…/…/payment-sessions/8fe1c93",
"amount": 199.50,
"vatAmount": 199.50,
︙
"payment": "https://…/…/payments/f57eb662",
}
16. TODO: Retrieve Payment URL
GET https://…/…/payment-sessions/8fe1c93 HTTP/1.1
Authorization: Bearer efee34ef79…461f78f51034ef11
Host: api.payex.com
{
"id": "https://…/…/payment-sessions/8fe1c93",
"amount": 199.50,
"vatAmount": 199.50,
︙
"payment": "https://…/…/payments/f57eb662",
}
17. TODO: Retrieve Capture Operation
GET https://…/…/payments/f57eb662 HTTP/1.1
Authorization: Bearer efee34ef79…461f78f51034ef11
Host: api.payex.com
{
"id": "https://…/…/payments/f57eb662",
︙
"operations": [{
"rel": "create-checkout-capture",
"href": " https://…/…/f57eb662/captures",
"method": "POST",
}]
}
18. TODO: Retrieve Capture Operation
GET https://…/…/payments/f57eb662 HTTP/1.1
Authorization: Bearer efee34ef79…461f78f51034ef11
Host: api.payex.com
{
"id": "https://…/…/payments/f57eb662",
︙
"operations": [{
"rel": "create-checkout-capture",
"href": " https://…/…/f57eb662/captures",
"method": "POST",
}]
}
19. TODO: Capture the payment
POST /…/payment-sessions/f57eb662/captures HTTP/1.1
Authorization: Bearer efee34ef79…461f78f51034ef11
Host: api.payex.com
{
"transaction": {
"description": "Show me the money!"
}
}
Hinweis der Redaktion Show how the "barebones" version of the webshop looks like Manually retrieve an Access Token from PayEx Admin that can perform Invoice, Credit Card and Checkout payment operations.
Add the JavaScript to the <head> of the HTML page that displays the purchasable items. In the Purchase <button> elements for each purchasable item, add a disabled attribute; PayEx Checkout will enable the button when it is initialized.
In the Purchase <button> elements for each purchasable item, add a disabled attribute; PayEx Checkout will enable the button when it is initialized.
Demo time!
Hat tip to Spaceballs’ “State Of The Art” You can reach me on:
Twitter
E-mail
Slack. Join the HTTP API slack! It's full of great people in love with the web and APIs.