0.4.1 • Published 1 year ago
@paycore/merchant-widget-js v0.4.1
##An client third-party inteface to init and render Mechant HPP to an a clint page with custom options.
#Initializing iframe on page.
- Get iframe widget from CDN.
<script src="https://unpkg.com/@paycore/merchant-widget-js@0.4.1/dist/merchantWidget.umd.min.js"></script>- Init widget on your client page:
window.widget.init({
selector: 'HTML_ID_SELECTOR_TO_INSERT_WIDGET_INTO',
flow: 'iframe',
public_key: 'YOUR_PUBLIC_KEY',
amount: 'AMOUNT_OF_INVOICE',
currency: 'USD',
baseUrl: 'URL_OF_YOUR_HPP',
});Parameters
optionsObject Requiredoptions.selectorString Selector on client page you wnat insert iframe to. Required.options.flowString Widget supports 2 ways to initalize HPP - in the iframe or in blank page. To Open widget in the iframe, you need pass iframe flow, or redirect for open in new browser tab;options.public_keyString Commerce account PUBLIC API_KEY Requiredoptions.baseUrlString Base endpoint to HPP that will be initialized in the iframe. Requiredoptions.currencyString The currency of the invoice (3-letter ISO 4217 code). Must be a commerce-account supported currency. Required.options.amountNumber The amount of payment invoice
HPP Layout config
You can set which elements of our HPP you want to hide. To do this, you need set true Boolean value;
options.displayObject HPP layout config.options.display.hide_footerBooleanoptions.display.hide_headerBooleanoptions.display.hide_progress_barBooleanoptions.display.hide_method_filterBooleanoptions.display.hide_lifetime_counterBoolean
HPP Styling config
You can set custom variables to styling your HPP. Some of variables will be generated automatically based on their related colors values. For example, if you will pass dark accent color (options.style.primary) then primary_variant and on_primary_color variables will be generated for the best user readabilyty.
options.styleObject HPP Styling config.options.style.themeString One of presetted themes ( 'basic' or 'dark').options.style.primaryObject Primary/Accent coloroptions.style.primary_variantObject - Based on primary color, or can be passed by you. If primary color will be dark - then this variable will be lighter. Used on most important UI components (stepper,buttons)
Customer info
If customer data is provided, it will be passed in the payment processing request.
options.customer.reference_idString Unique identifier of the customer. Must always have to be in the customer data objectoptions.customer.emailString Customer email (Optional)options.customer.nameString Customer name (Optional)options.customer.phoneString Customer phone (Optional)options.customer.date_of_birthString - FORMAT "YYYY-MM-DD" Customer date of birth (Optional)options.customer.individual_tax_idString Customer individual tax ID (Optional)options.customer.metadataObject Key-value map to provide additional user info (Optional)options.customer.addressObject User address information (Optional)options.customer.address.countryString - ALPHA 2 CODE Customer country (Optional)options.customer.address.cityString Customer city (Optional)options.customer.address.post_codeString Customer post code (Optional)options.customer.address.regionString Customer region (Optional)options.customer.address.streetString Customer street (Optional)options.customer.address.full_addressString Customer full address (Optional)