millipay. EventReactionCollector¶
Used internally to create the millipay. Product sec-api-product-attributes. Exposes convenience methods for common tasks as reaction to an event fired by millipay. Product.
Check the API Cheatsheet for an overview.
Constructor¶
-
class
millipay.EventReactionCollector(eventEmitter, eventName)¶ Arguments: - eventEmitter (Object) – an Object firing events.
- eventName (String) – the exact event name this collector is managing.
Methods¶
-
erc.show(selector)¶ Arguments: - selector (JQuerySelector) –
Check the JQuerySelector to understand the power and implications. This method really does no more magic than calling
$(jquerySelector).show().
-
erc.hide(selector)¶ Arguments: - selector (JQuerySelector) –
Check the JQuerySelector to understand the power and implications. This method really does no more magic than calling
$(jquerySelector).hide().
Arguments: - href (string) – set window.location.href = href.
Normally used to open a detail page after paying on an overview page.
-
erc.fetchContentThenCall(contentURL, callback)¶ Arguments: - contentURL (string) – An URI to the location of the partial content to fetch via an AJAX call.
- callback – Gets called with the response.data of the AJAX call.
The AJAX call to contentURL is a
POSTrequest containing a JSON Webtoken with the payment confirmation. You can decode and verify this JWT with your merchant secret. It contains the pay instruction data, and your custom payload data as well. The contentURL endpoint must accepttext/plainand respond withtextas content type.
{
url: contentURL,
method: "POST",
data: paymentConfirmationJWT,
responseType: 'text',
headers: {
'Content-Type': 'text/plain',
}
})
-
EventReactionCollector.fetchContentThenInject(contentURL, selector)¶ Arguments: - contentURL (string) – An URI to the location of the partial content to fetch via an AJAX call.
- selector (JQuerySelector) – $(selector).html(response.data), target DOM element gets the response set as html.
The AJAX call to contentURL is a
POSTrequest containing a JSON Webtoken with the payment confirmation. You can decode and verify this JWT with your merchant secret. It contains the pay instruction data, and your custom payload data as well. The contentURL endpoint must accepttext/plainand respond withtextas content type. The returned response data is set as html of the selected DOM element.
{
url: contentURL,
method: "POST",
data: paymentConfirmationJWT,
responseType: 'text',
headers: {
'Content-Type': 'text/plain',
}
})
-
erc.call(callback)¶ Arguments: - callback – function to call if event reaction collector was activated.
Create your specific reaction code, e.g. use your analytics tool to gather payment process event analytics.