Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Multichain payment #845

Merged
merged 73 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
42690c3
init payment service
volodymyr-basiuk Nov 5, 2024
485c4b8
payment abi gen
volodymyr-basiuk Nov 5, 2024
2009e0c
add recipient
volodymyr-basiuk Nov 7, 2024
9d1eb97
Merge branch 'develop' into feat/multichain-payment
x1m3 Nov 8, 2024
e4c62ca
chore: linter
x1m3 Nov 8, 2024
8d02268
chore: Use protocol messages
x1m3 Nov 12, 2024
de4ab31
feat: Payment settings
x1m3 Nov 12, 2024
bec717b
feat: Payment settings injected in service and endpoint to return it
x1m3 Nov 12, 2024
7e4c0ac
feat: Test get payment settings
x1m3 Nov 13, 2024
8b3b041
feat: Payment options repo redone
x1m3 Nov 14, 2024
a5655a0
feat: Payment options API.
x1m3 Nov 15, 2024
ee7833e
feat: Create Payment Option test
x1m3 Nov 15, 2024
c428691
fix: API running via docker
x1m3 Nov 18, 2024
d30d1ae
chore: Test get payment option
x1m3 Nov 18, 2024
a6b8d1d
feat: Test get payment options
x1m3 Nov 18, 2024
d76f784
feat: Test remove payment options
x1m3 Nov 19, 2024
b79059d
feat: Define structure for paymentOption Config
x1m3 Nov 20, 2024
40bae14
wip: Payment request endpoint uses payment options
x1m3 Nov 21, 2024
cb95423
feat: Payload signed with kms using key
x1m3 Nov 22, 2024
726ba7a
fix: Remove not used status response
x1m3 Nov 25, 2024
1602ac9
feat: One paymentRequest object for each stable coin
x1m3 Nov 25, 2024
6d8471e
fix: Remove unwanted commented code
x1m3 Nov 25, 2024
35268d8
fix: request parsing in CreatePaymentRequest
x1m3 Nov 25, 2024
a5b2acd
fix: Amounts management. Other tests.
x1m3 Nov 26, 2024
11bb162
chore: lint
x1m3 Nov 26, 2024
3f4231b
feat: If present, use signin key in payment option config
x1m3 Nov 27, 2024
06ce29a
fix: linter
x1m3 Nov 27, 2024
e3bd7bb
chore: verifyPayment endpoint now accepts and optionid and returns ob…
x1m3 Nov 28, 2024
2a04d8e
feat: improve example
x1m3 Nov 28, 2024
a61300e
feat: Load contract from configuration and test it
x1m3 Nov 28, 2024
db3ada8
chore: Reuse protocol constants for payment request type defined in i…
x1m3 Nov 29, 2024
2c7dd00
feat: Payment request repository
x1m3 Dec 4, 2024
3580d7e
fix payment-request signature
volodymyr-basiuk Dec 4, 2024
19c8ede
big int fix
volodymyr-basiuk Dec 4, 2024
f33764d
fix ERC20 type
volodymyr-basiuk Dec 4, 2024
2569644
feat: Change payment config format file
x1m3 Dec 4, 2024
7dcd1c6
feat: Remove hack to pass private key to sign payment requests
x1m3 Dec 4, 2024
a2c6520
feat: config and payments options management
x1m3 Dec 5, 2024
f037545
remove currency
volodymyr-basiuk Dec 5, 2024
06af779
Merge remote-tracking branch 'origin/feat/multichain-payment' into fe…
x1m3 Dec 5, 2024
714bf11
feat: Implement create payment request endpoint
x1m3 Dec 9, 2024
ff20d8c
fix: Failing test.
x1m3 Dec 9, 2024
a58e756
feat: revert changes in agent endpoint.
x1m3 Dec 9, 2024
37c801e
feat: revert changes in function to extrack ethkey from vault
x1m3 Dec 9, 2024
85216e1
chore: Extra check and remove unused code
x1m3 Dec 9, 2024
296810c
chore: Remove unused NewAgentProposalRequest function
x1m3 Dec 9, 2024
7b7430f
fix verificationMethod and signature += 27
volodymyr-basiuk Dec 9, 2024
7bb30c8
fix linter
volodymyr-basiuk Dec 9, 2024
37455ab
feat: MVP for verify payment endpoint
x1m3 Dec 10, 2024
a4df756
fix signature len check
volodymyr-basiuk Dec 10, 2024
783217e
fix: payments repo GetPaymentRequestItem fixed and tested
x1m3 Dec 10, 2024
a823a07
Merge remote-tracking branch 'origin/develop' into feat/multichain-pa…
x1m3 Dec 10, 2024
ede1e0c
fix: merge conflict
x1m3 Dec 10, 2024
7f5ea11
fix IsPaymentDone (check Recipient address)
volodymyr-basiuk Dec 10, 2024
2fd4345
feat: Use RPC resolver from network resolver
x1m3 Dec 11, 2024
9007c70
feat: Verify payment handles failed and cancelled transactions
x1m3 Dec 11, 2024
2cc84ff
update ethereumClientsByChainID
volodymyr-basiuk Dec 13, 2024
83b63bb
chore: Remove protocol.Iden3PaymentRequestCryptoV1Type as we do not s…
x1m3 Dec 16, 2024
daaeebc
chore: Remove hardcoded private key from test.
x1m3 Dec 16, 2024
b2b7137
chore: Fix context.Background and remove unneeded commented test code.
x1m3 Dec 16, 2024
c404908
feat: standardise lower case letters in payment api responses
x1m3 Dec 17, 2024
e8d8158
Merge remote-tracking branch 'refs/remotes/origin/develop' into feat/…
x1m3 Dec 17, 2024
84ffd93
feat: k8s configuration
x1m3 Dec 17, 2024
0463ede
feat: Refresh schema context on the fly if not present.
x1m3 Dec 18, 2024
d767ae9
Merge remote-tracking branch 'origin/develop' into feat/multichain-pa…
x1m3 Dec 18, 2024
71fb3d7
fix: merge conflict
x1m3 Dec 18, 2024
7f2c4b6
fix: configmap
x1m3 Dec 18, 2024
f5bb512
chore: payment configuration for devel
x1m3 Dec 18, 2024
97ea05d
feat: Return payments configuration
x1m3 Dec 18, 2024
9f63af5
feat: Rename field PaymentRequestMessage.RecipientDID to userDID
x1m3 Dec 18, 2024
9b6438c
Merge remote-tracking branch 'origin/develop' into feat/multichain-pa…
x1m3 Dec 19, 2024
8cf976e
chore: sync with develop
martinsaporiti Dec 23, 2024
3062fec
chore: update migration name for payments
martinsaporiti Dec 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ bin/
.env-issuer
.env-ui
resolvers_settings.yaml
payments.yaml

