-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgerencianet-pix-charge-revise-workflow.yml
More file actions
146 lines (146 loc) · 4.69 KB
/
Copy pathgerencianet-pix-charge-revise-workflow.yml
File metadata and controls
146 lines (146 loc) · 4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
arazzo: 1.0.1
info:
title: Efí Pix Charge Revise
summary: Create a Pix charge under a fixed txid, check its status, and revise it while still active.
description: >-
A charge-correction flow for Efí Pay Pix. The workflow authenticates, creates
an immediate Pix charge under a caller-supplied txid (PUT cob), reads the
charge back, and branches on its status: while the charge is still ATIVA it
patches the charge to a revised amount, and if the charge is no longer active
it ends without modifying it. This guards updates so a paid or expired charge
is never altered. Every step spells out its request inline so the flow can be
read and executed without opening the underlying OpenAPI description.
version: 1.0.0
sourceDescriptions:
- name: efiPixApi
url: ../openapi/efi-pix-openapi.yml
type: openapi
workflows:
- workflowId: pix-charge-revise
summary: Create a Pix charge by txid and revise its amount only while it is active.
description: >-
Authenticates, creates an immediate Pix charge under the supplied txid,
details it, and patches a revised amount only when the charge is still ATIVA.
inputs:
type: object
required:
- clientId
- clientSecret
- txid
- amount
- pixKey
- revisedAmount
properties:
clientId:
type: string
description: The OAuth2 client_id issued for the Efí Pay account.
clientSecret:
type: string
description: The OAuth2 client_secret issued for the Efí Pay account.
txid:
type: string
description: The 26-35 char transaction id to register the charge under.
amount:
type: string
description: The original charge amount in BRL as a decimal string.
pixKey:
type: string
description: The receiving Pix key (chave) the charge is credited to.
revisedAmount:
type: string
description: The corrected charge amount in BRL as a decimal string.
steps:
- stepId: authenticate
description: >-
Exchange the client_id and client_secret for an OAuth2 access token using
the client_credentials grant required by the Pix API.
operationId: pixAuthorize
requestBody:
contentType: application/json
payload:
grant_type: client_credentials
successCriteria:
- condition: $statusCode == 200
outputs:
accessToken: $response.body#/access_token
- stepId: createCharge
description: >-
Create an immediate Pix charge under the supplied txid crediting the given
Pix key for the original amount.
operationId: pixCreateCharge
parameters:
- name: Authorization
in: header
value: Bearer $steps.authenticate.outputs.accessToken
- name: txid
in: path
value: $inputs.txid
requestBody:
contentType: application/json
payload:
calendario:
expiracao: 3600
valor:
original: $inputs.amount
chave: $inputs.pixKey
successCriteria:
- condition: $statusCode == 201
outputs:
txid: $response.body#/txid
status: $response.body#/status
- stepId: detailCharge
description: >-
Read the charge back by txid and branch on its status so only an active
charge is revised.
operationId: pixDetailCharge
parameters:
- name: Authorization
in: header
value: Bearer $steps.authenticate.outputs.accessToken
- name: txid
in: path
value: $steps.createCharge.outputs.txid
successCriteria:
- condition: $statusCode == 200
outputs:
status: $response.body#/status
onSuccess:
- name: chargeActive
type: goto
stepId: reviseCharge
criteria:
- context: $response.body
condition: $.status == "ATIVA"
type: jsonpath
- name: chargeNotActive
type: end
criteria:
- context: $response.body
condition: $.status != "ATIVA"
type: jsonpath
- stepId: reviseCharge
description: >-
Patch the active charge to the revised amount, leaving the rest of the
charge intact.
operationId: pixUpdateCharge
parameters:
- name: Authorization
in: header
value: Bearer $steps.authenticate.outputs.accessToken
- name: txid
in: path
value: $steps.createCharge.outputs.txid
requestBody:
contentType: application/json
payload:
valor:
original: $inputs.revisedAmount
successCriteria:
- condition: $statusCode == 200
outputs:
revisedStatus: $response.body#/status
revisedValue: $response.body#/valor/original
outputs:
txid: $steps.createCharge.outputs.txid
status: $steps.detailCharge.outputs.status
revisedValue: $steps.reviseCharge.outputs.revisedValue