Skip to content

Tulo Paywall - Callbacks

Target Audience: Users, Stakeholders, Developers

Introduction

Throughout the Paywall journey that your customers embark on, there are several callbacks that are triggered. You can listen to these callbacks via the Tulo Paywall initialization, and react in any way that you'd like, given the provided information.

List of callbacks

onError

Triggered whenever the Paywall encounters an error, or the error template of the Paywall is shown.

let result = {
    "purchase_status": {
        "code": "failed",
        "reason": "campaign_already_purchased",
        "resolve": null,
        "display_alternative_offer": false
    },
    "account": {
        "id": "account_id",
        "status": "completed",
        "registered_from_purchase": false
    },
    "order": {
        "order_id": "order_id",
        "klarna_order_id": "klarna_order_id",
        "receipt_id": null,
        "redirect_url": null
    },
    "offering": {
        "initial": {
            "product": {
                "id": "product_id",
                "name": "Adeprimo Digital",
                "code": "adeprimo_digital"
            },
            "period": {
                "id": "period_id"
            }
        },
        "alternative": null
    }
};

onError(result); // Result is nullable

You can read more about error management within the Tulo Paywall here.

onCompleted

Triggered whenever the Paywall is done with it's processing, regardless if the outcome is good or bad.

let result = {
    "purchase_status": {
        "code": "ok",
        "reason": "purchase_allowed",
        "resolve": null,
        "display_alternative_offer": false
    },
    "account": {
        "id": "account_id",
        "status": "created",
        "registered_from_purchase": true
    },
    "order": {
        "order_id": "order_id",
        "klarna_order_id": "klarna_order_id",
        "receipt_id": "receipt_id",
        "redirect_url": "redirect_url"
    },
    "offering": {
        "initial": {
            "product": {
                "id": "product_id",
                "code": "adeprimo_digital",
                "name": "Adeprimo Digital"
            },
            "period": {
                "id": "period_id"
            }
        },
        "alternative": null
    }
};

onCompleted(result); // Result is nullable

onOrderClosed

Triggered whenever a order has been successfully created and closed via the Tulo Paywall.

let result = {
    "purchase_status": {
        "code": "ok",
        "reason": "purchase_allowed",
        "resolve": null,
        "display_alternative_offer": false
    },
    "account": {
        "id": "account_id",
        "status": "created",
        "registered_from_purchase": true
    },
    "order": {
        "order_id": "order_id",
        "klarna_order_id": "klarna_order_id",
        "receipt_id": "receipt_id",
        "redirect_url": "redirect_url"
    },
    "offering": {
        "initial": {
            "product": {
                "id": "product_id",
                "code": "adeprimo_digital",
                "name": "Adeprimo Digital"
            },
            "period": {
                "id": "period_id"
            }
        },
        "alternative": null
    }
};

onOrderClosed(result);