-
Couldn't load subscription status.
- Fork 101
fix(point-of-sale): added bruno script + added missing env variables to local docker compose file #3629
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
fix(point-of-sale): added bruno script + added missing env variables to local docker compose file #3629
Changes from 3 commits
606d215
14728c4
b824561
77b3c62
69bf632
2c17a92
e08e900
d6743f1
49e5ae3
73e0c3c
91402d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| meta { | ||
| name: Initiate Payment | ||
| type: http | ||
| seq: 3 | ||
| } | ||
|
|
||
| post { | ||
| url: http://localhost:3008/payment | ||
| body: json | ||
| auth: inherit | ||
| } | ||
|
|
||
| body:json { | ||
| { | ||
| "card": { | ||
| "walletAddress": "http://cloud-nine-wallet-backend/accounts/gfranklin", | ||
| "trasactionCounter": 1, | ||
| "expiry": "2025-09-13T13:00:00Z" | ||
| }, | ||
| "signature": "signature", | ||
| "value": 1, | ||
| "merchantWalletAddress": "http://localhost:3000/accounts/gfranklin" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,10 @@ services: | |||||
| LOG_LEVEL: debug | ||||||
| CARD_SERVICE_PORT: 3007 | ||||||
| DATABASE_URL: postgresql://cloud_nine_wallet_card_service:cloud_nine_wallet_card_service@shared-database/cloud_nine_wallet_card_service | ||||||
| GRAPHQL_URL: http://cloud-nine-wallet-backend:3001/graphql | ||||||
| TENANT_ID: 438fa74a-fa7d-4317-9ced-dde32ece1787 | ||||||
| TENANT_SECRET: tenant_secret | ||||||
|
||||||
| TENANT_SIGNATURE_VERSION: tenant_signature_version | ||||||
|
||||||
| TENANT_SIGNATURE_VERSION: tenant_signature_version | |
| TENANT_SIGNATURE_VERSION: 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -454,7 +454,7 @@ export class App { | |
| // For tests, we still need to get the tenant in the middleware, but | ||
| // we don't need to verify the signature nor prevent replay attacks | ||
| koa.use( | ||
| this.config.env !== 'test' | ||
| this.config.env !== 'test' && this.config.env !== 'development' | ||
|
||
| ? tenantSignatureMiddleware | ||
| : testTenantSignatureMiddleware | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ async function payment( | |
| ctx: PaymentContext | ||
| ): Promise<void> { | ||
| const body = ctx.request.body | ||
| const tenantId = ctx.request.header['tenant-id'] as string | undefined | ||
| try { | ||
| const walletAddress = await deps.paymentService.getWalletAddress( | ||
| body.card.walletAddress | ||
|
|
@@ -73,7 +74,8 @@ async function payment( | |
| } | ||
| const incomingPayment = await deps.paymentService.createIncomingPayment( | ||
| walletAddress.id, | ||
|
||
| incomingAmount | ||
| incomingAmount, | ||
| tenantId | ||
| ) | ||
| const deferred = new Deferred<WebhookBody>() | ||
| webhookWaitMap.setWithExpiry( | ||
|
|
@@ -101,6 +103,7 @@ async function payment( | |
| ctx.body = result | ||
| ctx.status = 200 | ||
| } catch (err) { | ||
| deps.logger.debug(err) | ||
| if (err instanceof IncomingPaymentEventTimeoutError) | ||
| webhookWaitMap.delete(err.incomingPaymentId) | ||
| const { body, status } = handlePaymentError(err) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,8 @@ import { IAppConfig } from '../config/app' | |
| import { ApolloClient, NormalizedCacheObject } from '@apollo/client' | ||
| import { | ||
| AmountInput, | ||
| CreateIncomingPaymentInput, | ||
| IncomingPayment, | ||
| MutationCreateIncomingPaymentArgs, | ||
| type Mutation | ||
| } from '../graphql/generated/graphql' | ||
| import { FnWithDeps } from '../shared/types' | ||
|
|
@@ -37,7 +37,8 @@ export type WalletAddress = OpenPaymentsWalletAddress & { | |
| export type PaymentService = { | ||
| createIncomingPayment: ( | ||
| walletAddressId: string, | ||
| incomingAmount: AmountInput | ||
| incomingAmount: AmountInput, | ||
| tenantId?: string | ||
| ) => Promise<IncomingPayment> | ||
| getWalletAddress: (walletAddressUrl: string) => Promise<WalletAddress> | ||
| } | ||
|
|
@@ -66,19 +67,28 @@ export function createPaymentService( | |
| const createIncomingPayment: FnWithDeps< | ||
| ServiceDependencies, | ||
| PaymentService['createIncomingPayment'] | ||
| > = async (deps, walletAddressId, incomingAmount) => { | ||
| > = async (deps, walletAddressId, incomingAmount, tenantId) => { | ||
| const client = deps.apolloClient | ||
| const { data } = await client.mutate< | ||
| Mutation['createIncomingPayment'], | ||
| CreateIncomingPaymentInput | ||
| MutationCreateIncomingPaymentArgs | ||
| >({ | ||
| mutation: CREATE_INCOMING_PAYMENT, | ||
| variables: { | ||
| walletAddressId, | ||
| incomingAmount, | ||
| idempotencyKey: v4(), | ||
| isCardPayment: true | ||
| } | ||
| input: { | ||
| walletAddressId, | ||
| incomingAmount, | ||
| idempotencyKey: v4(), | ||
| isCardPayment: true | ||
| } | ||
| }, | ||
| ...(tenantId && { | ||
| context: { | ||
| headers: { | ||
| 'tenant-id': tenantId | ||
| } | ||
| } | ||
| }) | ||
|
||
| }) | ||
|
|
||
| const incomingPayment = data?.payment | ||
|
|
@@ -101,7 +111,8 @@ async function getWalletAddress( | |
| ): Promise<WalletAddress> { | ||
| const config: AxiosRequestConfig = { | ||
| headers: { | ||
| 'Content-Type': 'application/json' | ||
| Accept: 'application/json', | ||
| host: 'cloud-nine-wallet-backend' | ||
| } | ||
| } | ||
| const { data: walletAddress } = await deps.axios.get< | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this, such that the incoming payment will be on the happy-life side of things, and cloud nine will pay into it.