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 | 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 |
paymentMethod | Force the payment method to display. If empty, null or undefined will list all the payment methods available for the payment order. Useless if instrument is provided. Doesn't work for apple_pay and google_pay due to security policy | Yes in | null | String |
mode | Choose how the library will work. Payment mode will execute a payment. Instrument modes will provide you a valid instrument. | Yes |
| 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 |
| Object |
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
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 10 days ago