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

WIP: ExMonobank.MerchantAPI #20

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
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
16 changes: 16 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Config

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",
merchant_api: %{
token: System.get_env("MONOBANK_API_TOKEN")
}
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"
}
}
]
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,29 @@
[
{
"request": {
"body": "",
"headers": {
"X-Token": "***"
},
"method": "get",
"options": [],
"request_body": "",
"url": "https://api.monobank.ua/api/merchant/invoice/payment-info?invoiceId=invalid"
},
"response": {
"binary": false,
"body": "{\"errCode\":\"1004\",\"errText\":\"invoice not found\"}",
"headers": {
"Date": "Sat, 10 Jun 2023 16:12:30 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": "a233d0efe47b76bc05b753322ed5a59b"
},
"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/payment-info?invoiceId=230605DpurVjPDSmfzEP"
},
"response": {
"binary": false,
"body": "{\"maskedPan\":\"53754114******22\",\"approvalCode\":\"563594\",\"rrn\":\"073687715731\",\"createdDate\":\"2023-06-05T17:59:05Z\",\"terminal\":\"MI000000\",\"paymentScheme\":\"full\",\"paymentMethod\":\"pan\",\"fee\":1,\"domesticCard\":true,\"country\":\"804\",\"amount\":100,\"ccy\":980,\"finalAmount\":0,\"cancelList\":[{\"status\":\"success\",\"amount\":100,\"ccy\":980,\"createdDate\":\"2023-06-05T17:59:28Z\",\"modifiedDate\":\"2023-06-05T17:59:28Z\",\"approvalCode\":\"563594\",\"rrn\":\"073687715731\"}]}",
"headers": {
"Date": "Sat, 10 Jun 2023 16:05:50 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "443",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",
"Trace-Id": "687d4279d364320310215bbf574613d0"
},
"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"
}
}
]
Loading