Пример #1
0
def testNotificationTable():
    configurationFile = open("owners.inp", "r")
    table = Notify.createTable(configurationFile)

    print table

    return
Пример #2
0
def wx_pub():
    channel = 'wx_pub'
    extra = {}
    extra['open_id'] = 'o9zpMs5MW2-62GAy5hRrjdYVCktU'
    scharge = datagen.create_charge("true",channel, **extra)
    charge_id = scharge['id']
    content, sign_str = Notify.wx_pub(scharge)
    content['sign'] = (hashlib.md5(sign_str).hexdigest()).upper()
    content_final = {k: v.encode('utf-8') for k, v in content.items()}
    print content_final

    result = Notify.send(True,charge_id, content_final)
    if 'success' in result:
        print 'The paid status of {0} charge {1} had updated successfully'.format(channel, charge_id)
    else:
        print 'Failed during update the paid status of {0} charge {1} '.format(channel, charge_id)

    return charge_id
Пример #3
0
def alipay():
    # for alipay
    key = load_privatekey(FILETYPE_PEM, open("./External/alipay/rsa_private_key.pem").read())

    # 默认是返回已存在的charge对象;若需要新生成charge,写为: DataGen.GetCharge(channel, True)
    scharge = datagen.create_charge(True,'alipay')
    charge_id = scharge['id']
    content, sign_str = Notify.alipay(scharge)

    sign_charge = sign(key, sign_str, 'sha1')

    ############### verify the signature to ensure the pair without any issues###########

    # pem = open("External/alipay/rsa_public_key.pem").read()
    #
    # bio = BIO.MemoryBuffer(pem)
    # rsa = RSA.load_pub_key_bio(bio)
    # pubkey = EVP.PKey()
    # pubkey.assign_rsa(rsa)
    #
    # pubkey.reset_context(md='sha1')
    # pubkey.verify_init()
    # pubkey.verify_update(sign_str)
    # print pubkey.verify_final(sign_charge)

    #########################################################################################

    sign_final = base64.b64encode(sign_charge)
    content['sign_type'] = "RSA"
    content['sign'] = sign_final
    content_final = {k: v.encode('utf-8') for k, v in content.items()}
    print content_final
    result = Notify.send("true",charge_id, content_final)
    if result == 'success':
        print 'The paid status of alipay charge {0} had updated successfully'.format(charge_id)
        return charge_id,"success"
    else:
        print 'Failed during update the paid status of alipay charge {0} '.format(charge_id)
        return charge_id,"Fail"