A Nmi library for python
Project description
NMI Gateway
This is the wklive implementation of nmi gateway, the original documentation of nmi is: 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.
Getting started
First you need to configure GOOGLE_APPLICATION_CREDENTIALS env variable to point to your google key credentials.
GOOGLE_APPLICATION_CREDENTIALS="path/to/you/service/account/credentials.json"
Doc
The library supports the next operations:
Billing
Add
The add method creates a new billing to the selected user_id
# Import library
from wknmi.billing import Billing
# Init Billing
billing = Billing(
url="https://nmi-server-orkrbzqvda-uc.a.run.app",
org="testOrg4"
)
# use add method
billing.add({
"user_id": "1",
"billing_id": "16",
"org": "testOrg4",
"token": "00000000-000000-000000-000000000000", # collect-js-token
"billing_info": {
"first_name": "test",
"last_name": "test",
"address1": "test",
"city": "test",
"state": "test",
"zip": "test",
"country": "test",
"phone": "test",
"email": "test",
"company": "test",
"address2": "test",
"fax": "test",
"shipping_id": "test",
"shipping_address1": "test",
"shipping_address2": "test",
"shipping_city": "test",
"shipping_country": "test",
"shipping_zip": "test",
"shipping_state": "test",
"shipping_first_name": "test",
"shipping_last_name": "test",
"shipping_phone": "test",
"shipping_email": "test"
}
})
update_billing_info
The update_billing_info method only updates only billing information, it can't edit billing_id, user_id.
billing.update_billing_info({
"user_id": "1",
"billing_id": "15",
"org": "testOrg4",
"token": "00000000-000000-000000-000000000000",
"billing_info": {
"first_name": "Carlos",
"last_name": "test",
"address1": "test",
"city": "test",
"state": "test",
"zip": "test",
"country": "test",
"phone": "test",
"email": "test",
"company": "test",
"address2": "test",
"fax": "test",
"shipping_id": "test",
"shipping_address1": "test",
"shipping_address2": "test",
"shipping_city": "test",
"shipping_country": "test",
"shipping_zip": "test",
"shipping_state": "test",
"shipping_first_name": "test",
"shipping_last_name": "test",
"shipping_phone": "test",
"shipping_email": "test"
}
})
delete
Deletes selected billing_id
billing.delete(org="testOrg4",user_id="1",billing_id="15")
priority
Changes the billing priority of a billing id.
billing.set_priority({
"user_id": "1",
"org": "testOrg4",
"billing_id": "16",
"priority": 1
})
info
get billing information of user_id
billing.info(org="testOrg4",user_id="1")
Customer Vault
Handle customer vault operations
add
Create a new customer vault with the provided id (this id is then used by other methods of this library as user_id)
# import library
from wknmi.customer_vault import CustomerVault
# init CustomerVault
customerVault = CustomerVault(url="https://nmi-server-orkrbzqvda-uc.a.run.app", org="testOrg4")
# add user
customerVault.add({
"id": "testId113233",
"token": "00000000-000000-000000-000000000000",
"billing_id": "",
"billing_info":{
"first_name": "",
"last_name": "",
"address1": "",
"city": "",
"state": "",
"zip": "",
"country": "",
"phone": "",
"email": ""
}
})
Plans
Handles plan operations with the nmi api
all
Get all plans created plans in the organization
# import library
from wknmi.plans import Plans
# init
plan = Plans(url="https://nmi-server-orkrbzqvda-uc.a.run.app", org="testOrg4")
# get plans
plan.all()
id
Get plan id information
# get swzshoppingonly plan information
plan.id("swzshoppingonly")
add_month_configuration
Create a new plan using month setup
# create plan
plan.add_month_configuration({
"custom_plan": {
"plan_amount": "10.00",
"plan_name": "test",
"plan_id": "testtset",
"month_frequency": "1",
"day_of_month": "1",
"plan_payments": "0"
}
})
edit_month_configuation
Edit plan using month configuration
# edit month configuration plan
plan.edit_month_configuration({
"custom_plan": {
"plan_amount": "10.00",
"plan_name": "test",
"plan_id": "testtset",
"month_frequency": "1",
"day_of_month": "1",
"plan_payments": "0"
}
})
add_day_configuration
Create a new plan using day setup
# create a plan using day configuration
plan.add_day_configuration({
"custom_plan": {
"plan_amount": "10.00",
"plan_name": "test",
"plan_id": "testtsetts",
"day_frequency": "1",
"plan_payments": "0"
}
})
edit_day_configuration
Edit a plan using day setup
# edit a plan using day configuration
plan.edit_day_configuration({
"custom_plan": {
"plan_amount": "20.00",
"plan_name": "test",
"plan_id": "testtsetts",
"day_frequency": "1",
"plan_payments": "0"
}
})
Subscription
Handles subscriptions using the nmi api
add_with_custom_month_frequency_config
Assign a subscriptions to the user_id (customer vault). if total_amount is set to 0, the method will behave as a normal subscription and the user will be charged according to the custom_subscription info object. But if total_amount is set to a value greater that 0 the user will be charged by that amount
# import library
from wknmi.subscriptions import Subscriptions
# init
subsObj = Subscriptions(url="https://nmi-server-orkrbzqvda-uc.a.run.app",org="testOrg4")
# assign subscription to custumer vault
subsObj.add_with_custom_month_frequency_config({
"user_id": "1",
"order_id": "test",
"total_amount": "0", # 0 for subscription without an addition sale amount
"custom_subscription_info": {
"plan_id": "test",
"plan_amount": "10.00",
"plan_name": "test",
"month_frequency": "1",
"day_of_month": "1",
"plan_payments": "0"
}
})
add_with_custom_day_frequency_config
Assign a subscriptions to the user_id (customer vault). if total_amount is set to 0, the method will behave as a normal subscription and the user will be charged according to the custom_subscription info object. But if total_amount is set to a value greater that 0 the user will be charged by that amount
# assign subscription to custumer vault
subsObj.add_with_custom_day_frequency_config({
"user_id": "1",
"org": "testOrg",
"order_id": "testRef",
"total_amount": "0",# 0 for subscription without an addition sale amount
"custom_subscription_info": {
"plan_payments": "15",
"plan_amount": "6",
"day_frequency": "1"
}
})
Pause/Resume
Pause subscription
#pause subscription
subscription_id = "your subscription id"
pause = "true" # true to pause/false to resume
subsObj.pause(subscription_id, "true")
Cancel
Cancel a subscripion
subscription_id = "your subscription id"
result = subsObj.cancel(subscription_id)
by_user_id
Get all subscriptions of user_id
#get subscriptions of user id
user_id = "your user id"
result = subsObj.by_user_id(user_id)
Config
Handles creations of the merchants
get
Get merchant information
# import library
from wknmi.config import Config
# init
Config(url="http://127.0.0.1:8000",org="testOrg4")
# get merchant configuration
configObj.get()
update
Update merchant information
# edit merchant information
configObj.update({
"store_id": 2342311,
"environment_active": "sandbox",
"org":"testOrg4",
"production_env": {
"token": ""
},
"sandbox_env": {
"token": ""
},
"secret_token": "",
"merchant_orchestrator_url":"http://",
"merchant_id":"123",
"merchant_signature":"123"
})
add
Create a new merchant
# add a new merchant
configObj.add({
"store_id": 234232211,
"environment_active": "sandbox",
"org":"testOrg5",
"production_env": {
"token": "4QaH5w77U2k843fu68EuB34c4M5KJ7r3"
},
"sandbox_env": {
"token": "4QaH5w77U2k843fu68EuB34c4M5KJ7r3"
},
"secret_token": "4QaH5w77U2k843fu68EuB34c4M5KJ7r3",
"merchant_orchestrator_url":"http://",
"merchant_id":"123",
"merchant_signature":"123"
})
delete
Delete a merchant
configObj.delete("testOrg5")
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
File details
Details for the file wkl-nmi-0.0.5.tar.gz
.
File metadata
- Download URL: wkl-nmi-0.0.5.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d091599bc937e06969640124cd23d5e599ec9d09e40500d769054435e3d6376e |
|
MD5 | fc6bd37760326d56c83442e6e10a5521 |
|
BLAKE2b-256 | 11bcd9a802d0c9fb252e01e314020a3bc763f919891534649f5eb18f1ef05d11 |
File details
Details for the file wkl_nmi-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: wkl_nmi-0.0.5-py3-none-any.whl
- Upload date:
- Size: 7.9 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 | 8cdffbdcb69d865ba63b9ac060535c742655db5307835967a9cf7bc7a28c167f |
|
MD5 | 4f32988d83380bb55d7f59ef1f61e41c |
|
BLAKE2b-256 | 2204f9e1112caf9edef3f17f2f17e801a69fc20373f1db11d8f9233ca924f2ba |