Quick start

Welcome to the SmartpayGenie Developer Documentation. This documentation is designed to help developers integrate with the SmartpayGenie payment gateway platform.

Prerequisites

  • A SmartpayGenie developer account
  • API keys (Public and Secret)
  • Basic understanding of JavaScript and AJAX requests
  • Steps to integrate payment processing

    1.Obtain API Keys:

  • Log in to your SmartpayGenie developer account.
  • Navigate to the API Keys section.
  • Generate a new API key pair.
  • 2. Create a Payment Form:

  • Create an HTML form with necessary fields like amount, currency,
  • description, etc.
  • Add a button to trigger the payment process.
  • 3.Implement Payment Processing Logic:

  • Use JavaScript to handle form submission.
  • Make an AJAX request to the SmartpayGenie API to create a payment.
  • Include your API keys in the request headers.
  • Handle the API response and redirect the customer to the payment gateway.
  • javascript
    
        const myHeaders = new Headers();
    myHeaders.append("token", "TlAWiePV51isvfuRZEHuCOW1ZDBeDHep2rnosIXHRVGvMwyFTMJZUVCeIneQJJ0h");
    myHeaders.append("Content-Type", "application/json");
    
    const raw = JSON.stringify({
      "customerId": "49438567-bc45-494c-b57d-80b41f193de7",
      "currency": "kes",
      "channel": "fiat"
    });
    
    const requestOptions = {
      method: "POST",
      headers: myHeaders,
      body: raw,
      redirect: "follow"
    };
    
    fetch("https://api.switch.tulupay.com/customer/add-account", requestOptions)
      .then((response) => response.text())
      .then((result) => console.log(result))
      .catch((error) => console.error(error));
    
        }

    Handling payment notifications

  • Set up a webhook URL in your SmartpayGenie dashboard to receive payment notifications.
  • Implement a server-side endpoint to handle these notifications.
  • Process the notification data to update your application's state, such as marking orders as paid or sending confirmation emails.
  • Security considerations

  • API Key Security: Store your API keys securely, avoiding hardcoding them in client-side scripts.
  • Data Encryption: Encrypt sensitive customer data, such as credit card information, before transmitting it.
  • Input Validation: Validate user input to prevent malicious attacks.
  • HTTPS: Ensure your website uses HTTPS to protect data transmission.
  • Additional tips

  • Test Environment: Use the SmartpayGenie test environment to simulate real-world scenarios without affecting live transactions.
  • Error Handling: Implement robust error handling and retry mechanisms.
  • Documentation: Refer to the detailed API reference for specificendpoints, request parameters, and response formats.