assistance-engine/docs/developer.avapframework.com/Servicio_de_Firma_EN.md

231 lines
5.1 KiB
Markdown

This service is used to approve several operations within the system.
POST:
`URL_BASE + /ws/firma.py/firmar`
## Receives:
All the parameters that the service receives must be indicated in the body
of the request.
## Returns:
Depending on the result of the operation, this service can return two
different JSON:
### Answer JSON OK:
```javascript
{
"status"
:{' '}
true
,
"signed"
: <boolean>
,
"invoice"
: <integer>
,
"currency_data"
:{' '}
{
"abbreviation"
: <string>
,
"suffix"
: <string>
,
"format"
: <string>
,
"symbol"
: <string>
,
"prefix"
: <string>
,
"decimals"
: <decimal>
,
"id"
: <integer>
}
,
"elapsed"
: <float>
,
"raw_amount"
: <decimal>
,
"currency"
: <string>
,
"commission_user_card"
: <decimal>
,
"codtran"
: <string>
,
"user_commission"
: <decimal>
,
"amount"
: <string>
}
```
## Where:
* `status:` Shows if the call has been successful (true) or not (false).
* `signed:` Shows if the signature has been successfully processed (true) or not (false).
* `invoice:` Invoice number associated to the operation.
* `currency_data:` Contains the different details of the currency used in the operation.
* `abbreviation:` The abbreviated name of the currency (EUR, MXN).
* `suffix:` Indicates the suffix that is applied in the currency format (pesos, euros).
* `format:` The full format that is applied to the currency, it includes the suffix and the prefix.
* `symbol:` The symbol associated to the currency (€, ¢, $).
* `prefix:` The prefix that is applied in the format of the currency.
* `decimals:` The maximum number of decimal places to be included in the currency format.
* `id:` Currency identifier in BBDD.
* `elapsed:` Execution operation time.
* `raw_amount:` Amount of the operation in negative without applying the format.
* `currency:` Short name of the currency used in the operation, it matches the abbreviation.
* `commission_user_card:` Commission that would be applied if the payment is made by card.
* `codtran:` Transaction code that identifies the executed operation.
* `user_commission:` Commission to be charged to the user.
* `amount:` Negative transaction amount with the applied format.
### Answer JSON KO:
```javascript
{
"status"
:{' '}
false
,
"level"
: <string>
,
"message"
: <string>
,
"error"
: <string>
}
```
## Where:
* `status:` Shows if the call has been successful (true) or not (false).
* `level:` Error importance level.
* `message:` Error message.
* `error:` Sole error coge.
## Example requests:
### Python - Requests:
```javascript
import requests
url ={' '}
"URL_BASE/ws/firma.py/firmar"
payload ={' '}
{
'otp'
:{' '}
'1234'
,
'phone'
:{' '}
'7229063245'
,
'country_code'
:{' '}
'MX'
}
files ={' '}
[
]
headers={' '}
{
}
response = requests
.request
(
"POST"
, url
, headers
=headers
, data{' '}
= payload
, files{' '}
= files
)
print
(response
.text
.encode
(
'utf8'
)
)
```
### NodeJs - Request:
```javascript
var request = require('request');
var options = {
'method': 'POST',
'url': 'URL_BASE/ws/firma.py/firmar',
'headers': {},
formData: {
'otp': '1234',
'phone_dst': '7229063245',
'country_code': 'MX'
}
};
request(options, function (error, response) {{' '}
if (error) throw new Error(error);
console.log(response.body);
});
```
### JavaScript - Fetch:
```javascript
var formdata = new FormData();
formdata.append("otp", "1234");
formdata.append("phone_dst", "7229063245");
formdata.append("country_code", "MX");
var requestOptions = {
method: 'POST',
body: formdata,
redirect: 'follow'
};
fetch("URL_BASE/ws/firma.py/firmar", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
```
### CURL:
```javascript
curl --location --request POST{' '}
'URL_BASE/ws/firma.py/firmar'{' '}
\
--form 'otp=1234'{' '}
\
--form{' '}
'phone_dst=7229063245'{' '}
\
--form 'country_code=MX'
```
## Business logic:
This service searches for the operations pending signing that the entered
phone has, and, among the results, accepts the operation through the OTP.