Skip to main content

Accepting Regulations

The following methods allow to generate checkbox for accepting regulations. Appropriate link to regulations document is rendered.

PayuRegulationsForm Instance Creation with shopId and extCustomerId
PayuRegulationsForm(params, options?)
This method requires a public shop identifier and unique submerchant identifier.
Parametery metody
paramsrequiredobject
Regulations form parameters.
shopIdrequiredstring
Public shop identifier obtained from the PayU panel.
extCustomerIdrequiredstring
Unique submerchant identifier given by marketplace.
optionsoptionalobject
Instance options.
devoptionalboolean
Allows to create instance in developer mode which enables you to operate on a site that does not use HTTPS.
Return
PayuRegulationsForm instance.
Exceptions
invalid.params
Occurs when creating PayuRegulationsForm instance when no shopId or extCustomerId parameter is specified or is empty.
npn.https.integration
Occurs on MarketplaceVerification instance creation when the protocol of the page, on which JS SDK is loaded, is not https and file, and the page is not loaded from localhost: 127.0.0.1 or 0.0.0.0.
During the implementation process you can enable developer mode in the optionsparameter.
const regulationsForm =  PayuRegulationsForm({shopId: 'marketplace-shop-id', extCustomerId: 'ext-customer-id'});
PayuRegulationsForm Instance Creation with verificationId parameter
PayuRegulationsForm(params, options?)
This method requires a verification identifier, which you can obtain by creating submerchant using the PayU API.
Method Parameters
paramsrequiredobject
Regulations form parameters.
verificationIdrequiredstring
Verification identifier.
optionsoptionalobject
Instance options.
devoptionalboolean
Allows to create instance in developer mode which enables you to operate on a site that does not use HTTPS.
Return
PayuRegulationsForm instance.
Exceptions
invalid.params
Occurs when creating PayuRegulationsForm instance when no verificationId parameter is specified or is empty.
non.http.integration
Occurs on MarketplaceVerification instance creation when the protocol of the page, on which JS SDK is loaded, is not https and file, and the page is not loaded from localhost: 127.0.0.1 or 0.0.0.0.
During the implementation process you can enable developer mode in the options parameter.
const regulationsForm = PayuRegulationsForm({verificationId: 'VERIFICATION_ID'});

Examples

Methods

Accepting Regulations Methods
render(selector, options?)
Displays the form on the page.
Parametery metody
selectorrequiredstring
Selector of the element in which the form will be displayed. Searching for element is done by querySelectorAll.
optionsoptionalobject
Form options.
labelstring
The text displayed as checkbox label before link to regulations.
linkLabelstring
The text displayed as link to regulations. If not specified, link will be displayed.
styleobject
Your own form style.
Exceptions
element.selector.empty
selector parameter not specified or is empty.
element.selector.not.string
selector parameter is not of the type string.
element.not.exists
Element does not exists on the page.
element.too.many.exists
There is more than one element on the page.
element.not.valid
Invalid element (appendChild method is not implemented or it is an input element).
element.contains.children
Element contains secondary items.
regulationsForm.render('#regulationsForm', {
label: 'Accept ',
linkLabel: 'Terms and Conditions'
});
acceptRegulations()
Sending a request to accept regulations.
Exceptions
regulationsForm.not.rendered
Form was not displayed. Display the form with regulationsForm method.
regulationsForm.acceptRegulations();
on(event, callback)
Attaching your own callback to the event emitted by the secure form.
Method Parameters
eventrequiredstring
Event type
Possible Values
readyEmitted when the form is displayed.
acceptEmitted when a regulations are accepted on a secure form.
callbackrequiredfunction
Callback called after the event is emitted.
Exceptions
event.unknown
Unknown event type in event parameter.
event.callback.not.function
callback parameter is not a function.
documentForm
.on('ready', function() {
// formularz gotowy
});

documentForm
.on('accept', function(body) {
// zaakceptowano regulaminy
});

Form Styles

The style of the form depends on how the style object is set up.

style Object
The style object groups styles for different form behaviors in objects. Each group has its own set of permitted styles.
{
style: {
label: {
fontColor: '#ff0000',
fontSize: '20px',
fontFamily: 'Verdana',
fontWeight: 'bolder'
},
link: {
fontColor: '#888888',
fontWeight: '200',
textDecoration: 'none'
},
linkHover: {
fontColor: '#00ff00',
fontWeight: '700',
textDecoration: 'underline'
}
}
}
Style Groups
Style GroupPermitted StylesDescription
label
fontColor fontSize fontFamily fontWeight
Label styles.
link
fontColor fontWeight textDecoration
Link styles.
linkHover
fontColor fontWeight textDecoration
Style for hovered link.
Available Styles
StyleDescriptionPermitted Values
fontColor
font color
#[0-9a-f]{6}
fontSize
font size
(\d+|\d*\.\d+)(px|em|%)
fontFamily
font family
[0-9a-z\-\s]{1,50}
fontWeight
font weight
([1-9]00|normal|bold|lighter|bolder|inherit|initial|unset)
textDecoration
text decoration
(none|underline)

Events

Forms emit events to which you can attach your own callback using the on method.

ready Event
This event is emitted after calling render method after the form is displayed.
accept Event
This event is emitted when regulations are accepted. Callback is called with one object parameter with the following structure:
FieldDescription
status
Acceptance status:
  • SUCCESS - regulations acceptance was processed successfully,
  • Error - an error has occured while accepting regulations. Error information can be found in error field.
error
Only for ERROR status. Object with messages array which contains error information. Details can be found in Errors section.
correlationId
Only for ERROR status.

Errors

error object contains an array of objects (messages), which contain detailed information about the errors.

messages Object
error Object Parameters
FieldDescription
code
Error code.
message
Error description in english.
parameters
Object containing changeable error fragments.
Possible Error Codes
FieldLinked EventDescription
regulations-not-checked
accept
The checkbox is not checked. Checking checkbox is required to accept regulations.
error.regulations.acceptance
accept
An error has occured while processing acceptance.
error.network
accept
A network communication error has occurred. Information about the cause of the error can be found in parameters object in the error field.
event Object Example
{
"status": "ERROR",
"correlationId": "correlation-id",
"error": {
"messages": [
{
"code": "regulations-not-checked",
}
]
}
}