|
1 | 1 | exports.post = ({ appSdk }, req, res) => { |
2 | 2 | /** |
3 | | - * Requests coming from the modules receive a hydrated body with two objects, `params` and application`. |
4 | | - * In `application` is a copy of your application installed by the merchant, including the properties` data` and `hidden_data`. |
5 | | - * JSON Schema of the list_payments module |
| 3 | + * Requests coming from Modules API have two object properties on body: `params` and `application`. |
| 4 | + * `application` is a copy of your app installed by the merchant, |
| 5 | + * including the properties `data` and `hidden_data` with admin settings configured values. |
| 6 | + * JSON Schema reference for the List Payments module objects: |
6 | 7 | * `params`: https://apx-mods.e-com.plus/api/v1/list_payments/schema.json?store_id=100 |
7 | 8 | * `response`: https://apx-mods.e-com.plus/api/v1/list_payments/response_schema.json?store_id=100 |
| 9 | + * |
| 10 | + * Examples in published apps: |
| 11 | + * https://github.com/ecomplus/app-pagarme/blob/master/functions/routes/ecom/modules/list-payments.js |
| 12 | + * https://github.com/ecomplus/app-custom-payment/blob/master/functions/routes/ecom/modules/list-payments.js |
8 | 13 | */ |
| 14 | + |
9 | 15 | const { params, application } = req.body |
10 | 16 | const { storeId } = req |
11 | | - |
12 | | - // merge all app options configured by merchant |
13 | | - const appData = Object.assign({}, application.data, application.hidden_data) |
14 | | - |
15 | 17 | // setup basic required response object |
16 | | - // Must follow schema: https://apx-mods.e-com.plus/api/v1/list_payments/response_schema.json?store_id=100 |
17 | 18 | const response = { |
18 | 19 | payment_gateways: [] |
19 | 20 | } |
| 21 | + // merge all app options configured by merchant |
| 22 | + const appData = Object.assign({}, application.data, application.hidden_data) |
20 | 23 |
|
21 | 24 | /* DO THE STUFF HERE TO FILL RESPONSE OBJECT WITH PAYMENT GATEWAYS */ |
22 | | - /* |
23 | | - // eg; |
24 | | - response.payment_gateways.push({ |
25 | | - intermediator: { |
26 | | - code: 'paupay', |
27 | | - link: 'https://www.paupay.com.br', |
28 | | - name: 'paupay' |
29 | | - }, |
30 | | - payment_url: 'https://www.paupay.com.br/', |
31 | | - type: 'payment', |
32 | | - payment_method: { |
33 | | - code: 'banking_billet', |
34 | | - name: 'Boleto Bancário' |
35 | | - }, |
36 | | - label: 'Boleto Bancário', |
37 | | - expiration_date: appData.banking_billet.expiration_date || 14 |
38 | | - }) |
| 25 | + |
| 26 | + /** |
| 27 | + * Sample snippets: |
| 28 | +
|
| 29 | + // add new payment method option |
| 30 | + response.payment_gateways.push({ |
| 31 | + intermediator: { |
| 32 | + code: 'paupay', |
| 33 | + link: 'https://www.palpay.com.br', |
| 34 | + name: 'paupay' |
| 35 | + }, |
| 36 | + payment_url: 'https://www.palpay.com.br/', |
| 37 | + type: 'payment', |
| 38 | + payment_method: { |
| 39 | + code: 'banking_billet', |
| 40 | + name: 'Boleto Bancário' |
| 41 | + }, |
| 42 | + label: 'Boleto Bancário', |
| 43 | + expiration_date: appData.expiration_date || 14 |
| 44 | + }) |
| 45 | +
|
39 | 46 | */ |
40 | 47 |
|
41 | 48 | res.send(response) |
|
0 commit comments