JS API public methods

JS api public methods

Either merchants that fully integrate js api and use the default cashier, or merchants that use their own forms, they will need to interact and use the given public methods to retrieve account data, to perform an account registration etc.

EPGJS includes three main public objects merchants can make use of:

  • EPGJS
  • EPGJS_COM
  • EPGJS_STYLE

EPGJS object and its methods

This object manages most of the rendering available methods to render a cashier or methods that control the flow such as rendering callback success/errors, field function validations, etc.

The following table will go over all the public methods, showing their params and the method explanation:

Public method Parameters Description
renderCashier authToken, containerDiv This method will be called whenever we want to render the cashier in a div provided as parameter. It takes two parameters:

  • The auth token will also be needed in order to obtain all the forms info and validate the info
  • Container div where the cashier will be drawn
renderRegisterAccount publicMerchantToken, paysol, containerDiv This method will be used to render an anonymous cashier. This will be specially useful for ecom business where they don’t keep track or register their customers information. It takes three parameters.

  • A public merchant key will be needed (not the same as the merchantKey).
  • The paysol we want to render the cashier for
  • The container div where the cashier will be drawn
setRenderCashierErrorCallback merchantFunction This method will allow the merchant to set a function that will be fired whenever an error renderingTheCashier is raised. The unique param that it takes is a function to be fired when an error is raised
setPrePayAccountErrorCallback merchantFunction This method will allow the merchant to set a function that will be fired whenever an error calling to a prepay action is raised.
setRemoveAccountErrorCallback merchantFunction This method will allow the merchant to set a function that will be fired whenever an error removing an account is raised.
setQuickPayErrorCallback merchantFunction This method will allow the merchant to set a function that will be fired whenever an error performing a quickDeposit is raised.
setOnFormSubmit merchantfunction This method will allow the merchant to override the formSubmit behavior which is triggered on all the communications actions. By default this function takes a resumeMethod and dataParam as paremters and resumeMethod will be called with dataParam
setTranslate merchantFunction This method will allow the merchant to override the translate function that epgjs uses by default.
getLang Gets the language setted in the epgjs object to render the cashier
setLang lang Sets the language to be used by the epgjs object to render the cashier
getI18n Gets the internationalization object used to render the cashier. This object is grouped by languages and has the label translations for the objects of the cashier
setI18n i18n Sets the internationalization object used to render the cashier. This allows to extend the cashier’s translation to other languages
setShowAllPaysolToRegisterAndQuickDeposit allow Sets a flag to tell the api whether it will draw the anonymous available payments solutions under the register or the quickpay options or not
getTranslate Gets the translation function used to render the cashier
setOnBlurOverrideValidationError merchantFunction This method will allow the merchant to override the validation function that epgjs uses by default to detect whether a field has errors or not
getRegisterAccountErrorCallback merchantFunction This function will allow the merchant to override the function that will be triggered whenever an error is raised registering an account
getPaymentMethod This function will return all the payment solutions configured for the merchant and product used in the authToken

 

EPGJS_COM object and its methods

This object is meant to manage all the communications against EPGJS integration endpoints, allowing the merchant to override some of the functions that will be called after this calls.

Public method Parameters Description
call Method, url, data, headers, callback, errorCallback Javascript low level function used to perform calls to different endpoints.

  • Method: Method used to perform the call
  • Url: endpoint to be called
  • Data: data to be sent in the body
  • Headers: list of headers that will be sent
  • Callback: function that will be called on a success case
  • errorCallback: function that will be called when a call error is produced.
callForRetrieveCashierData authToken, successCallback, errorCallback Function that will be used by epgjs api to get all the info to render a cashier.

  • authToken: token needed to perform all the calls.
  • SuccessCallback: function to be called processing a success result
  • errorCallback: function to be called processing an error result
callForRetrieveRegisterCashierData publicMerchantToken, paysol, successCallback, errorCallback Function used to draw an specific paysol form for an anonymous user.

  • publicMerchantToken: public merchant key (not the merchant key) used to render cashiers for anonymous customers.
  • Paysol: desired paysol to be drawn
  • successCallback: function to be called processing a success result
  • errorCallback: function to be called processing an error result.
callForDisableAccount accountId, authToken, successCallback, errorCallback Function used to disable a specific account.

  • accountId: account to be disabled
  • authToken: token needed to perform all the calls.
  • SuccessCallback: function to be called processing a success result
  • errorCallback: function to be called processing an error result
callForPrePay accountId, authToken, jsonData, successCallback, errorCallback Function that will call an specific endpoint to perform a prepay operation.

  • accountId: the account we want to to pay/withdraw with.
  • authToken: token needed to perform all the calls.
  • jsonData: payment solution need info to perform a charge operation (cvv for CC, password for wallet accounts, etc)
  • SuccessCallback: function to be called processing a success result
  • errorCallback: function to be called processing an error result
callForRegisterAccount jsonData, paysol, authToken, successCallback, errorCallback Function that will call an specific endpoint to register a customer account.

  • jsonData: Info needed to register an account. Info defined by EPG on their forms.
  • Paysol: paysol we want to register the account for.
  • authToken: token needed to perform all the calls.
  • SuccessCallback: function to be called processing a success result
  • errorCallback: function to be called processing an error result
callForQuickPay jsonData, paysol, authToken, successCallback, errorCallback Function that will call to an specific endpoint to perform a quickpay operation (register + prepay).

  • jsonData: Info needed to register an account and pay. Info defined by EPG on their forms.
  • Paysol: paysol we want to register the account for.
  • authToken: token needed to perform all the calls.
  • SuccessCallback: function to be called processing a success result
  • errorCallback: function to be called processing an error result
setCallMethod callFunction Method that will override the call function with a personalized function
getEpgBaseUrl Function that will return an EPG base url used for different functions to call to several endpoints
setEpgBaseUrl url Method that will set the EPG base url to call to different endpoints
getMerchantRegisterAccountCallback Function that will return the function to be called on a success registered account
setMerchantRegisterAccountCallback merchantFunction Method that will set a function to be called on a success register account
setRegisterAccountErrorCallback merchantFunction Method that will set a function to be called on an error register account
getRegisterAccountErrorCallback Function that will get the function used on an account registration error result
getMerchantPrepayCallback Function that will get the function used on a prepay operation success result.
setMerchantPrepayCallback merchantFunction Method that will set a function to be called on a prepay success operation result
getShowOnlyCardRegister Function that will return whether option to register a credit card will appear or not
setShowOnlyCardRegister showOnlyCardReg Method that will set whether credit card registration will appear or not
getOnlyRegisteredAccounts Function that will return whether option to register accounts will appear or not
setOnlyRegisteredAccounts onlyRegisteredAccounts Method that will set whether account registration will appear or not

EPGJS_STYLE object and it’s public methods

This object will allow merchants to customize the default css styles for the rendered cashier elements.

Public method Parameters Description
getClass key Function that will return the style class used for an specific theme.
getCssTheme Function that will return the setted css theme
setCssTheme theme Sets the theme to be used by the cashier
Cookies Policy We need our cookies to make Easy Payment Gateway better. If you need more information click here.