Exemple #1
0
 def test_createLinkString(self):
     a = {
         "transType": "01",
         "sysReserved": "{aaa=a&bbb=b}",
         "merId": "888888888888888"
     }
     sort_url = SDKUtil.createLinkString(a, True, False)
     self.assertEqual(
         sort_url,
         'merId=888888888888888&sysReserved={aaa=a&bbb=b}&transType=01')
     sort_encode_url = SDKUtil.createLinkString(a, True, True)
     self.assertEqual(
         sort_encode_url,
         'merId=888888888888888&sysReserved=%7Baaa%3Da%26bbb%3Db%7D&transType=01'
     )
    def getCustomerInfoWithEncrypt(customerInfo):
        '''
        加密时使用此方法
        '''
        if customerInfo is None or len(customerInfo) == 0:
            return ""

        encryptedInfo = {}
        for key in customerInfo.keys():
            if key == 'phoneNo' or key == 'cvn2' or key == 'expired':
                encryptedInfo[key] = customerInfo[key]

        del customerInfo['phoneNo']
        del customerInfo['cvn2']
        del customerInfo['expired']

        if len(encryptedInfo):
            encryptedInfo = SDKUtil.createLinkString(encryptedInfo, False, False)
            encryptedInfo = AcpService.encryptData(encryptedInfo, SDKConfig().encryptCertPath)
            customerInfo["encryptedInfo"] = encryptedInfo

        b64_str = "{" + SDKUtil.createLinkString(customerInfo, False, False) + "}"
        b64_data = base64.b64encode(b64_str.encode('utf-8'))
        return b64_data.decode('utf-8')
 def getCustomerInfo(customerInfo):
     if customerInfo == None or customerInfo.length == 0:
         return ""
     b64_str = "{" + SDKUtil.createLinkString(customerInfo, False, False) + "}"
     b64_data = base64.b64encode(b64_str.encode('utf-8'))
     return b64_data.decode('utf-8')
 def post(params, url):
     content = SDKUtil.createLinkString(params, False, True)
     respString = SDKUtil.post(url, content)
     resp = SDKUtil.parseQString(respString)
     return resp