First, you must add the library and its style to the page of your site where you want the payment form to appear:
Once the script has been added, the varibale
paygreenjs will be available every where.
About security and PCI Compliance
To be PCI Compliant you must integrate PayGreenJS directly from pgjs.paygreen.fr. The scripts and style sheets cannot be included in your bundle.
Paygreen JS will automatically place elements on your page to collect payment information from the buyer. We find:
- Payment methods bloc
- Payment form bloc
- Card number field
- Expiration date
- CVV field
- Checkbox of consent (the buyer allows you or not to reuse the card. Available only if you have the option enabled and you don't manage it by your own)
In order for PaygreenJS (PGJS) to display these blocks correctly, you must place "skeletons" in your page. You can place them wherever you want on the page and thus vary the structure of the form as you wish.
|paygreen-container||Contains PGJS instance.|
Will not display anything.
|paygreen-methods-container||If no paymentMethod is provided, will display all available paymentMethods||No (if paymentMethod is provided)|
|paygreen-pan-frame||Contains card numbers||No (if paymentMethod is provided and it's not card method)|
|paygreen-cvv-frame||Contains card CVV||No (if paymentMethod is provided and it's not card method)|
|paygreen-exp-frame||Contains card expiration date||No (if paymentMethod is provided and it's not card method)|
|paygreen-reuse-checkbox-container||Contains a checkbox used to collect user consent to reuse instrument.|
This option must be activated for the payment configuration in the back office.
<div id="paygreen-container"></div> <div id="paygreen-methods-container"></div> <div class="my-custom-form"> <div id="paygreen-pan-frame"></div> <div id="paygreen-cvv-frame"></div> <div id="paygreen-exp-frame"></div> <div id="paygreen-reuse-checkbox-container"></div> </div>
You can place those elements wherever you decide on your page.
paygreenjs variable has many methods:
|init||Init the payment form.|
Take ParamsType as parameter
|unmount||Unmount the form.|
Accept a boolean parameter to unsubsribe events (default
|useInstrument||Use an instrument to complete the actual payment flow.|
Accept an instrument ID as paramter.
|status||Give the actual state of flows|
|submitPayment||Manually submit the payment form.|
|focus||Change the actual field focus.|
Accept an enum as parameter
|attachEventListener||Listen an event.|
Accept two parameters, first the name of the event, second the callback
|detachEventListener||Remove an event listener previoulsy attached|
|Events||List all available events|
|updateConsent||Change the actual state of the consent.|
Accept a boolean true/false parameter which represents if the user's consentment is implicit.
(can be used only if you passed an technical audit by Paygreen)
|setPaymentMethod||Change the payment method of the actual flow.|
Accepts string like the init params paymentMethod
|setLanguage||Change the current language of PGJS. Take language as param exemple: setLanguage("en")|
First of all, init the library with the method
init() by passing a parameter object of type
Here is a resume of all parameters available:
|paymentOrderID||ID of the payment order||Yes in ||null||String|
|objectSecret||Secret of the payment order. This one is provided once in the response of the POST createPaymentOrder||Yes in ||null||String|
|publicKey||Public key of your Paygreen shop. Yours can be found or created here||Yes||null||String|
|instrument||ID of the instrument. If provided will directly init a payment with this instrument (oneclick)||No||null||String|
|token||If provided will directly init a payment with this token||No||null||String|
|paymentMethod||Force the payment method to display.|
If empty, null or undefined will list all the payment methods available for the payment order.
Otherwise will display the payment method corresponding to the string value.
Useless if instrument or token is provided.
Doesn't work for apple_pay due to Apple security policy
|Yes in ||null||String|
|mode||Choose how the library will work. Payment mode will execute a payment. Instrument and tokenizer modes will provide you a valid instrument or token.|
More info here
|modeOptions||Options to define for each mode. Actually only used in instrument mode|
AuthorizedInstrument: define if the instrument will be authorized or not
ShopId: precise for which shop you want to create this instrument
|style||Pass a custom style to the payment form. Will apply to inputs inside the iframes||No||Null||Object|
|buyer||ID of the buyer to link the instrument created (||No||Null||String|
|displayCardLogo||Display the logo of the card provider in pan input||No||true||Bool|
|lang||Change language of the forms||No||Browser language||String|
|displayAuthentication||Define how you want to display the 3DS (||No||String|
Details parameters types are available here
Updated about 1 month ago