Skip to main content
Version: 3.0.0 (current)

Events

Listen to events emitted from the iframe

_briqpay.subscribe('event name here', function (data) {
// Use data as you wish
})

Available events:

  • addressupdate
  • billing_validate
  • shipping_validate
  • additionalFieldsUpdate
  • upsellFieldsUpdate
  • make_decision
  • before-purchase
  • session_complete

Act on updated addresses

One common use case is to update the offered shipping methods based on the user's selected shipping address. You can accomplish this by listening to the addressupdate event, which will expose the selected postcode and allow you to calculate new shipping options.

_briqpay.subscribe('addressupdate', function (data) {
// use data as you wish
})
Data that Briqpay will share in the addressupdate callback
{
"billingaddress": { "zip": "12345", "country": "SE" },
"shippingaddress": { "zip": "12345", "country": "SE" }
}

Validating addresses

It might be desirable to validate a user's inputted address in the frontend. This is achievable by subscribing to the events for shipping_validate or billing_validate, respectively.

_briqpay.subscribe('billing_validate', function (data) {
console.log(data) //
})
_briqpay.subscribe('shipping_validate', function (data) {
console.log(data) //
})

Both events for validating the addresses expose the same data, allowing you to perform any necessary validation.

Data that Briqpay will share in the callbacks
{ "zip": "12345", "country": "SE", "city": "The test city" }

Adress validation result

If you have subscribed to any of the above methods, the client will automatically suspend and wait for your frontend reply on how to proceed. Therefore, it's important to call the validation method. If you don't call the validation method, the client will automatically reject the update after 7 seconds.

To approve or deny, use the billingValidate or shippingValidate function, respectively:

window._briqpay.v3.billingValidate(true)
or
window._briqpay.v3.shippingValidate(true)

Session complete

If you have set disableSessionCompleteRedirect to true when creation a session, the session_complete event might be useful to identify when a session has been completed. If there's a redirect, listening and acting to this event may not give you enough time to fulfill the action.

_briqpay.subscribe('session_complete', function (data) {
console.log(data) // Do your own redirect or hide Briqpay
})