Static Pay Buttons
Introduction
Sticitt Pay buttons are elements (usually buttons) that are configured to open up the Sticitt Pay modal when clicked, and can either be static
or dynamic
.
Static pay buttons are usually defined in the HTML code, and are available at the time the web page fires the load event. These kind of pay buttons must have sticitt-pay-button
class name so that they can be automatically registered by the Sticitt Pay SDK on document load.
Passing payment ID
The static pay button must also be provided with the payment ID of the payment you wish the to complete.
The payment ID can be specified via the data-payment-id
attribute like so,
Passing payment ID using retrieve function
The payment ID can also be provided through a retrieve payment ID function, which is useful when you want to perform a call in order to retrieve the payment ID, like a network call to your server.
To achieve this, first create a function that takes in a HTML element and a callback function. Here's an example of what that might look like:
Then set your button's data-retrieve-payment-id
attribute to the name of your function. This function will be called when the pay button is clicked and only once the setPaymentId callback is called will the Sticitt Pay modal be opened with the given payment ID.
- Note
The function passed to data-retrieve-payment-id must be available in global scope, i.e., on the `window` object, at the time the document is loaded otherwise it will not be registered.
This will then retrieve the payment ID before opening the Sticitt Pay modal.
Optional OnPaid callback
If you want to run some code when a payment is completed you can do so by defining a function with any name that matches the following signature.
Now set the data-on-paid
to the name of your function.
Optional OnClosed callback
If you want to run some code when the Sticitt Pay modal is closed you can do so by defining a function with any name that takes in the .
Now set the data-on-closed
to the name of your function.