Skip to main content

Configure Dojo components

Dojo Card

const card = new Dojo.Payment(config, displayErrorsCallback, onSubmitTriggered, onBlur);
ParameterTypeDescription
configobject ConfigRequired. Config containing details of this payment and the styling of the payment form.
displayErrorsCallbackfunctionAn optional callback to display text validation errors. The supplied function is called when there is a validation state change. This function is passed an array of validationError objects.
onSubmitTriggeredfunctionAn optional callback that's called when the submit event on the payment form is fired. This allows the payment to be submitted or extra validation done when the user presses the enter key on the payment form.
onBlurfunction(isValid: boolean)An optional callback that's called when focus is lost from any field in the form. The parameter isValid will be true when all fields are completed and there are no validation errors.

Dojo Wallet

const wallet = new Dojo.WalletPayment(config, displayErrorsCallback, paymentComplete);
ParameterTypeDescription
configobject ConfigRequired. Config containing details of this payment and the styling of the payment button.
displayErrorsCallbackfunctionAn optional callback to display text validation errors. The supplied function is called when there is a validation state change. This function is passed an array of validationError objects.
paymentCompletefunctionA callback that returns the result of payment. The supplied function is called when the payment is executed. This function is passed a Transaction Result object.

Configuration

PropertyTypeDescriptionCard ComponentWallet Component
containerIdstringRequired. The id of the div element where the payment details will be displayed.
paymentDetailspaymentDetailsRequired. Details of the payment to be made.
fontCssarray of stringsArray of urls pointing to css files for importing fonts, for example https://fonts.googleapis.com/css?family=Do+Hyeon-
stylesstylesConfigRequired. Object defining custom styles for the payment form.-
texttextConfigObject defining text to override the defaults.-
onIframeLoadedfunctionAn optional function that's called once the iframe has been loaded and configured.
onIframeLoadFailedfunctionAn optional function that's called if there is an error loading the iframe.
errorMessageserrorMessagesObject defining custom validation error messages for the payment form.
callbackscallbacksConfigObject defining callback functions on various events.-
callbackswalletPaymentCallbacksConfigObject defining callback functions on various events.-
buttonConfigbuttonConfigAn optional button config. It defaults to colour black and type plain.-
emailRequiredbooleanAn optional config to collect the buyer's email. It defaults to false.-
billingAddressRequiredbooleanAn optional config to collect the buyer's billing address. It defaults to false.-
shippingAddressRequiredbooleanAn optional config to collect the buyer's shipping address. It defaults to false.-

Payment details

PropertyTypeDescription
paymentTokenstringRequired. The access token supplied by the get access token API.

Styles configuration

PropertyTypeDescription
basefieldStyleRequired. Styles to be applied to all fields.
cv2fieldStyleStyles to override the base styles for the cv2 field.
cardNumberfieldStyleStyles to override the base styles for the card number field.
expiryDatefieldStyleStyles to override the base styles for the expiry date field.
cardNamefieldStyleStyles to override the base styles for the card name field.
cardIconJavaScript CSS propertiesStyles to be applied to the card icon.
formJavaScript CSS propertiesStyles to be applied HTML form element containing all the fields.

Field style

PropertyTypeDescription
defaultJavaScript CSS propertiesStyles to be applied when the field is in its initial state.
focusJavaScript CSS propertiesStyles to be applied when the field has focus.
errorJavaScript CSS propertiesStyles to be applied when the field has failed validation.
validJavaScript CSS propertiesStyles to be applied when the field has passed validation.
errorFocusJavaScript CSS propertiesStyles to be applied when the field has focus and is in an error state.
validFocusJavaScript CSS propertiesStyles to be applied when the field has focus and is valid.
containerJavaScript CSS propertiesStyles to be applied to the div wrapping the label and the input field.
labelJavaScript CSS propertiesStyles to be applied to the label.
validationTextJavaScript CSS propertiesStyles to be applied to the validation message. Only applicable if text.(cardName |cardNumber|expiryDate|cv2).showValidation is true.
validationIconJavaScript CSS propertiesStyles to be applied to the validation message icon. Only applicable if text.(cardName |cardNumber|expiryDate|cv2).showValidation is true. E.g., to set the icon colour to purple set this property to { backgroundColor: 'purple' }

Text configuration

PropertyTypeDescription
cardNamefieldTextConfig to override the default card name placeholder and label text.
cardNumberfieldTextConfig to override the default card number placeholder and label text.
expiryDatefieldTextConfig to override the default cv2 placeholder and label text.
cv2fieldTextConfig to override the default expiry date placeholder and label text.

Field text

