Modem Pay uses API keys to authenticate requests, ensuring that only authorized applications can access payment functions. API keys are generated in the Modem Pay dashboard and can be used in either live or test modes.

  1. API Keys
    Modem Pay provides two types of API keys:

    • Public Key: Used on the client side for initial requests (e.g., HTML form submissions).
    • Secret Key: Used on the server side for secure API calls and operations that need high trust (e.g., managing payment intents, accessing sensitive customer data).
  2. Using API Keys in Requests
    To authenticate a request, include the appropriate key in the request header:

    import ModemPay from "modem-pay";
    
    const modempay = new ModemPay("sk_test_b9596....4865");
    

    Alternatively, in HTML forms, pass the public_key as a hidden field.

  3. Test and Live Modes

    Modem Pay separates test and live keys, enabling you to test transactions without impacting real accounts. Test keys operate in a sandbox environment, allowing you to simulate payment flows before going live.