Package: wkl-nmi
NMI GatewayThis 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_variablesThis package was build with the unique intention to make the integration with the gateway easy.Getting startedFirst 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"DocThe library supports the next operations:CustomerVaultaddPlansallidadd_month_configurationedit_month_configurationadd_day_configurationedit_day_configurationSubscriptionsadd_with_custom_month_frequency_configadd_with_custom_day_frequency_configpausecancelidallConfiggetupdateadddeletePaymentswith_tokenwith_customer_vaultrefundCustomer VaultHandle customer vault operationsadd-1Create a new customer vault with the provided id (this id is then used by other methods of this library as user_id)# import libraryfromwknmi.customer_vaultimportCustomerVault# init CustomerVaultcustomerVault=CustomerVault(url="https://nmi-server-orkrbzqvda-uc.a.run.app",org="testOrg4")# add usercustomerVault.add({"id":"testId113233","token":"00000000-000000-000000-000000000000","billing_id":"","billing_info":{"first_name":"","last_name":"","address1":"","city":"","state":"","zip":"","country":"","phone":"","email":""}})editEdit customer vault with the provided id (this id is then used by other methods of this library as user_id)# import libraryfromwknmi.customer_vaultimportCustomerVault# init CustomerVaultcustomerVault=CustomerVault(url="https://nmi-server-orkrbzqvda-uc.a.run.app",org="testOrg4")# add usercustomerVault.edit({"id":"testId113233","billing_id":"","billing_info":{"first_name":"","last_name":"","address1":"","city":"","state":"","zip":"","country":"","phone":"","email":""}})deleteDelete customer vault with the provided id (this id is then used by other methods of this library as user_id)# import libraryfromwknmi.customer_vaultimportCustomerVault# init CustomerVaultcustomerVault=CustomerVault(url="https://nmi-server-orkrbzqvda-uc.a.run.app",org="testOrg4")# add usercustomerVault.delete(id="testId113233")PlansHandles plan operations with the nmi apiallGet all plans created plans in the organization# import libraryfromwknmi.plansimportPlans# initplan=Plans(url="https://nmi-server-orkrbzqvda-uc.a.run.app",org="testOrg4")# get plansplan.all()idGet plan id information# get swzshoppingonly plan informationplan.id("swzshoppingonly")add_month_configurationCreate a new plan using month setup# create planplan.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_configuationEdit plan using month configuration# edit month configuration planplan.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_configurationCreate a new plan using day setup# create a plan using day configurationplan.add_day_configuration({"custom_plan":{"plan_amount":"10.00","plan_name":"test","plan_id":"testtsetts","day_frequency":"1","plan_payments":"0"}})edit_day_configurationEdit a plan using day setup# edit a plan using day configurationplan.edit_day_configuration({"custom_plan":{"plan_amount":"20.00","plan_name":"test","plan_id":"testtsetts","day_frequency":"1","plan_payments":"0"}})SubscriptionHandles subscriptions using the nmi apiadd_with_custom_month_frequency_configAssign 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 libraryfromwknmi.subscriptionsimportSubscriptions# initsubsObj=Subscriptions(url="https://nmi-server-orkrbzqvda-uc.a.run.app",org="testOrg4")# assign subscription to custumer vaultsubsObj.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_configAssign 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 vaultsubsObj.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/ResumePause subscription#pause subscriptionsubscription_id="your subscription id"pause="true"# true to pause/false to resumesubsObj.pause(subscription_id,"true")CancelCancel a subscripionsubscription_id="your subscription id"result=subsObj.cancel(subscription_id)by_user_idGet all subscriptions of user_id#get subscriptions of user iduser_id="your user id"result=subsObj.by_user_id(user_id)ConfigHandles creations of the merchantsgetGet merchant information# import libraryfromwknmi.configimportConfig# initConfig(url="http://127.0.0.1:8000",org="testOrg4")# get merchant configurationconfigObj.get()updateUpdate merchant information# edit merchant informationconfigObj.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"})addCreate a new merchant# add a new merchantconfigObj.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"})deleteDelete a merchantconfigObj.delete("testOrg5")PaymentsHandles nmi paymentswith_token# import libraryfromwknmi.paymentimportPay# initpay=Pay(url="https://nmi-server-orkrbzqvda-uc.a.run.app",org="testOrg")# fill payment dataresult=pay.with_token({"token":"00000000-000000-000000-000000000000","total":"11","billingInfo":{"first_name":"","last_name":"","address1":"","city":"","state":"","zip":"","country":"","phone":"","email":"","company":"","address2":"","fax":"","shipping_id":"","shipping_address1":"","shipping_address2":"","shipping_city":"","shipping_country":"","shipping_zip":"","shipping_state":"","shipping_first_name":"","shipping_last_name":"","shipping_phone":"","shipping_email":""},})with_customer_vault# import libraryfromwknmi.paymentimportPay# initpay=Pay(url="https://nmi-server-orkrbzqvda-uc.a.run.app",org="testOrg")# fill payment datapay.with_customer_vault({"customerVault":"982f128f-8e77-4ed9-a495-1b708f79b8e2","total":"11","billingInfo":{"first_name":"","last_name":"","address1":"","city":"","state":"","zip":"","country":"","phone":"","email":"","company":"","address2":"","fax":"","shipping_id":"","shipping_address1":"","shipping_address2":"","shipping_city":"","shipping_country":"","shipping_zip":"","shipping_state":"","shipping_first_name":"","shipping_last_name":"","shipping_phone":"","shipping_email":""},})refund# import libraryfromwknmi.paymentimportPay# initpay=Pay(url="https://nmi-server-orkrbzqvda-uc.a.run.app",org="testOrg")# fill payment datapay.refund("9192863564")