PropertyTypeDescription
labelstringRequired. Text to replace the default label text.
placeholderstringRequired. Text to replace the default placeholder text. (Empty will be ignored)
showValidationbooleanOption to show the validation message. Defaults to false if not set.

Button configuration

PropertyTypeDescription
colourstringIt defaults to black, but it can optionally be changed to white.
typestringIt defaults to plain (payment button without additional text), but it can optionally be changed to book (Book with GooglePay/ApplePay), buy, checkout, donate or order.

Error messages

This allows overriding of the default error messages. This will override both the messages passed to displayErrorsCallback and the message displayed if showValidation is set to true.

PropertyTypeDescription
cardNameRequiredstringCard name isn't entered.
cardNameInvalidstringInvalid card name is entered.
cardNumberRequiredstringCard number isn't entered.
cardNumberInvalidstringInvalid card number is entered.
expiryDateRequiredstringCard expiry date isn't entered.
expiryDateInvalidstringInvalid card expiry date is entered.
expiryDateMustBeInFuturestringCard expiry date isn't in the future.
cv2RequiredstringCV2 isn't entered.
cv2InvalidstringInvalid CV2 is entered.

Card callbacks

PropertyTypeDescription
onFormCompletefunctionAn optional function which is called once the form is complete and all input values are valid.
onFormFieldValidfunction(fieldName: string)An optional function which is called once a form field input is valid.

Wallet callbacks

PropertyTypeDescription
onPaymentCancelledfunctionAn optional function which is called if the user closes the wallet payment form without paying.
onPaymentInitiatedfunctionAn optional function which is called when the wallet payment button is clicked.

Validation error

PropertyTypeDescription
errorTypestringThe type of validation error that has occured. For the card component this can be one of the following: cardNameRequired, cardNameInvalid, cardNumberRequired, cardNumberInvalid, expiryDateRequired, expiryDateInvalid, expiryDateMustBeInFuture, cv2Required, or cv2Invalid.
messagestringMessage detailing the validation error for displaying to the user.

Execute payment

card.executePayment(additionalInfo)
.then(function(data){
/*handle response here*/
}).catch(function(data){
/*handle failure here*/
}

When the promise is fulfilled the following object will be passed.

Transaction result

PropertyTypeDescription
statusCodestatusCodeIndicated the status of the transaction. 0 for a successful transaction.
authCodestringIf the transaction was successful, then the auth code is passed out here.
messagestringThis gives a more detailed description of the status of the transaction.

Status code

Status CodeResultDescription
0SuccessfulThe transaction was successful.
3AuthorizingThe card holder hasn't completed 3DS, this status will only be seen on the REST API.
4ReferredThe card issuer has parked the transaction awaiting contact with the customer before proceeding to authorize or decline the transaction.
5DeclinedThe transaction was declined by the card issuer or acquiring bank.
20Duplicate TransactionThe transaction which was processed was a duplicate. Ensure each transaction has a unique OrderId.
30FailedError executing transaction.
400Invalid RequestThe request has failed validation by our servers and the transaction hasn't been submitted to the gateway. Possible causes for this are invalid transaction type or other data in the request.
401Issue with Access TokenThe access token being used isn't valid, the transaction hasn't been submitted to the gateway. This can be caused if the token has already been used or the 30 minute expiry time has elapsed.
404No Access Token SuppliedNo access token has been supplied to Connect-E. Transaction hasn't been submitted to the gateway.
500Internal Server ErrorThere's been an error submitting the transaction, please check the REST API for the status of the transaction.

Additional information

The user's email address and billing address can be passed as the optional additionalInfo object as defined below. These values will override those set when the access token was created.

PropertyTypeDescription
userEmailAddressstringThis email will be checked with the card issuer to provide additional security.
userPhoneNumberstringThe cardholder's phone number.
billingAddressaddressThis address will be checked with the card issuer to provide additional security.
shippingDetailsshippingDetailsShipping details for the order.
metaDataMap<string, string>Meta data to be passed at execution time. This will be merged into MetaData passed via the REST API. This can be represented as a JSON object with only string values, other types aren't supported.

Shipping details

PropertyTypeDescription
namestringName order is being shipped to.
addressaddressAddress order is being shipped to.

Address

PropertyTypeDescription
address1stringCustomer’s billing address line 1.
address2stringCustomer’s billing address line 2.
address3stringCustomer’s billing address line 3.
address4stringCustomer’s billing address line 4.
citystringCustomer’s billing address city.
statestringCustomer’s billing address state or county.
postcodestringCustomer’s billing address postcode or zipcode.
countryCodestringCustomer’s billing address country code using ISO 3166–1 for example United Kingdom: 826.