本文整理汇总了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)