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:
Name | Description | Required | Default | Type |
---|---|---|---|---|
paymentOrderID | ID of the payment order | Yes in payment mode | null | String |
objectSecret | Secret of the payment order. This one is provided once in the response of the POST createPaymentOrder | Yes in payment mode | 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 |
paymentMethod | Force 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 mode | null | String |
mode | Choose how the library will work. Payment mode will execute a payment. Instrument modes will provide you a valid instrument. More info here | Yes | payment | String |
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 | No | { authorizedInstrument?: false, shopId?: null } | Object |
style | Pass a custom style to the payment form. Will apply to inputs inside the iframes See customization | No | Null | Object |
buyer | ID of the buyer to link the instrument created (instrument mode only) | 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 (inline or modal ) | No | inline | String |
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",
});
Updated about 2 months ago