Python SDK for MWC Pay
Project description
MWC Pay Python SDK
Description
Python SDK for MWC Pay.
Installing
Run the following command to install this library.
pip install nicolasflamel.mwc-pay
Usage
After an MwcPay object has been created, it can be used to create payments, query the status of payments, get the current price of MimbleWimble coin, and get info about MWC Pay's public server.
A high level overview of a payment's life cycle when using this SDK consists of the following steps:
- The merchant creates a payment and gets the payment's URL from the response.
- The buyer sends MimbleWimble Coin to that URL.
- The merchant can optionally monitor the payment's status via the
getPaymentInfomethod, thecreatePaymentmethod'sreceivedCallbackparameter, thecreatePaymentmethod'sconfirmedCallbackparameter, and/or thecreatePaymentmethod'sexpiredCallbackparameter. - The payment's completed callback is ran once the payment achieves the desired number of on-chain confirmations.
The following code briefly shows how to use this SDK. A more complete example with error checking is available here.
# Require dependencies
from nicolasflamel.mwc_pay import MwcPay
# Initialize MWC Pay
mwcPay = MwcPay("http://localhost:9010")
# Create payment
payment = mwcPay.createPayment("123.456", 5, 600, "http://example.com/completed", "http://example.com/received", "http://example.com/confirmed", "http://example.com/expired", "notes")
# Get payment info
paymentInfo = mwcPay.getPaymentInfo(payment["payment_id"])
# Get price
price = mwcPay.getPrice()
# Get public server info
publicServerInfo = mwcPay.getPublicServerInfo()
Functions
-
MWC Pay constructor:
constructor(privateServer: str = "http://localhost:9010") -> MwcPayThis constructor is used to create an
MwcPayobject and it accepts the following parameter:privateServer: str(optional): The URL for your MWC Pay's private server. If not provided then the default valuehttp://localhost:9010will be used.
This method returns the following value:
MwcPay: AnMwcPayobject.
-
MWC Pay create payment method:
createPayment(price: str | None, requiredConfirmations: int | None, timeout: int | None, completedCallback: str, receivedCallback: str | None = None, confirmedCallback: str | None = None, expiredCallback: str | None = None, notes: str | None = None, apiKey: str | None = None) -> dict[str, str] | bool | NoneThis method is used to create a payment and it accepts the following parameters:
price: str | None: The expected amount for the payment. IfNonethen any amount will fulfill the payment.requiredConfirmations: int | None: The required number of on-chain confirmations that the payment must have before it's considered complete. IfNonethen one required confirmation will be used.timeout: int | None: The duration in seconds that the payment can be received. IfNonethen the payment will never expire.completedCallback: str: The HTTP GET request that will be performed when the payment is complete. If the response status code to this request isn'tHTTP 200 OK, then the same request will be made at a later time. This request can't follow redirects. This request may happen multiple times despite a previous attempt receiving anHTTP 200 OKresponse status code, so make sure to prepare for this and to respond to all requests with anHTTP 200 OKresponse status code if the request has already happened. All instances of__id__,__completed__, and__received__are replaced with the payment's ID, completed timestamp, and received timestamp respectively.receivedCallback: str | None(optional): The HTTP GET request that will be performed when the payment is received. If the response status code to this request isn'tHTTP 200 OK, then anHTTP 500 Internal Errorresponse will be sent to the payment's sender when they are sending the payment. This request can't follow redirects. This request may happen multiple times despite a previous attempt receiving anHTTP 200 OKresponse status code, so make sure to prepare for this and to respond to all requests with anHTTP 200 OKresponse status code if the request has already happened. All instances of__id__,__price__,__sender_payment_proof_address__,__kernel_commitment__, and__recipient_payment_proof_signature__are replaced with the payment's ID, price, sender payment proof address, kernel commitment, and recipient payment proof signature respectively. If not provided orNonethen no request will be performed when the payment is received.confirmedCallback: str | None(optional): The HTTP GET request that will be performed when the payment's number of on-chain confirmations changes and the payment isn't completed. The response status code to this request doesn't matter. This request can't follow redirects. All instances of__id__, and__confirmations__are replaced with the payment's ID and number of on-chain confirmations respectively. If not provided orNonethen no request will be performed when the payment's number of on-chain confirmations changes.expiredCallback: str | None(optional): The HTTP GET request that will be performed when the payment is expired. If the response status code to this request isn'tHTTP 200 OK, then the same request will be made at a later time. This request can't follow redirects. This request may happen multiple times despite a previous attempt receiving anHTTP 200 OKresponse status code, so make sure to prepare for this and to respond to all requests with anHTTP 200 OKresponse status code if the request has already happened. All instances of__id__are replaced with the payment's ID. If not provided orNonethen no request will be performed when the payment is expired.notes: str | None(optional): Text to associate with the payment.apiKey: str | None(optional): API key that must match the private server's API key if it's using one.
This method returns the following values:
dict[str, str]: The payment was created successfully. This object contains thepayment_id: str,url: str, andrecipient_payment_proof_address: strof the created payment.False: An error occurred on the private server and/or communicating with the private server failed.None: Parameters are invalid.
-
MWC Pay get payment info method:
getPaymentInfo(paymentId: str, apiKey: str | None = None) -> dict[str, str | int | bool | None] | bool | NoneThis method is used to get the status of a payment and it accepts the following parameters:
paymentId: str: The payment's ID.apiKey: str | None(optional): API key that must match the private server's API key if it's using one.
This method returns the following values:
dict[str, str | int | bool | None]: This object contains the payment'surl: str,price: str | None,required_confirmations: int,received: bool,confirmations: int,time_remaining: int | None,status: str, andrecipient_payment_proof_address: str. Thestatus: strcan be one of the following values:Expired,Not received,Received,Confirmed, orCompleted.False: An error occurred on the private server and/or communicating with the private server failed.None: Parameters are invalid and/or the payment doesn't exist.
-
MWC Pay get price method:
getPrice(apiKey: str | None = None) -> str | bool | NoneThis method is used to get the price of MimbleWimble coin and it accepts the following parameters:
apiKey: str | None(optional): API key that must match the private server's API key if it's using one.
This method returns the following values:
string: The price of MimbleWimble Coin in USDT.False: An error occurred on the private server and/or communicating with the private server failed.None: Parameters are invalid and/or the price API is disabled on the private server.
-
MWC Pay get public server info method:
getPublicServerInfo(apiKey: str | None = None) -> dict[str, str | None] | bool | NoneThis method is used to get info about MWC Pay's public server and it accepts the following parameters:
apiKey: str | None(optional): API key that must match the private server's API key if it's using one.
This method returns the following values:
dict[str, str | None]: This object contains the public server'surl: strandonion_service_address: str | None.False: An error occurred on the private server and/or communicating with the private server failed.None: Parameters are invalid.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nicolasflamel_mwc_pay-0.2.0.tar.gz.
File metadata
- Download URL: nicolasflamel_mwc_pay-0.2.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a16ec5bbe4b1076ff919ac6333dcb9207c7677350dad30ee862409b12fc81f98
|
|
| MD5 |
3c9d46553706441a74c7352ac581aa9a
|
|
| BLAKE2b-256 |
dbce24218cff13ed6f2a2161a208e1a2dac36c60cc11015576303cf06e47e860
|
File details
Details for the file nicolasflamel.mwc_pay-0.2.0-py3-none-any.whl.
File metadata
- Download URL: nicolasflamel.mwc_pay-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b16275886767cbaff75ef18bbf3e1f9954c94797d0a3499abdb60f43c96b9329
|
|
| MD5 |
542978c6797d0c6182cf87e8e6baa783
|
|
| BLAKE2b-256 |
05ccc4b44a810c8fcc2eed82cfe939fea4cd61a8272e84b3d7605fa26ed70b46
|