Mode Payment

window.addEventListener("load", function () {
  paygreenjs.init({
    paymentOrderID: "po_4b6c4203ff89488265ar971f45ac6ff9",
    objectSecret: "6a2d6828147f626d",
    mode: "payment",
    publicKey: "pk_231e1063b8fb324d9324acc9f94af8a5",
    instrument: "ins_fc6409dc32f248839295539623276cl98", // Optionnal
    token: "tkn_6e59a2fc97caze936a9b20fa57b18df13", // Optionnal
    paymentMethod: "bank_card", // Optionnal
    style: {
      input: {
        base: {
          color: "black",
          fontSize: "18px",
        },
      },
    },
  });
});

Once the init method will be exectued, you should see the payment form (or the payment methods available if no paymentMethod is provided)

Mode Instrument

window.addEventListener("load", function () {
  paygreenjs.attachEventListener(
    paygreenjs.Events.INSTRUMENT_READY,
    (event) => {
      const instrument = event.detail.instrument;
      // ...Handle instrument here
    }
  );

  paygreenjs.init({
    publicKey: "pk_231e1063b8fb324d9324acc9f94af8a5",
    mode: "instrument",
    buyer: "buy_34def8077f774cea8a6f58daojns65419",
    modeOptions: {
      authorizedInstrument: true,
    },
    paymentMethod: "bank_card",
  });
});

Instrument mode provide you a valid instrument once the form has been completed. You will get the instrument (authorized or not) throught the INSTRUMENT_READY event. Tokenizing error will be return in the event TOKEN_FAIL.

You can create an instrument as a marketplace for a sub-shop using the params modeOptions.shopId passing the sub-shop id

After, for example, you can init PGJS in payment mode with the token to process the payment.

Mode Tokenizer (deprecated)

❗️

Tokenizer is deprecated

Please use mode Instrument instead. Mode tokenizer will not receive any more updates.

window.addEventListener("load", function () {
  paygreenjs.attachEventListener(
    paygreenjs.Events.TOKEN_DETAILS_READY,
    (event) => {
      const token = event.detail.token;
      // ...Handle token here
    }
  );

  paygreenjs.init({
    publicKey: "pk_231e1063b8fb324d9324acc9f94af8a5",
    mode: "tokenizer",
    paymentMethod: "bank_card",
  });
});

Tokenizer mode provide you a valid Token once the form has been completed. You can retrieve the token throught
the TOKEN_DETAILS_READY event. Tokenizing error will be return in the event TOKEN_FAIL.

After, for example, you can init PGJS in payment mode with the token to process the payment.