This document will show you how to collect payments from your customers using PayChangu inline in a js

Sample inline Redirect Implementation

You can embed PayChangu on your page using our PayChanguCheckout() JavaScript function. The function responds to your request in accordance with your request configurations. If you specify a callback_url in your request, the function will redirect your users to the provided callback URL when they complete the payment.

<form>
  <script src="https://in.paychangu.com/js/payment.js"></script>
  <div id="message"></div>
  <button type="button" onClick="makePayment()">Pay Now</button>
  </form>
<script>
    function makePayment(){
      PayChanguCheckout({
        "public_key": "pub-test-R1kGqpldxWW7HAVrRf4CRx4E6RSEbAmG",
        "tx_ref": '' + Math.floor((Math.random() * 1000000000) + 1),
        "amount": "1000",
        "currency": "MWK",
        "callback_url": "https://webhook.site/7657863465874",
        "return_url": "https://webhook.site",
        "customer":{
          "email": "[email protected]",
          "first_name":"Madalo",
          "last_name":"Phiri",
        },
        "customization": {
          "title": "Test Payment",
          "description": "Payment Description",
          "logo": "https://assets.piedpiper.com/logo.png"
        },
        "meta": {
          "uuid": "uuid",
          "response": "Response"
        }
      });
    }
    </script>

With this, you can go ahead and perform other activities like Transaction verification