Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
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 @@ -23,3 +23,4 @@ erl_crash.dump
ex_monobank-*.tar

/demo
.env
8 changes: 3 additions & 5 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import Config

# Sample configuration:
#
# config :ex_monobank, PrivateAPI,
# token: "your-personal-token",
# base_url: "https://api.monobank.ua"
config :tesla, adapter: Tesla.Adapter.Hackney

import_config "#{Mix.env()}.exs"
1 change: 1 addition & 0 deletions config/dev.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Config
18 changes: 18 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Config

config :tesla, adapter: Tesla.Adapter.Hackney

config :exvcr,
vcr_cassette_library_dir: "fixture/vcr_cassettes",
filter_sensitive_data: [
[pattern: "<PASSWORD>.+</PASSWORD>", placeholder: "PASSWORD_PLACEHOLDER"]
],
filter_url_params: false,
filter_request_headers: ["X-Token"],
response_headers_blacklist: []

config :ex_monobank,
base_url: "https://api.monobank.ua",
private_api: %{
token: System.get_env("MONOBANK_API_TOKEN")
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big deal, just typo in file name:
cancel_invoice_failure_with_inbvalid_id.json
should be:
cancel_invoice_failure_with_invalid_id.json

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "{\"invoiceId\":\"invalid\"}",
"headers": {
"X-Token": "***",
"content-type": "application/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/cancel"
},
"response": {
"binary": false,
"body": "{\"errCode\":\"1004\",\"errText\":\"invoice not found\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 17:56:20 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "48",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "43de06cedd872e972ebfbbeb5403301d"
},
"status_code": 404,
"type": "ok"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "{\"invoiceId\":\"230605DpurVjPDSmfzEP\"}",
"headers": {
"X-Token": "***",
"content-type": "application/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/cancel"
},
"response": {
"binary": false,
"body": "{\"status\":\"success\",\"createdDate\":\"2023-06-05T17:59:28Z\",\"modifiedDate\":\"2023-06-05T17:59:28Z\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 17:59:28 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "95",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "39c7df33208ce1ba96f347eb788ab34e"
},
"status_code": 200,
"type": "ok"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "{\"amount\":\"amount\",\"ccy\":null,\"merchant_paym_info\":null,\"payment_type\":null,\"qr_id\":null,\"redirect_url\":null,\"save_card\":null,\"validity\":null,\"webhook_url\":null}",
"headers": {
"X-Token": "***",
"content-type": "application/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/create"
},
"response": {
"binary": false,
"body": "{\"errCode\":\"BAD_REQUEST\",\"errText\":\"json unmarshal: : json: cannot unmarshal string into Go struct field InvoiceCreateRequest.amount of type int64\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 16:49:28 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "148",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "61895d4c6139a769df80f390860c0a5f"
},
"status_code": 400,
"type": "ok"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "{\"amount\":null,\"ccy\":null,\"merchant_paym_info\":null,\"payment_type\":null,\"qr_id\":null,\"redirect_url\":null,\"save_card\":null,\"validity\":null,\"webhook_url\":null}",
"headers": {
"X-Token": "***",
"content-type": "application/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/create"
},
"response": {
"binary": false,
"body": "{\"errCode\":\"1001\",\"errText\":\"invalid 'amount'\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 16:44:37 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "47",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "92d8434a8f38222e69d1eb73a33d1025"
},
"status_code": 400,
"type": "ok"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "{\"amount\":100,\"ccy\":null,\"merchantPaymInfo\":null,\"paymentType\":null,\"qrId\":null,\"redirectUrl\":null,\"saveCardData\":null,\"validity\":null,\"webhookUrl\":null}",
"headers": {
"X-Token": "***",
"content-type": "application/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/create"
},
"response": {
"binary": false,
"body": "{\"invoiceId\":\"230605A3RNUJNt1oqoiY\",\"pageUrl\":\"https://pay.mbnk.biz/230605A3RNUJNt1oqoiY\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 18:12:48 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "90",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "fedf58314b5641523bdc9ac34be10ee3"
},
"status_code": 200,
"type": "ok"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "{\"amount\":100,\"ccy\":980,\"merchantPaymInfo\":{\"basketOrder\":[{\"name\":\"TestItem\",\"qty\":2,\"sum\":100}],\"destination\":\"destination_info\",\"reference\":\"reference_id\"},\"paymentType\":\"debit\",\"qrId\":null,\"redirectUrl\":\"https://localhost:4000/monopay/success\",\"saveCardData\":null,\"validity\":3600,\"webhookUrl\":\"https://localhost:4000/api/v1/monopay/webhook\"}",
"headers": {
"X-Token": "***",
"content-type": "application/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/create"
},
"response": {
"binary": false,
"body": "{\"invoiceId\":\"2306058TJ5EYzZxFNuvv\",\"pageUrl\":\"https://pay.mbnk.biz/2306058TJ5EYzZxFNuvv\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 16:57:58 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "90",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "b74df652f9fc0fce4466babf6f745135"
},
"status_code": 200,
"type": "ok"
}
}
]
Comment thread
sveredyuk marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"request": {
"body": "",
"headers": {
"X-Token": "***"
},
"method": "get",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/status?invoiceId=invalid"
},
"response": {
"binary": false,
"body": "{\"errCode\":\"1004\",\"errText\":\"invoice not found\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 17:38:08 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "48",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "c4381cba68a97a67caf7b73542a1e1d9"
},
"status_code": 404,
"type": "ok"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"request": {
"body": "",
"headers": {
"X-Token": "***"
},
"method": "get",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/status?invoiceId=230605DpurVjPDSmfzEP"
},
"response": {
"binary": false,
"body": "{\"invoiceId\":\"230605DpurVjPDSmfzEP\",\"status\":\"created\",\"amount\":100,\"ccy\":980,\"createdDate\":\"2023-06-05T16:38:48Z\",\"modifiedDate\":\"2023-06-05T16:38:48Z\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 17:15:54 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "153",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "80c43a91813277182f0b8b807d98c0c5"
},
"status_code": 200,
"type": "ok"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "{\"invoiceId\":\"invalid\"}",
"headers": {
"X-Token": "***",
"content-type": "application/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/remove"
},
"response": {
"binary": false,
"body": "{\"errCode\":\"1004\",\"errText\":\"invoice not found\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 18:14:21 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "48",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "3f59e316eb13eefedd7087e04868e00e"
},
"status_code": 404,
"type": "ok"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "{\"invoiceId\":\"230605DpurVjPDSmfzEP\"}",
"headers": {
"X-Token": "***",
"content-type": "application/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/remove"
},
"response": {
"binary": false,
"body": "{\"errCode\":\"INVOICE_ALREADY_USED\",\"errText\":\"invoice not active\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 18:14:20 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "65",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "c11c87927cbf4f08d4f5074fcbc26651"
},
"status_code": 400,
"type": "ok"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "{\"invoiceId\":\"230605A3RNUJNt1oqoiY\"}",
"headers": {
"X-Token": "***",
"content-type": "application/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/remove"
},
"response": {
"binary": false,
"body": "{\"status\":\"success\"}",
"headers": {
"Date": "Mon, 05 Jun 2023 18:14:20 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "20",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "83048e17bb9a58a75bac25c586987261"
},
"status_code": 200,
"type": "ok"
}
}
]
3 changes: 3 additions & 0 deletions lib/ex_monobank.ex
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
defmodule ExMonobank do
@default_url "https://api.monobank.ua"

def default_url, do: @default_url
end
Loading