Changes for page API

Last modified by David Persson on 2022/08/11 10:43
From empty
To version 18.1
edited by David Persson
on 2020/01/17 00:13
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,0 +1,1 @@
1 +API
Parent
... ... @@ -1,0 +1,1 @@
1 +Main.credit-account.WebHome
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.XWikiGuest
1 +xwiki:XWiki.dap
Default language
... ... @@ -1,0 +1,1 @@
1 +en
Tags
... ... @@ -1,0 +1,1 @@
1 +px-custom-page-content
Content
... ... @@ -1,0 +1,162 @@
1 +(% class="jumbotron" %)
2 +(((
3 +(% class="container" %)
4 +(((
5 +Integrate to **PayEx Credit Account API **
6 +)))
7 +)))
8 +
9 +== ChangeLog ==
10 +
11 +
12 +== Glossary ==
13 +
14 +*
15 +
16 +== Introduction ==
17 +
18 +The credit-account functions i divided in three different apis.
19 +
20 +* [[Acquiring>>doc:.credit-account-acquiring.WebHome]] - Functions to create reservations and transactions on an account.
21 +* [[Onboarding>>doc:.credit-account-onboardings.WebHome]] - Functions to list possible account types, onboard/create new accounts including the signing process
22 +* [[Account >>doc:.credit-account.WebHome]]- Functions to view details and interact with a specific account
23 +
24 +=== API resources overview ===
25 +
26 +[[image:1579214873530-759.png||height="639" width="350"]]
27 +
28 +=== REST-full pattern guidance ===
29 +
30 +(% class="lead" %)
31 +The resources follows REST-full patterns including hyper-media links, we use hyper-media and backend-for-frontend principles to impose business rules and reduce duplication of business logic. Errors uses HTTP friendly status codes as well as detailed "problem+json" responses.
32 +
33 +----
34 +
35 +==== Basic resources ====
36 +
37 +(% class="box" %)
38 +(((
39 +//Basic resources uses the common HTTP patterns for GET, POST, PUT, PATCH, DELETE.//
40 +)))
41 +
42 +Requests __**without**__ specific resource identifier - f.ex. /ledger/credit-account/v1/XXX/accounts
43 +
44 +* HTTP GET - Returns a list of resources
45 +* HTTP POST - Creates a new resource
46 +
47 +Requests __**with**__ specific //__resource identifier__// - f.ex. /ledger/credit-account/v1/XXX/accounts///__1234568__//
48 +
49 +* HTTP GET - Returns a specific resource
50 +* HTTP PUT - Updates a specific resource
51 +* HTTP PATCH - Partially updates a specific resource
52 +* HTTP DELETE - Deletes a specific resource
53 +
54 +==== Operation resources ====
55 +
56 +(% class="box" %)
57 +(((
58 +//Functions that cannot be mapped directly to resources are called "Operation Resources" they only support HTTP POST//.
59 +)))
60 +
61 +Requests __**without**__ specific resource identifier operates on the list
62 +
63 +* HTTP POST - f.ex. /ledger/credit-account/v1/XXX/accounts/generate-summary - Generates a summary
64 +
65 +Requests __**with**__ specific resource identifier operates on a resource
66 +
67 +* HTTP POST - f.ex. /ledger/credit-account/v1/XXX/accounts/1234568/initiates-termination - Starts termination of an account
68 +
69 +==== Hyper-media response ====
70 +
71 +The response will include a list of operations that is possible to perform. Below is an example when a HTTP-GET Request is issued to retrieve information on an account. The response includes an "operations" property with a list of possible possible operations. The list of operations returned only contains business-rule and access-control validated operations. In the sample below the only allowed way to interact with the resource is to issue "patch" requests to modify fields. Different states as well as access permissions on the resource affect which operations are returned.
72 +
73 +
74 +{{code language="javascript" title="**Hyper-media response sample**"}}
75 +{
76 + "@id": "/ledger/credit-account/v1/501/accounts/1234567", //Resource identifier
77 + //Fields...
78 + "operations" : [
79 + {
80 + "rel" : "partial-update",
81 + "method" : "patch",
82 + "href" : "/ledger/credit-account-onboardings/v1/501/accounts/123456"
83 + }
84 + ]
85 +}
86 +{{/code}}
87 +
88 +
89 +(% class="box successmessage" %)
90 +(((
91 +**Tip:** As an implementing consumer of the api **operations** should be taken into consideration rather than trying to determine possible operation based on other basic resource properties. By following this tip we: minimize duplication of business logic, simplify maintenance when business rules change, have a clear separation of concerns.
92 +)))
93 +
94 +----
95 +
96 +=== Problems ===
97 +
98 +(% class="box" %)
99 +(((
100 +Errors uses HTTP friendly status codes as well as detailed "problem+json" responses. All errors that can be avoided by the client is in the **"HTTP status 4XX"** ragne, all errors that must be fixed by payex is in the **"HTTP status 5XX"** range. All errors contains an instance-id, the instance-id should be provided in support questions to simplify the support process.
101 +)))
102 +
103 +
104 +If an error occur or any validation failed, a "problem" response will be returned.
105 +Below is a list of problems that can occur:
106 +
107 +**HttpStatus 401 Unauthorized**
108 +
109 +* Token expired
110 +* Token invalid
111 +* SellerNumber does not match token
112 +* CompanyNumber does not match token
113 +
114 +**HttpStatus 400 Error**
115 +
116 +* Validation: Argument required
117 +* Validation: Invalid value
118 +
119 +**HttpStatus 422 Unprocessable entity**
120 +
121 +* Authorization declined
122 +
123 +**HttpStatus 409 Conflict**
124 +
125 +* Invoice already authorized
126 +* Duplicate InvoiceNumber
127 +* Authorization is cancelled
128 +* Authorization already captured
129 +* Authorization has expired
130 +* Insufficient debited amount XXX
131 +
132 +**HttpStatus 501 NotImplemented**
133 +
134 +* CompanyNumber XXX not configured
135 +* SellerNumber XXX not configured at PayEx
136 +* CompanyNumber XXX missing configuration
137 +
138 +**HttpStatus 404 NotFound**
139 +
140 +* Authorization not found
141 +
142 +==== Sample ====
143 +
144 +Below is an example of a problem that will be returned if buyer##.nationalConsumerIdentifier.value## is not valid in the authorization post request.
145 +
146 +{{code language="http" title="**Response**"}}
147 +HTTP/1.1 400 Error
148 +Content-Type: application/problem+json
149 +
150 +{
151 + "Type": "http://[DNS]/ledger/invoice-purchase/problems/validation",
152 + "Title": "A validation error occurred",
153 + "Status": 400, //Fel status code..
154 + "Instance": "dd07e588-70c8-4b27-95f5-020cc2968c06",
155 + "Detail": "A validation error occurred. Please fix the problems mentioned in the 'problems' property below.",
156 + "Problems": [
157 + {
158 + "buyer.nationalConsumerIdentifier.value": "Not a valid SE nationalConsumerIdentifier"
159 + }
160 + ]
161 +}
162 +{{/code}}
1579214755752-602.png
Author
... ... @@ -1,0 +1,1 @@
1 +xwiki:XWiki.dap
Size
... ... @@ -1,0 +1,1 @@
1 +0 bytes
Content
1579214873530-759.png
Author
... ... @@ -1,0 +1,1 @@
1 +xwiki:XWiki.dap
Size
... ... @@ -1,0 +1,1 @@
1 +0 bytes
Content