Skip to content

Commit

Permalink
Merge pull request #84 from mojaloop/dev
Browse files Browse the repository at this point in the history
feat: implemented merchant payments and added timeout config in mtn-ug-connector
  • Loading branch information
elijah0kello authored Jan 10, 2025
2 parents eddef6e + f9d6d00 commit c041e31
Show file tree
Hide file tree
Showing 27 changed files with 411 additions and 99 deletions.
Empty file modified .husky/pre-push
100644 → 100755
Empty file.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ This command also creates a new branch for the core connector. For this connecto

> Do not commit directly to main. Only work on the core connector you created or are assigned to. This will prevent merge conflicts
# Developer Commands
Here are some commands to manage this repo of connectors.

Running pre push checks
```bash
npm run check:pre-push
```

Installing dependencies in all connectors
```bash
npm run dep:install-all
```

Updating the dependencies in all connectors
```bash
npm run dep:update-all
```

# Customizing the core connector
To refactor the newly created core connector refer to the core connector template guide [here](./docs/README.md).

39 changes: 39 additions & 0 deletions core-connector-template/docs/payer-merchant-payment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Payer Initiate Merchant Payment
This sequence diagram details the process of initiating a merchant payment and the steps the core connector takes to initiate a payment in the mojaloop connector.


```mermaid
sequenceDiagram
autoNumber
DFSP Customer App->>CC: POST /merchant-payment/ {}
CC->>CC: Check Request
Alt if Checks fail
CC-->>DFSP Customer App: Response 400
End
CC->>ML Connector: POST /transfer /{amountType: RECEIVE}
ML Connector-->>CC: Response
CC->> CC: Check Response
Alt if Checks fail
CC-->>DFSP Customer App: Response 500
End
Alt if WAITING_FOR_CONVERSION_ACCEPTANCE
ML Connector-->>CC: Response: ConversionRate
CC->>CC: Check Conversion Terms
Alt if Conversion Terms are invalid
CC->>ML Connector: PUT /transfers/{id}[aceeptConversion: false]
CC-->>DFSP Customer App: Response 500
End
CC->>ML Connector: PUT /transfers/{id}[aceeptConversion: true]
End
ML Connector-->>CC:Response, Normal Quote
Alt if response not successful
CC-->>DFSP Customer App: Response 500
End
CC->>CC: Check Returned Quote
Alt if Quote is incorrect
CC-->>DFSP Customer App: Response 500
End
CC-->>DFSP Customer App: Response 200
DFSP Customer App->>DFSP Customer App:Show terms of transfer to customer
```
2 changes: 1 addition & 1 deletion core-connector-template/docs/payer-send-money.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sequenceDiagram
Alt if Checks fail
CC-->>DFSP Customer App: Response 400
End
CC->>ML Connector: POST /transfer /{}
CC->>ML Connector: POST /transfer /{amountType: SEND}
ML Connector-->>CC: Response
CC->> CC: Check Response
Alt if Checks fail
Expand Down
35 changes: 35 additions & 0 deletions core-connector-template/docs/payer-update-merchant-payment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Payer Update Merchant Payment
This sequence diagram details the process of updating an initiated merchant payment and the steps the core connector takes to initiate a payment in the mojaloop connector.

```mermaid
sequenceDiagram
autoNumber
DFSP Customer App->>CC: POST /merchant-payment/{id}/acceptQuote=true | false
CC->>CC: Check acceptQuote
Alt If Quote not Accepted
CC-->>DFSP Customer App: Response 500 OK
End
CC->>CBS Api:POST /merchant/v2/payments
CBS Api-->>CC:Response
CC-->CC: Check Response
Alt If Couldnt make reservation
CC-->>DFSP Customer App: Response 500
End
CBS Api->>CC: PUT /callback
CC->>CC: Check payment status
Alt If Transaction Successful
CC->>ML Connector:PUT /transfers/{id} {acceptQuote = true}
Else
CC->>ML Connector:PUT /transfers/{id} {acceptQuote = false}
End
ML Connector-->>CC: Response
CC->>CC: Check response
Alt if http error code 500 or 504 or currentState = ERROR_OCCURED
CC->>CBS Api : Rolback transfer POST /standard/v2/payments/refund
CBS Api-->>CC:Check Response
Alt if Response not Successful
CC->>CC: Initiate manual refund
End
End
CC-->> CBS Api: Response 200
```
126 changes: 63 additions & 63 deletions core-connector-template/src/api-spec/core-connector-api-spec-dfsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ paths:
tags:
- Health
responses:
'200':
"200":
description: >-
Returns empty body if the scheme adapter outbound transfers service
is running.
/send-money:
post:
summary: Send Money endpoint
description: >-
description: >-
The Endpoint used by the DFSP Operations application to initiate send money
requests to the mojaloop connector
Expand All @@ -57,7 +57,7 @@ paths:
tags:
- Send Money
responses:
'200':
"200":
description: >-
Response for send money request. A quote if it is double
integration or a payment status response if it is single
Expand All @@ -66,13 +66,13 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/sendMoneyResponse"
'400':
"400":
description: >-
Response for a bad request.
'500':
"500":
description: >-
Response for an internal server error
'504':
"504":
description: >-
Response for a timed out transfer
/send-money/{transferId}:
Expand All @@ -92,18 +92,19 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ConfirmSendMoney'
$ref: "#/components/schemas/ConfirmSendMoney"
tags:
- Send Money
responses:
'200':
"200":
description: Send money confirmed successfully
'400':
"400":
description: Bad request

