4. Mobile App Setup

This section describes the setup process for plugging the VPay Javascript Payment Dropin into a mobile app (Flutter, ReactNative, etc). All examples are made with reference to the SANDBOX environment.

Sandbox: https://dropinbutton-sandbox.vpay.africa/service/pay

Live: https://dropinbutton.vpay.africa/service/pay

A. Open a webview and point to https://dropinbutton-sandbox.vpay.africa/service/pay while passing your payment options payload as a query string. This will load the SANDBOX dropin payment interface inside the webview and guide the customer to payment completion.

https://dropinbutton-sandbox.vpay.africa/service/pay?

    amount=1890
    &[email protected]
    &customer_logo=https://yourdomain.com/yourbusinesslogo
    &domain=sandbox
    &key=fdcdb195-6553-4890-844cee576b7ea715
    &
transactionref=a4b2-1345-
78da
    &[email protected],
+2348191000800
    &txn_charge_type=percentage
    &txn_charge=1.5
    &currency=NGN

B. Setup a socket stream listener against https://zander.vpay.africa (SANDBOX) or https://kola.vpay.africa (LIVE).

  • Emit a payload against the key NEW_TRANSACTION_REF and pass the same transactionref value used above as a stringified JSON payload.

  • Implement a socket listener against the key TRANSACTION_STATUS. Once the transaction is successful OR when the transaction Time-To-Live (TTL) has elapsed, the server will push a notification to your socket listener and then you may close the webview opened in #4A above.

See sample snippets below:

<script src="https://zander.vpay.africa/socket.io/socket.io.js"></script>
<!-- For LIVE setup, change script point to kola.vpay.africa -->
<!--<script src="https://zander.vpay.africa/socket.io/socket.io.js"></script>-->

<script>
  let socket_payload = JSON.stringify({
      transactionref: "xxx-xxxx"
  });
  
  let sandbox_socket_url = "https://zander.vpay.africa/";
  //let live_socket_url = "https://kola.vpay.africa/";  
  
  let socket = io(sandbox_socket_url, { transports: ["websocket"], forceNew: true });

  socket.on("connect", () => {
    console.log("Connected");
    socket.emit("NEW_TRANSACTION_REF", socket_payload);

    socket.on("TRANSACTION_STATUS", (data) => {
      //You may use the data['code'] to take next action

      // sample response data payload
      /*{
          reference: "efc2-g2dd-fvvb",            // the system generated ref
          transactionref: "ref-3458-72343085Hs",  //your generated ref
          code: "00",
          message: "Transaction successful",
          timestamp: "2023-12-09T12:38:49.505Z"
      }*/
    });
  });
</script>

Last updated

Was this helpful?