The Payback Element allows you to provide a way to pay your users back. This is useful in situations where you would like to reward your users for certain actions.
Which is simply implemented using the Elements SDK create()
function.
await elements.create("payback", { hash: "<HASH>" });
/// We get an `HTMLElement` that we would like to use for the Payback Element.
const el = document.getElementById("ref");
/// Load the JS SDK.
const micro = await loadMicroPayments("<PUBLIC_SECRET>", { apiVersion: "main" });
/// We're going to be using Elements.
const elements = micro.elements();
if (elements) {
/// We'll create an Element with the `type` argument set to `payback`. You
/// will also need to create a Commodity and provide the Commodity's `hash`.
const embed = await elements.create("payback", { hash: "<HASH>" });
/// As long as everything worked out correctly, and there were no issues,
/// mount the Element to our `HTMLElement`.
if (embed && el) {
embed.mount(el);
}
};
Where <PUBLIC_SECRET>
is replaced with your User or Account Public Secret. and
<HASH>
is replaced with a Commodity hash identifier. You can create a
Commodity using either the Node.JS SDK or the Create Commodity API
request.
There may be situations that you would like to gain access to a user’s personal information. This can be accomplished by providing the Payback Element with some Consent configured.
At any time, you may want to remove the Payback Element.
const embed = await elements.create("payback", { hash: "<HASH>" });
embed.destroy();
const embed = await elements.create("payback", { hash: "<HASH>", theme: "dark" });