3. Init the library

Init the library with the method init() by passing a parameter object of type ParamsType.
Here is a resume of all parameters available:

NameDescriptionRequiredDefaultType
paymentOrderIDID of the payment orderYes in payment modenullString
objectSecretSecret of the payment order. This one is provided once in the response of the POST createPaymentOrderYes in payment modenullString
publicKeyPublic key of your Paygreen shop. Yours can be found or created hereYesnullString
instrumentID of the instrument. If provided will directly init a payment with this instrument (oneclick)NonullString
paymentMethodForce the payment method to display.

list of payment methods

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 is provided.

Doesn't work for apple_pay and google_pay due to security policy
Yes in instrument modenullString
modeChoose how the library will work. Payment mode will execute a payment. Instrument modes will provide you a valid instrument.
More info here
YespaymentString
modeOptionsOptions 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
No{ authorizedInstrument?: false, shopId?: null }Object
stylePass a custom style to the payment form. Will apply to inputs inside the iframes

See customization
NoNullObject
buyerID of the buyer to link the instrument created (instrument mode only)NoNullString
displayCardLogoDisplay the logo of the card provider in pan inputNotrueBool
langChange language of the formsNoBrowser languageString
displayAuthenticationDefine how you want to display the 3DS (inline or modal)NoinlineString

Details parameters types are available here

Example

paygreenjs.init({  
  paymentOrderID: "po_xxxxxxxxxxxxxxxxxxx", <!--Add your payment order IDD-->  
  objectSecret: "xxxxxxxxxxxx", <!--Add the payment order objectsecret here -->  
  publicKey: "pk_xxxxxxxxxxx", <!--Add your public key heree-->  
  mode: "payment",   
});