# Wiki source code of Payment

Last modified by Trieu Tran on 2019/12/04 14:12

#### Export

#### Office Formats

Export as PDF Export as ODT Export as RTF

#### Other Formats

Select the pages to export:

select all / none

Export as HTML
Show last authors

1 | = Retrieve Payment =
2 |
3 | An implementer must first perform a POST to the [[Payment Session resource>>Sandbox.payex-checkout-v1.Introduction.Payment-session.WebHome]] to begin the PayEx Checkout user flow. When done, a Payment resource will be created. Operations to perform a Capture, Cancel or Reversal transaction requests will be found within the Payment resource.
4 |
5 | The URL of the Payment is found within the Payment Session resource. [[Read about how to retrieve the payment session here.>>Sandbox.payex-checkout-v1.Introduction.Payment-session.WebHome||anchor="HRetrievePaymentSession"]] This resource requires authentication as mentioned in the [[Intro>>Sandbox.payex-checkout-v1.Introduction.WebHome||anchor="HAuthentication"]].
6 |
7 | == Example ==
8 |
9 | === Request ===
10 |
11 | {{code language="JavaScript"}}
12 | GET <payment_url> HTTP/1.1
13 | Content-Type: application/json
14 | Authorization: Bearer <access_token>
15 | {{/code}}
16 |
17 | === Response ===
18 |
19 | {{code language="JavaScript"}}
20 | {
21 | "payment": {
22 | "id": "/psp/creditcard/payments/5adc265f-f87f-4313-577e-08d3dca1a26c",
23 | "number": 1234567890,
24 | "created": "2016-09-14T13:21:29.3182115Z",
25 | "updated": "2016-09-14T13:21:57.6627579Z",
26 | "operation": "Purchase|Verify|Recur",
27 | "intent": "Authorization|AutoCapture",
28 | "state": "Ready|Pending|Failed|Aborted",
29 | "currency": "NOK|SEK|...",
30 | "amount": 1500,
31 | "remainingCaptureAmount": 1500,
32 | "remainingCancellationAmount": 1500,
33 | "remainingReversalAmount": 0,
34 | "description": "Test Purchase",
35 | "initiatingSystemUserAgent": "PostmanRuntime/3.0.1",
36 | "userAgent": "Mozilla/5.0...",
37 | "language": "nb-NO",
38 | "paymentToken": "5adc265f-f87f-4313-577e-08d3dca1a26c",
39 | "prices": {
40 | "id": "/psp/creditcard/payments/5adc265f-f87f-4313-577e-08d3dca1a26c/prices"
41 | },
42 | "transactions": {
43 | "id": "/psp/creditcard/payments/5adc265f-f87f-4313-577e-08d3dca1a26c/transactions"
44 | },
45 | "authorizations": {
46 | "id": "/psp/creditcard/payments/5adc265f-f87f-4313-577e-08d3dca1a26c/authorizations"
47 | },
48 | "captures": {
49 | "id": "/psp/creditcard/payments/5adc265f-f87f-4313-577e-08d3dca1a26c/captures"
50 | },
51 | "cancellations": {
52 | "id": "/psp/creditcard/payments/5adc265f-f87f-4313-577e-08d3dca1a26c/cancellations"
53 | },
54 | "reversals": {
55 | "id": "/psp/creditcard/payments/5adc265f-f87f-4313-577e-08d3dca1a26c/reversals"
56 | },
57 | "payeeInfo": {
58 | "id": "/psp/creditcard/payments/5adc265f-f87f-4313-577e-08d3dca1a26c/payeeInfo"
59 | },
60 | "urls": {
61 | "id": "/psp/creditcard/payments/5adc265f-f87f-4313-577e-08d3dca1a26c/urls"
62 | },
63 | },
64 | "operations": [
65 | {
66 | "href": "<capture_operation_url>",
67 | "rel": "create-checkout-capture",
68 | "method": "POST"
69 | },
70 | {
71 | "href": "<cancellation_operation_url>",
72 | "rel": "create-checkout-cancellation",
73 | "method": "POST"
74 | },
75 | {
76 | "href": "<reversal_operation_url>",
77 | "rel": "create-checkout-reversal",
78 | "method": "POST"
79 | }
80 | ]
81 | }
82 | {{/code}}
83 |
84 | = Operations =
85 |
86 | The available operations that can be performed on a Payment will be listed inside the {{code}}operations{{/code}} property. For documentation on these operations, please see below.
87 |
88 | == Capture ==
89 |
90 | To perform a Capture operation in PayEx Checkout, you find the {{code}}create-checkout-capture{{/code}} operation listed in the Payment resource. It will look something like this:
91 |
92 | {{code language="JavaScript"}}
93 | {
94 | ...
95 | "operations": [{
96 | "href": "<capture_operation_url>"
97 | "rel": "create-checkout-capture",
98 | "method": "POST"
99 | },
100 | {
101 | ...
102 | }]
103 | ...
104 | }
105 | {{/code}}
106 |
107 | === Simple capture request ===
108 |
109 | Build the Capture request by finding the {{code}}href{{/code}} and {{code}}method{{/code}} properties of the {{code}}create-checkout-capture{{/code}} operation.
110 |
111 | The simple Capture request does a full capture of the {{code}}amount{{/code}} and {{code}}fees{{/code}} specified in the [[Payment Session>>Sandbox.payex-checkout-v1.Introduction.Payment-session.WebHome]]. Unless you want to perform a partial Capture or add item descriptions, the simple Capture is the recommended way to Capture the payment.
112 |
113 | {{code language="JavaScript"}}
114 | POST <capture_operation_href> HTTP/1.1
115 | Accept: application/json
116 | Content-Type: application/json
117 | Authorization: Bearer <access_token>
118 |
119 | {
120 | "transaction": {
121 | "description": "description for the transaction"
122 | }
123 | }
124 | {{/code}}
125 |
126 | **Parameters**
127 |
128 | |(% style="text-align:right; width:131px" %)**Param** |(% style="width:1347px" %)**Details**
129 | |(% style="text-align:right; width:131px" %){{code}}description{{/code}}
130 | (% style="color:LightGrey" %)string|(% style="width:1347px" %)Description of the item you are capturing.
131 |
132 | === Advanced capture request ===
133 |
134 | If you want to Capture less than the total amount of the Payment (partial capture) or add additional item descriptions that may be printed on an invoice. The advanced Capture adds any {{code}}fees{{/code}} specified in the [[Payment Session>>Sandbox.payex-checkout-v1.Introduction.Payment-session.WebHome]]. An advanced Capture request may look something like this:
135 |
136 | {{code language="JavaScript"}}
137 | {
138 | "transaction": {
139 | "amount": 350.00,
140 | "vatAmount": 70.00, // Note: please see the valid VAT rates in the parameter description below.
141 | "description": "description for transaction"
142 | "payeeReference": "reference of the Capture. Will be shown on Invoice"
143 | },
144 | "itemDescriptions": [{
145 | "amount": 250.00,
146 | "vatAmount": 50.00, // Note: please see the valid VAT rates in the parameter description below.
147 | "itemAmount": 50.00,
148 | "quantity": 5,
149 | "description": "item description 1"
150 | },
151 | {
152 | "amount": 100.00,
153 | "vatAmount": 20.00, // Note: please see the valid VAT rates in the parameter description below.
154 | "itemAmount": 50.00,
155 | "quantity": 2,
156 | "description": "item description 2"
157 | }
158 | ]
159 | }
160 | {{/code}}
161 |
162 | **Parameters**
163 |
164 | |(% style="text-align:right" %)**Param**|**Details**
165 | |(% style="text-align:right" %){{code}}transaction.amount{{/code}}
166 | (% style="color:LightGrey" %)decimal|Total amount of the transaction (sum of ##itemDescriptions.amount##), including VAT.
167 | |(% style="text-align:right" %){{code}}transaction.vatAmount{{/code}}
168 | (% style="color:LightGrey" %)decimal|(% style="width:1764px" %)Total VAT amount of the transaction. Note: Due to legal requirements, VAT must be calculated from the following valid rates: 0%, 6%, 8%, 10%, 12%, 14%, 15%, 22%, 24% and 25%. All other VAT rates will be declined and cause an input validation error.
169 | |(% style="text-align:right" %){{code}}transaction.description{{/code}}
170 | (% style="color:LightGrey" %)string|(% style="width:1764px" %)Description of the transaction.
171 | |(% style="text-align:right" %){{code}}transaction.payeeReference{{/code}}
172 | (% style="color:LightGrey" %)string|(% style="width:1764px" %)The reference of the order capture. This reference will be visible on Invoice payment if consumer has paid with invoice. Must match the regular expression (% class="box code" %)^\w*$(%%) and be no longer than 40 characters.
173 | |(% style="text-align:right" %){{code}}itemDescriptions.amount{{/code}}
174 | (% style="color:LightGrey" %)decimal|(% style="width:1764px" %)The total amount of the items (##itemAmount * quantity##), including VAT.
175 | |(% style="text-align:right" %){{code}}itemDescriptions.vatAmount{{/code}}
176 | (% style="color:LightGrey" %)decimal|(% style="width:1764px" %)Total VAT amount of the items (not divided by quantity).
177 | |(% style="text-align:right" %){{code}}itemDescriptions.itemAmount{{/code}}
178 | (% style="color:LightGrey" %)decimal|(% style="width:1764px" %)Amount per item, VAT included.
179 | |(% style="text-align:right" %){{code}}itemDescriptions.quantity{{/code}}
180 | (% style="color:LightGrey" %)integer|(% style="width:1764px" %)Number of items.
181 | |(% style="text-align:right" %){{code}}itemDescriptions.description{{/code}}
182 | (% style="color:LightGrey" %)string|(% style="width:1764px" %)Description of the item (order line, product, shopping cart item, or similar).
183 |
184 | === Capture response ===
185 |
186 | {{code language="JavaScript"}}
187 | {
188 | "payment": "<paymentUrl>",
189 | "capture": {
190 | "id": "<paymentCaptureUurl>",
191 | "transaction": {
192 | "id": "<transactionUrl>",
193 | "created": "2016-09-14T01:01:01.01Z",
194 | "updated": "2016-09-14T01:01:01.03Z",
195 | "type": "Capture",
196 | "state": "Initialized|Completed|Failed",
197 | "number": 1234567890,
198 | "amount": 350.00,
199 | "vatAmount": 70.00,
200 | "description": "Test Capture",
201 | "payeeReference": "ABC123",
202 | "failedReason": "",
203 | "isOperational": "TRUE|FALSE",
204 | "operations": []
205 | }
206 | }
207 | }
208 | {{/code}}
209 |
210 | == Cancellation ==
211 |
212 | To perform a Cancellation operation in PayEx Checkout, you find the {{code}}create-checkout-cancellation{{/code}} operation listed in the Payment resource.
213 | It will look something like this:
214 |
215 | {{code language="JavaScript"}}
216 | ...
217 | "operations": [{
218 | "href": "<cancellation_operation_url>"
219 | "rel": "create-checkout-cancellation",
220 | "method": "POST"
221 | } ... ]
222 | ...
223 | {{/code}}
224 |
225 | === Cancellation request ===
226 |
227 | Build the Cancellation request by finding the {{code}}href{{/code}} and {{code}}method{{/code}} properties of the {{code}}create-checkout-cancellation{{/code}} operation.
228 |
229 | The Cancellation request does a full cancellation of the {{code}}amount{{/code}} and {{code}}fees{{/code}} specified in the [[Payment Session>>Sandbox.payex-checkout-v1.Introduction.Payment-session.WebHome]].
230 |
231 | {{code language="JavaScript"}}
232 | POST <cancel_operation_href> HTTP/1.1
233 | Accept: application/json
234 | Content-Type: application/json
235 | Authorization: Bearer <access_token>
236 |
237 | {
238 | "transaction": {
239 | "description": "Test Cancellation",
240 | }
241 | }
242 | {{/code}}
243 |
244 | **Parameters**
245 |
246 | |(% style="text-align:right; width:131px" %)**Param** |(% style="width:1347px" %)**Details**
247 | |(% style="text-align:right; width:131px" %){{code}}Description{{/code}}
248 | (% style="color:LightGrey" %)string|(% style="width:1347px" %)Description of the item you are canceling.
249 |
250 | === Cancel response ===
251 |
252 | {{code language="JavaScript"}}
253 | {
254 | "payment": "<paymentUrl>",
255 | "cancellation": {
256 | "id": "<paymentCancellationUrl>",
257 | "transaction": {
258 | "id": "<transactionUrl>",
259 | "created": "2016-09-14T01:01:01.01Z",
260 | "updated": "2016-09-14T01:01:01.03Z",
261 | "type": "Cancellation",
262 | "state": "Initialized|Completed|Failed",
263 | "number": 1234567890,
264 | "amount": 1000,
265 | "vatAmount": 200,
266 | "description": "Test Cancellatiopn",
267 | "payeeReference": "ABC123",
268 | "failedReason": "",
269 | "isOperational": "TRUE|FALSE",
270 | "operations": []
271 | }
272 | }
273 | }
274 | {{/code}}
275 |
276 | == Reversal ==
277 |
278 | To perform a Reversal operation in PayEx Checkout, you find the {{code}}create-checkout-reversal{{/code}} operation listed in the Payment resource.
279 | It will look something like this:
280 |
281 | {{code language="JavaScript"}}
282 | {
283 | ...
284 | "operations": [{
285 | "href": "<reversal_operation_url>",
286 | "rel": "create-checkout-reversal",
287 | "method": "POST"
288 | },
289 | {
290 | ...
291 | }]
292 | ...
293 | }
294 | {{/code}}
295 |
296 | === Reversal request ===
297 |
298 | Build the Reversal request by finding the {{code}}href{{/code}} and {{code}}method{{/code}} properties of the {{code}}create-checkout-reversal{{/code}} operation.
299 |
300 | The Reversal request does a reversal of the amount specified in the Request.
301 |
302 | {{code language="JavaScript"}}
303 | POST <reversal_operation_href> HTTP/1.1
304 | Accept: application/json
305 | Content-Type: application/json
306 | Authorization: Bearer <access_token>
307 |
308 | {
309 | "transaction": {
310 | "amount": 100.00,
311 | "vatAmount": 20.00,
312 | "description": "Test Reversal"
313 | }
314 | }
315 | {{/code}}
316 |
317 | **Parameters**
318 |
319 | |(% style="text-align:right; width:201px" %)**Param**|(% style="width:1277px" %)**Details**
320 | |(% style="text-align:right; width:201px" %){{code}}transaction.amount{{/code}}
321 | (% style="color:LightGrey" %)decimal|(% style="width:1277px" %)Total amount of the transaction vat included.
322 | |(% style="text-align:right; width:201px" %){{code}}transaction.vatAmount{{/code}}
323 | (% style="color:LightGrey" %)decimal|(% style="width:1277px" %)Total vat amount of the transaction.
324 | |(% style="text-align:right; width:201px" %){{code}}transaction.description{{/code}}
325 | (% style="color:LightGrey" %)string|(% style="width:1277px" %)Description of the transaction
326 |
327 | === Reversal response ===
328 |
329 | {{code language="JavaScript"}}
330 | {
331 | "payment": "<paymentUrl>",
332 | "reversal": {
333 | "id": "<paymentReversalUrl>",
334 | "transaction": {
335 | "id": "<transactionUrl>",
336 | "created": "2016-09-14T01: 01: 01.01Z",
337 | "updated": "2016-09-14T01: 01: 01.03Z",
338 | "type": "Capture",
339 | "state": "Initialized|Completed|Failed",
340 | "number": 1234567890,
341 | "amount": 1000,
342 | "vatAmount": 200,
343 | "description": "Testtransaction",
344 | "payeeReference": "AH123456",
345 | "failedReason": "",
346 | "isOperational": "TRUE|FALSE",
347 | "operations": []
348 | }
349 | }
350 | }
351 | {{/code}}
352 |
353 | = Problems =
354 |
355 | If a request fails, its response will have a status code between 400 and 599. The HTTP body of the response will also be in the form of an {{code}}application/problem+json{{/code}} ([[RFC 7807>>https://tools.ietf.org/html/rfc7807]]), explaining in detail why the request failed and which, if any, actions you can take to remedy the problem. You can read more about this [[here>>doc:Sandbox.payex-checkout-v1.Introduction.Problems.WebHome]].

# Applications

# Tips

If you're starting with XWiki, check out the Getting Started Guide.

# Need help?

If you need help with XWiki you can contact:

- Community Support
- Professional Support