A Nmi library for python
Project description
NMI Gateway
This is a nmi handy package to interact with the nmi gateway endpoints, you can find the original documentation here: https://secure.networkmerchants.com/gw/merchants/resources/integration/integration_portal.php#cv_variables
This package was build with the unique intention to make the integration with the gateway easy.
Examples
Customer Vault methods
Create customer vault
from nmigate.lib.customer_vault import CustomerVault
secret_key = 'your secret key'
org = 'your org'
token = 'your test token here' # test token "00000000-000000-000000-000000000000"
customer_vault = CustomerVault(secret_key, org)
result = customer_vault.create_customer_vault({
"id": "",
"token": token,
"billing_id": "",
"billing_info": {
"first_name": "1",
"last_name": "1",
"address1": "1",
"city": "1",
"state": "1",
"zip": "1",
"country": "1",
"phone": "1",
"email": "1"
}
})
Get billing info by transaction id
from nmigate.lib.customer_vault import CustomerVault
secret_key = 'your secret key'
org = 'your org'
transaction_id = 'transaction id '
customer_vault = CustomerVault(secret_key, org)
result = customer_vault.get_billing_info_by_transaction_id(transaction_id)
Plans
Get all plans
from nmigate.src.nmigate.lib.plans import Plans
secret_key = 'your secret key'
org = 'your org'
plansObj = Plans(secret_key, org)
response = plansObj.get_all_plans()
plans = response['nm_response']['plan']
Get plan
from nmigate.src.nmigate.lib.plans import Plans
secret_key = 'your secret key'
org = 'your org'
plan_id = 'your plan id'
plans = Plans(secret_key, org)
response = plans.get_plan(plan_id)
Add plan using frequency configuration
from nmigate.src.nmigate.lib.plans import Plans
secret_key = 'your secret key'
org = 'your org'
plans = Plans(secret_key, org)
response = plans.add_plan_by_day_frequency({
'plan_amount': '10.00',
'plan_name': 'test',
'plan_id': 'test',
'day_frequency': '1',
'plan_payments': '0'
})
Edit day frequency plan
from nmigate.src.nmigate.lib.plans import Plans
secret_key = 'your secret key'
org = 'your org'
plans = Plans(secret_key, org)
response = plans.edit_plan_by_day_frequency({
"recurring": "edit_plan",
'plan_amount': '10.00',
'plan_name': 'test',
'plan_id': 'test',
'day_frequency': '2',
'plan_payments': '0'
})
Add plan using month config
from nmigate.src.nmigate.lib.plans import Plans
secret_key = 'your secret key'
org = 'your org'
plans = Plans(secret_key, org)
response = plans.add_plan_by_month_config({
'plan_amount': '10.00',
'plan_name': 'test',
'plan_id': 'test1',
'month_frequency': '1',
"day_of_month": '1',
'plan_payments': '0'
})
Edit plan using month config
from nmigate.src.nmigate.lib.plans import Plans
secret_key = 'your secret key'
org = 'your org'
plans = Plans(secret_key, org)
response = plans.edit_plan_by_month_config({
'plan_amount': '10.00',
'plan_name': 'test',
'plan_id': 'test1',
'month_frequency': '1',
"day_of_month": '10',
'plan_payments': '0'
})
Subscriptions
Get Subscriptions
from nmigate.lib.customer_vault import CustomerVault
secret_key = 'your secret key'
org = 'your org'
subscription_id='customer vault id'
subscriptions = Subscriptions(secret_key, org)
info = subscriptions.get_info(subscription_id)
print(result)
Subscription + sale, using plan_id and customer vault
If total_amount = 0 then its a simple subscription, if total_amount > 0 then its a subscription with sale
from nmigate.lib.customer_vault import CustomerVault
secret_key = 'your secret key'
org = 'your org'
customer_vault_id='customer vault id'
subscriptions = Subscriptions(secret_key, org)
result = subscriptions.custom_sale_using_vault(plan_id = customer_vault_id, customer_vault_id=customer_vault_id, create_customer_vault=False)
print(result)
Custome Subscription + sale, using vault number and month frequency configuration
from nmigate.lib.subscriptions import Subscriptions
secret_key = 'your secret key'
org = 'your org'
subscriptions = Subscriptions(secret_key, org)
result = subscriptions.custom_sale_using_vault_month_frequency(request_sub = {
"user_id": "1",
"total_amount": "11",
"custom_subscription_info": {
"plan_payments": "13",
"plan_amount": "12",
"month_frequency": "1",
"day_of_month": "1"
}
})
print(result)
Custome Subscription + sale, using vault number and day frequency configuration
from nmigate.lib.subscriptions import Subscriptions
secret_key = 'your secret key'
org = 'your org'
subscriptions = Subscriptions(secret_key, org)
result = subscriptions.custom_with_sale_and_vault_day_frequency(request_sub = {
"user_id": "1",
"total_amount": "14",
"custom_subscription_info": {
"plan_payments": "15",
"plan_amount": "6",
"day_frequency": "1"
}
})
print(result)
Delete subscription
from nmigate.lib.subscriptions import Subscriptions
secret_key = 'your secret key'
org = 'your org'
subscription_id = 'your subscription_id'
subscriptions = Subscriptions(secret_key, org)
info = subscriptions.delete_subscription(subscription_id)
Pause/resume Subscription
from nmigate.lib.subscriptions import Subscriptions
secret_key = 'your secret key'
org = 'your org'
subscription_id = 'your subscription_id'
pause=True # True to pause, False to unpause
transactions = Subscriptions(secret_key, org)
result = transactions.pause_subscription(subscription_id, pause)
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
nmigate-0.0.14.tar.gz
(9.1 kB
view details)
Built Distribution
File details
Details for the file nmigate-0.0.14.tar.gz
.
File metadata
- Download URL: nmigate-0.0.14.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01f0f7c784fc468f4a28970adea7fb16407a75a2c53dcc0d7ea4fe8ced132a72 |
|
MD5 | 4ae284d98b827cc22ea62f7831133377 |
|
BLAKE2b-256 | b098338d093d64c88d4c4c0e446fc2fc0e43afac4ae1844623d7d3ad80d49fde |
File details
Details for the file nmigate-0.0.14-py3-none-any.whl
.
File metadata
- Download URL: nmigate-0.0.14-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42008f18de4fe80acbe79f042b1ece34ef143bd3ae5b52e724f86c5ffe2b985c |
|
MD5 | 81c4d7fc626f6343206b74928bd5c725 |
|
BLAKE2b-256 | 6784e60f2b157556ed7dfcb3078eaa9ebf96f458c78319b78ae1313a3c900a53 |