/merchant-payment:
post:
summary: Send Money endpoint
operationId: initiateMerchantPayment
description: >-
The Endpoint used by the DFSP Operations application to initiate merchant payment
requests to the mojaloop connector
Expand All @@ -116,7 +117,7 @@ paths:
tags:
- Merchant Payments
responses:
'200':
"200":
description: >-
Response for send money request. A quote if it is double
integration or a payment status response if it is single
Expand All @@ -126,19 +127,20 @@ paths:
schema:
$ref: "#/components/schemas/merchantPaymentResponse"

'400':
"400":
description: >-
Response for bad request
'500':
"500":
description: >-
Internal Server error
'504':
"504":
description: >-
Transfer Timeout.
/merchant-payment/{id}:
put:
summary: Confirm send money
operationId: updateInitiatedMerchantPayment
parameters:
- name: id
in: path
Expand All @@ -152,15 +154,15 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ConfirmSendMoney'
$ref: "#/components/schemas/ConfirmSendMoney"
tags:
- Merchant Payments
responses:
'200':
"200":
description: Send money confirmed successfully
'400':
"400":
description: Bad request

/callback:
put:
operationId: callback
Expand All @@ -171,12 +173,11 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/callbackPayload'
$ref: "#/components/schemas/callbackPayload"
responses:
'200':
"200":
description: Receipt of callback confirmed


components:
schemas:
callbackPayload:
Expand Down Expand Up @@ -212,19 +213,24 @@ components:
homeTransactionId:
type: string
example: "HTX123456789"
merchantPaymentId:
amountType:
type: string
example: "RECEIVE"
enum:
- "RECEIVE"
payeeId:
type: string
example: "16135551212"
merchantPaymentIdType:
payeeIdType:
type: string
example: "MSISDN"
receiveAmount:
sendAmount:
type: string
example: "150.00"
receiveCurrency:
sendCurrency:
type: string
example: "UGX"
sendCurrency:
receiveCurrency:
type: string
example: "KES"
transactionDescription:
Expand All @@ -242,44 +248,37 @@ components:
dateOfBirth:
type: string
example: "1985-04-12"
geoLocationData:
description: >-
Indicates the geographic location from where the transaction was
initiated.
properties:
latitude:
$ref: '#/components/schemas/latitude'
longitude:
$ref: '#/components/schemas/longitude'
required:
- latitude
- longitude
type: object
latitude:
description: >-
The API data type Latitude is a JSON String in a lexical format that is
restricted by a regular expression for interoperability reasons.
pattern: >-
^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$
type: string
longitude:
description: >-
The API data type Longitude is a JSON String in a lexical format that is
restricted by a regular expression for interoperability reasons.
pattern: >-
^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$
type: string


merchantPaymentResponse:
type: object
properties:
merchantDetails:
type: string
example: "{\"name\":\"Jane Smith\",\"accountNumber\":\"1234567890\",\"bankName\":\"Example Bank\",\"address\":\"456 Elm Street, Somecity, Country\"}"
sendAmount:
payeeDetails:
type: object
properties:
idType:
type: string
example: "MSISDN"
idValue:
type: string
example: "990454454"
fspId:
type: string
example: "airtelzambia"
firstName:
type: string
example: "Niza"
lastName:
type: string
example: "Tembo"
dateOfBirth:
type: string
example: "1997/09/04"

receiveAmount:
type: string
example: "140.00"
sendCurrency:
receiveCurrency:
type: string
example: "EUR"
fees:
Expand All @@ -288,13 +287,9 @@ components:
feeCurrency:
type: string
example: "USD"
exchangeRate:
type: string
example: "1.10"
expiryDateTime:
transactionId:
type: string
format: date-time
example: "2024-08-01T12:00:00Z"
example: "42fdb186-2a36-46f1-9be9-8989a9e0aeb4"
sendMoneyResponse:
type: object
properties:
Expand Down Expand Up @@ -341,6 +336,11 @@ components:
homeTransactionId:
type: string
example: "HTX123456789"
amountType:
type: string
example: "SEND"
enum:
- "SEND"
payeeId:
type: string
example: "16135551212"
Expand Down
Loading

0 comments on commit c041e31

Please sign in to comment.