infrastructure/local/.vault/data
infrastructure/local/.vault/plugins
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ RUN apk add curl
COPY --from=base ./service/api ./api
COPY --from=base ./service/bin/* ./
COPY --from=base ./service/pkg/credentials ./pkg/credentials
COPY --from=base ./service/resolvers_settings.* ./
COPY --from=base ./service/resolvers_settings.* ./
COPY --from=base ./service/payment.* ./
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ a4a1d3ec9159 redis:6-alpine "docker-entrypoint.s…" 38 sec
make private_key=<private-key> import-private-key-to-kms
```

**_TODO_**: Add section to configure payments

then visit:
* https://localhost:8088/ to access the UI (default username / password are: user-ui, password-ui). You can set them using env [vars](.env-ui.sample).
* <PUBLICLY_ACCESSIBLE_URL_POINTING_TO_ISSUER_SERVER_PORT>:3001/ to access the API. (default username / password are: user-issuer, password-issuer)
Expand Down Expand Up @@ -139,6 +141,8 @@ then modify the file with the proper values. The most important fields to run th
In this file you can define customizations for each type of blockchain and network. For this example, we only need to
define the RPCs. that will use.

**_TODO_**: Add section to configure payments****

4. Copy .env-ui sample file and fill the needed env variables:

```bash
Expand Down
311 changes: 309 additions & 2 deletions api/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,192 @@ paths:
'500':
$ref: '#/components/responses/500'

/v2/identities/{identifier}/payment-request:
post:
summary: Create Payment Request
operationId: CreatePaymentRequest
description: Create a payment request for the provided identity.
tags:
- Payment
security:
- basicAuth: [ ]
parameters:
- $ref: '#/components/parameters/pathIdentifier'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreatePaymentRequest'
responses:
'201':
description: Payment Request Created
content:
application/json:
schema:
$ref: '#/components/schemas/BasicMessage'
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
'422':
x1m3 marked this conversation as resolved.
Show resolved Hide resolved
$ref: '#/components/responses/422'
'500':
$ref: '#/components/responses/500'

/v2/payment/settings:
get:
summary: Return payment settings
operationId: GetPaymentSettings
description: Get the payment settings
tags:
- Payment
security:
- basicAuth: [ ]
responses:
'200':
description: Payment settings
content:
application/json:
schema:
$ref: '#/components/schemas/PaymentSettings'

/v2/identities/{identifier}/payment/options:
get:
summary: Get Payment Options
operationId: GetPaymentOptions
description: Get the payment options for the provided identity.
tags:
- Payment
security:
- basicAuth: [ ]
parameters:
- $ref: '#/components/parameters/pathIdentifier'
responses:
'200':
description: Payment options
content:
application/json:
schema:
$ref: '#/components/schemas/PaymentOptionsPaginated'
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
post:
summary: Create Payment Option
operationId: CreatePaymentOption
description: Create a payment option for the provided identity.
tags:
- Payment
security:
- basicAuth: [ ]
parameters:
- $ref: '#/components/parameters/pathIdentifier'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PaymentOptionRequest'
responses:
'201':
description: Payment Option Created
content:
application/json:
schema:
$ref: '#/components/schemas/UUIDResponse'
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
'422':
$ref: '#/components/responses/422'
'500':
$ref: '#/components/responses/500'

/v2/identities/{identifier}/payment/options/{id}:
get:
summary: Get Payment Option
operationId: GetPaymentOption
description: Get a specific payment option for the provided identity.
tags:
- Payment
security:
- basicAuth: [ ]
parameters:
- $ref: '#/components/parameters/pathIdentifier'
- $ref: '#/components/parameters/id'
responses:
'200':
description: Payment option
content:
application/json:
schema:
$ref: '#/components/schemas/PaymentOption'
'400':
$ref: '#/components/responses/400'
'404':
$ref: '#/components/responses/404'
'500':
$ref: '#/components/responses/500'
delete:
summary: Delete Payment Option
operationId: DeletePaymentOption
description: Remove a specific payment option for the provided identity.
tags:
- Payment
security:
- basicAuth: [ ]
parameters:
- $ref: '#/components/parameters/pathIdentifier'
- $ref: '#/components/parameters/id'
responses:
'200':
description: Payment option deleted
content:
application/json:
schema:
$ref: '#/components/schemas/GenericMessage'
'400':
$ref: '#/components/responses/400'
'500':
$ref: '#/components/responses/500'


/v2/payment/verify/{recipient}:
post:
summary: Verify Payment
operationId: VerifyPayment
description: Verify a payment.
tags:
- Payment
security:
- basicAuth: [ ]
parameters:
- $ref: '#/components/parameters/pathRecipient'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BasicMessage'
responses:
'200':
description: Payment verified
content:
application/json:
schema:
type: boolean
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'

components:
securitySchemes:
basicAuth:
Expand Down Expand Up @@ -1858,8 +2044,8 @@ components:
type: object
x-go-type: verifiable.W3CCredential
x-go-type-import:
name: verifiable
path: "github.com/iden3/go-schema-processor/v2/verifiable"
name: verifiable
path: "github.com/iden3/go-schema-processor/v2/verifiable"

AuthenticationResponse:
type: object
Expand Down Expand Up @@ -1985,6 +2171,119 @@ components:
to:
type: string

PaymentSettings:
type: object
x-go-type: payments.Settings
x-go-type-import:
name: payments
path: "github.com/polygonid/sh-id-platform/internal/payments"

PaymentOptionsPaginated:
type: object
required: [ items, meta ]
properties:
items:
$ref: '#/components/schemas/PaymentOptions'
meta:
$ref: '#/components/schemas/PaginatedMetadata'

PaymentOptions:
type: array
items:
$ref: '#/components/schemas/PaymentOption'

PaymentOption:
type: object
required:
- id
- issuerID
- name
- description
- config
- modifiedAt
- createdAt
properties:
id:
type: string
x-go-type: uuid.UUID
x-go-type-import:
name: uuid
path: github.com/google/uuid
issuerID:
type: string
name:
type: string
description:
type: string
config:
type: object
modifiedAt:
$ref: '#/components/schemas/TimeUTC'
createdAt:
$ref: '#/components/schemas/TimeUTC'

PaymentOptionRequest:
type: object
required:
- id
- issuerID
- name
- description
- config
- modifiedAt
- createdAt
properties:
name:
type: string
description:
type: string
config:
type: object

BasicMessage:
type: object
required:
- body
- id
- typ
- type
- threadID
- from
- to
properties:
id:
type: string
typ:
type: string
type:
type: string
threadID:
type: string
body:
type: null
from:
type: string
to:
type: string

CreatePaymentRequest:
type: object
required:
- signingKey
- credentialType
- credentialContext
- userDID
properties:
signingKey:
type: string
credentialType:
type: string
credentialContext:
type: string
userDID:
type: string


TimeUTC:
type: string
x-go-type: timeapi.Time
Expand Down Expand Up @@ -2287,6 +2586,14 @@ components:
description: Issuer identifier
schema:
type: string

pathRecipient:
name: recipient
in: path
required: true
description: Payment recipient address
schema:
type: string

pathClaim:
name: id
Expand Down
Loading
Loading