Available Callbacks

Here you can find all the available Callbacks that can be returned from the everypay.payform() or the everypay.tokenized functions.

    
   //payload is the object that is passed for the form initalization
   var payload = {
        pk: 'your-public-key',
        amount: 'your-amount'
    }

    //response returns a callback function which contains the response from the iframe
    function response(r) {
        if (r.onLoad) {
            //iframe has been loaded
        }   

        if (r.response === 'success') {
            //use token from r.token
        }   
        
        if (r.response === 'error') {
            //log the error
        }   
    }

    function isValid(v) {
        //returns { isValid: true }
        //form is validated correctly and user can proceed with the payment
        //(to be used in the case that you have an external button that uses everypay.onClick()
    }

   everypay.payform(payload, response, isValid, errorMsg, selectedInstallments);

Response Callback

The response can have 3 outcomes: onLoad, success, error.

NameTypeDescription
onLoadJSONThis callback comes back when the iFrame has completed its loading. It will always come back as true. An example use-case is to show a loader until this comes back.
successJSONThis callback will always contain a temporary token in order to proceed to the /payments API
errorJSON", uuid: "d5c43643-c1cb-4b27-a367-da05900bf035"}The format of the error will always be the same. You can save the code and the message and contact us for further debugging if needed.

onLoad example response

{ onLoad: true }

success example response

{response: "success", token: "ctn_KuTCy234YvB2RO4badRsvZJc", uuid: "c6c82264-089f-461e-b744-d9ba771bfb7f"}

error example response

{response: "error", { msg: { code: "20012", message: "3D Secure authentication failed Please provide another payment card", status: "402" }}, uuid: "4eae8bda-c812-4cce-847c-938faef8dc4d"}

isValid Callback

This Callback is used to let you know that the form has passed the validation and is ready to be submitted.

example

{ isValid: true }

errorMsg Callback

This Callback is an array and is used to let you know which fields are not passing validation within the form, so you can present custom error messages.

example

['cvv','name']

selectedInstallments Callback

This Callback is used to let you know how many installments the cardholder has selected before proceeding to the payment.

example

2