本文整理匯總了Python中PythonNetBanxSDK.OptimalApiClient.OptimalApiClient.serialize方法的典型用法代碼示例。如果您正苦於以下問題:Python OptimalApiClient.serialize方法的具體用法?Python OptimalApiClient.serialize怎麽用?Python OptimalApiClient.serialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PythonNetBanxSDK.OptimalApiClient.OptimalApiClient
的用法示例。
在下文中一共展示了OptimalApiClient.serialize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_split
# 需要導入模塊: from PythonNetBanxSDK.OptimalApiClient import OptimalApiClient [as 別名]
# 或者: from PythonNetBanxSDK.OptimalApiClient.OptimalApiClient import serialize [as 別名]
def test_split(self):
##### Create necessary objects
### Listing the requested parameters
ip = '10.8.0.1'
currency = 'CAD'
amount = '1125'
redirecttype = 'on_success'
redirecturi = 'http://localhost/redirect'
redirectkey_id = 'id'
redirectkey_amount = 'transaction.amount'
refnum = str(RandomTokenGenerator().generateToken())
### Creating object that will be sent to netbanx
order_obj = Order(None)
order_obj.customerIp(ip)
order_obj.merchantRefNum(refnum)
order_obj.currencyCode(currency)
order_obj.totalAmount(amount)
redirect = Redirect(None)
redirect.rel(redirecttype)
redirect.uri(redirecturi)
redirect.returnKeys((redirectkey_id, redirectkey_amount))
redirect_list = []
redirect_list.append(redirect.__dict__)
order_obj.redirect((redirect_list))
### Check if the function will send all requested parameters
## If we want to actually send something, configure the followin and
## uncomment the create_order line
apikey = ""
apipassword = ""
apienviro = "TEST"
apiacnum = ""
optimal_obj = OptimalApiClient(apikey, apipassword, apienviro, apiacnum)
#response_object = optimal_obj.hosted_payment_service_handler().create_order(order_obj)
output = optimal_obj.serialize(order_obj)
parsed_json = json.loads(output)
pp = pprint.PrettyPrinter(indent=4)
#pp.pprint("RAW OUTPUT:")
#pp.pprint(parsed_json)
expected = {'currencyCode':currency, 'customerIp':ip, 'merchantRefNum':refnum, 'redirect':[{'rel':redirecttype, 'returnKeys':[redirectkey_id, redirectkey_amount], 'uri':redirecturi}], 'totalAmount':amount}
self.assertEqual(parsed_json, expected)