-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgerencianet-pix-charge-qrcode-workflow.yml
More file actions
136 lines (136 loc) · 4.72 KB
/
Copy pathgerencianet-pix-charge-qrcode-workflow.yml
File metadata and controls
136 lines (136 loc) · 4.72 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
arazzo: 1.0.1
info:
title: Efí Pix Immediate Charge to QR Code
summary: Create an immediate Pix charge, confirm it, and render its payable QR Code.
description: >-
The canonical Efí Pay Pix collection flow. The workflow first exchanges the
client credentials for an OAuth2 access token, then creates an immediate Pix
charge (cob) for a payer and amount, reads the charge back to confirm it is
active and to resolve the location id that the Pix specification attaches to
the charge, and finally generates the BR Code / QR Code image payload that a
payer can scan to settle the charge. 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-qrcode
summary: Create an immediate Pix charge and produce its scannable QR Code.
description: >-
Authenticates against the Pix API, creates an immediate charge for the given
payer and amount, confirms the charge is active, and renders the QR Code for
the location bound to the charge.
inputs:
type: object
required:
- clientId
- clientSecret
- amount
- pixKey
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.
amount:
type: string
description: The charge amount in BRL as a decimal string (e.g. "123.45").
pixKey:
type: string
description: The receiving Pix key (chave) that the charge is credited to.
payerCpf:
type: string
description: The CPF of the payer (devedor) for the charge.
payerName:
type: string
description: The full name of the payer (devedor) for the charge.
expiration:
type: integer
description: Seconds the charge stays valid (calendario.expiracao). Defaults to 3600.
default: 3600
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 (cob) for the payer and amount, crediting
the supplied Pix key. The server assigns a txid and a location id.
operationId: pixCreateImmediateCharge
parameters:
- name: Authorization
in: header
value: Bearer $steps.authenticate.outputs.accessToken
requestBody:
contentType: application/json
payload:
calendario:
expiracao: $inputs.expiration
devedor:
cpf: $inputs.payerCpf
nome: $inputs.payerName
valor:
original: $inputs.amount
chave: $inputs.pixKey
successCriteria:
- condition: $statusCode == 201
outputs:
txid: $response.body#/txid
locationId: $response.body#/loc/id
- stepId: confirmCharge
description: >-
Read the charge back by txid to confirm it was registered and is in the
ATIVA status before exposing its QR Code to a payer.
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
- context: $response.body
condition: $.status == "ATIVA"
type: jsonpath
outputs:
status: $response.body#/status
pixCopiaECola: $response.body#/pixCopiaECola
- stepId: generateQrCode
description: >-
Generate the QR Code image payload for the location bound to the charge so
the payer can scan it to pay.
operationId: pixGenerateQRCode
parameters:
- name: Authorization
in: header
value: Bearer $steps.authenticate.outputs.accessToken
- name: id
in: path
value: $steps.createCharge.outputs.locationId
successCriteria:
- condition: $statusCode == 200
outputs:
qrcode: $response.body#/qrcode
imagemQrcode: $response.body#/imagemQrcode
outputs:
txid: $steps.createCharge.outputs.txid
status: $steps.confirmCharge.outputs.status
pixCopiaECola: $steps.confirmCharge.outputs.pixCopiaECola
qrcode: $steps.generateQrCode.outputs.qrcode