Esempio n. 1
0
def create_payment_request_response(wallet_addr, amount, id_obj):

    # TODO: This might not work with remote keys
    if not id_obj.x509_cert:
        raise ValueError('id_obj missing x509_cert')

    signer = PluginManager.get_plugin('SIGNER', config.signer_type)
    signer.set_id_obj(id_obj)

    if not id_obj.payment_url:
        log.info('Creating Addressimo payment_url [ID: %s]' % id_obj.id)

        resolver = PluginManager.get_plugin('RESOLVER', config.resolver_type)

        try:
            payment_url_uuid = resolver.set_payment_request_meta_data(id_obj.get_expires(), wallet_addr, amount * 100000000)
        except Exception:
            return create_json_response(False, 'Internal Server Error. Please try again.', 500)

    # Setup PaymentRequest
    pr = generate_payment_request(
        wallet_addr,
        id_obj.x509_cert,
        id_obj.get_expires(),
        signer,
        amount,
        id_obj.memo,
        id_obj.payment_url or 'https://%s/payment/%s' % (config.site_url, payment_url_uuid),
        id_obj.merchant_data if id_obj.payment_url else payment_url_uuid
    )

    return Response(response=pr, status=200, content_type=PR_MIMETYPE, headers={'Content-Transfer-Encoding': 'binary', 'Access-Control-Allow-Origin': '*'})
Esempio n. 2
0
def create_payment_request_response(wallet_addr, amount, id_obj):

    # TODO: This might not work with remote keys
    if not id_obj.x509_cert:
        raise ValueError('id_obj missing x509_cert')

    signer = PluginManager.get_plugin('SIGNER', config.signer_type)
    signer.set_id_obj(id_obj)

    # Setup PaymentRequest
    pr = generate_payment_request(
        wallet_addr,
        id_obj.x509_cert,
        signer,
        amount,
        id_obj.expires,
        id_obj.memo,
        id_obj.payment_url,
        id_obj.merchant_data
    )

    return Response(response=pr, status=200, content_type=PR_MIMETYPE, headers={'Content-Transfer-Encoding': 'binary', 'Access-Control-Allow-Origin': '*'})