Esempio n. 1
0
def configs_delete(webhook_config_id):
    form = WebhookConfigDeleteForm(webhook_config_id=webhook_config_id,
                                   user=current_user)

    if form.validate_on_submit():
        WebhookConfig.delete(form.webhook_config)
        return redirect(url_for('configs_list'))
    return render_template('configs_delete.html', form=form)
Esempio n. 2
0
def configs_delete(webhook_config_id):
    form = WebhookConfigDeleteForm(
        webhook_config_id=webhook_config_id,
        user=current_user
    )

    if form.validate_on_submit():
        WebhookConfig.delete(form.webhook_config)
        return redirect(url_for('configs_list'))
    return render_template('configs_delete.html', form=form)
Esempio n. 3
0
def configs_show(webhook_config_id):
    config = WebhookConfig.get(webhook_config_id, current_user)
    form = WebhookConfigDeleteForm(webhook_config_id=webhook_config_id,
                                   user=current_user)
    if config is None:
        return Response(status=404)
    return render_template('configs_show.html', config=config, clear_form=form)
Esempio n. 4
0
def webhook_receiver(webhook_config_unique_id):
    config = WebhookConfig.get_by_unique_id(webhook_config_unique_id)
    if config is None: return Response(status=404)

    webhook_response = config.parse_webhook_response(
        raw=request.form['bt_payload'],
        signature=str(request.form['bt_signature']))

    if webhook_response is not None:
        db.session.commit()
        return Response(status=200)

    return Response(status=500)
Esempio n. 5
0
def configs_show(webhook_config_id):
    config = WebhookConfig.get(webhook_config_id, current_user)
    form = WebhookConfigDeleteForm(
        webhook_config_id=webhook_config_id,
        user=current_user
    )
    if config is None:
        return Response(status=404)
    return render_template(
        'configs_show.html',
        config=config,
        clear_form=form
    )
Esempio n. 6
0
def webhook_receiver(webhook_config_unique_id):
    config = WebhookConfig.get_by_unique_id(webhook_config_unique_id)
    if config is None: return Response(status=404)

    webhook_response = config.parse_webhook_response(
        raw=request.form['bt_payload'],
        signature=str(request.form['bt_signature'])
    )

    if webhook_response is not None:
        db.session.commit()
        return Response(status=200)

    return Response(status=500)
Esempio n. 7
0
    def validate(self):
        rv = Form.validate(self)
        if not rv:
            return False
        try:
            self.webhook_config = self.user.add_webhook_config(
                WebhookConfig(
                    name=self.name.data,
                    notes=self.notes.data,
                    bt_merchant_id=self.bt_merchant_id.data,
                    bt_public_key=self.bt_public_key.data,
                    bt_private_key=self.bt_private_key.data,
                ))
        except IntegrityError as error:
            self.bt_public_key.errors.append(
                "A webhook endpoint with this public key already exists")
            return False

        return True
Esempio n. 8
0
File: db.py Progetto: cbjoseph/btray
if command == "generate":
    if app.config["ENVIRONMENT"] == "production":
        raise Exception("Cannot generate in production")

    words = [
        "Horse", "Zenith", "Goose", "Farmer", "Obsidian", "Grapefruit",
        "Martian", "Coal", "Morlock"
    ]

    password = app.config.get("TESTING_USER_PASSWORD", None)
    if password is None:
        password = getpass("Password for 'user': "******"user", "*****@*****.**", password)
    for i in range(0, 10):
        webhook_config = WebhookConfig(name=" ".join(sample(words, 4)),
                                       notes="\n".join(sample(words, 6)),
                                       bt_merchant_id="abc%s" % i,
                                       bt_public_key="def%s" % i,
                                       bt_private_key="ghi%s" % i)
        user.webhook_configs.append(webhook_config)

        for j in range(0, 15):
            webhook_config.parse_webhook_response(
                'VGhpcyBpcyBhIHRlc3QNClRoaXMgaXMgb25seSBhIHRlc3QNCklmIHlvdSB0cnkgYW55dGhpbmcgZnVubnkgaXQgd2lsbCBlbmQgcG9vcmx5Lg==',
                'fake-valid-signature-for-testing')
    db.session.add(user)

db.session.commit()
print("Committed")
Esempio n. 9
0
if command == "generate":
    if app.config["ENVIRONMENT"] == "production":
        raise Exception("Cannot generate in production")

    words = ["Horse", "Zenith", "Goose", "Farmer", "Obsidian",
        "Grapefruit", "Martian", "Coal", "Morlock"]

    password = app.config.get("TESTING_USER_PASSWORD", None)
    if password is None:
        password = getpass("Password for 'user': "******"user", "*****@*****.**", password)
    for i in range(0,10):
        webhook_config = WebhookConfig(
            name=" ".join(sample(words, 4)),
            notes="\n".join(sample(words,6)),
            bt_merchant_id="abc%s" % i,
            bt_public_key="def%s" % i,
            bt_private_key="ghi%s" % i
        )
        user.webhook_configs.append(webhook_config)

        for j in range(0, 15):
            webhook_config.parse_webhook_response('VGhpcyBpcyBhIHRlc3QNClRoaXMgaXMgb25seSBhIHRlc3QNCklmIHlvdSB0cnkgYW55dGhpbmcgZnVubnkgaXQgd2lsbCBlbmQgcG9vcmx5Lg==','fake-valid-signature-for-testing')
    db.session.add(user)

db.session.commit()
print("Committed")

Esempio n. 10
0
    def __init__(self, *args, **kwargs):
        Form.__init__(self, *args, **kwargs)

        self.url_config_id = kwargs['webhook_config_id']
        self.webhook_config = WebhookConfig.get(self.url_config_id, kwargs['user'])
Esempio n. 11
0
    def __init__(self, *args, **kwargs):
        Form.__init__(self, *args, **kwargs)

        self.url_config_id = kwargs['webhook_config_id']
        self.webhook_config = WebhookConfig.get(self.url_config_id,
                                                kwargs['user'])
Esempio n. 12
0
def webhook_helper(webhook_config_unique_id):
    config = WebhookConfig.get_by_unique_id(webhook_config_unique_id)
    if config is None: return Response(status=404)

    return render_template('endpoint_helper.html', webhook=config)
Esempio n. 13
0
def webhook_helper(webhook_config_unique_id):
    config = WebhookConfig.get_by_unique_id(webhook_config_unique_id)
    if config is None: return Response(status=404)

    return render_template('endpoint_helper.html', webhook=config)