Tutorials

Step-by-step guides, from your first payment to a live integration.

No code needed to start Test mode Go live checklist
Your first payment, no code PigaPay checkout on your website Receive payment results safely Test, then go live

Your first payment, no code

5 minutes · for any business

Take a payment today with a payment link or QR code. No website needed.

  1. Create your free account and confirm the code we send you.
  2. Open Payment Links in your dashboard and press New Link.
  3. Set the amount (or let the customer type it) and a short description.
  4. Share it: send the link on WhatsApp or SMS, or print the QR code for your shop counter.
  5. The customer pays by phone with M-Pesa, Mixx by Yas, Airtel Money or HaloPesa, and you see the payment in your dashboard.

PigaPay checkout on your website

20 minutes · PHP

Send your customer to a PigaPay payment page. PigaPay asks for the phone number, sends the prompt, lets them try again and brings them back to your site.

  1. Create a test key in your dashboard: API Keys, then Create key, mode Test. Copy the key and the webhook secret.
  2. Download the PHP library and save it next to your code.
  3. Create a checkout when the customer presses Pay on your site:
    $pigapay  = new PigaPay\Client(getenv('PIGAPAY_KEY'));
    $checkout = $pigapay->createCheckout([
        'amount' => $order->total, 'reference' => 'ORDER-' . $order->id,
        'success_url' => 'https://yourshop.co.tz/paid', 'cancel_url' => 'https://yourshop.co.tz/cart',
    ]);
    header('Location: ' . $checkout['url']);
  4. Show a thank-you page at your success_url. Mark the order paid only from the webhook (next guide), not from this page.

Receive payment results safely

15 minutes

PigaPay sends every result to your webhook URL, signed with your webhook secret.

  1. Set your webhook URL on the key (API Keys, Edit), for example https://yourshop.co.tz/pigapay/webhook.
  2. Check the signature on every request and answer 200:
    $event = PigaPay\Webhook::fromRequest(getenv('PIGAPAY_WEBHOOK_SECRET'));
    if ($event['event'] === 'payment.completed') {
        markOrderPaid($event['reference'], $event['event_id']);   // once per event_id
    }
    http_response_code(200);
  3. Press Send test on the API Keys page: your server should answer 200.
  4. Missed one? PigaPay tries again after 1 minute, 5 minutes, 30 minutes, 2 hours... and lists every delivery on the API Keys page.

Test, then go live

Checklist

With a test key no money moves and no phone is contacted. These numbers give these results:

  1. 255700000001 fails (not enough money), 255700000002 is cancelled, 255700000003 stays waiting; any other number completes.
  2. Upload your business documents (BRELA, TIN, NIDA) so you can withdraw.
  3. Create a live key with the same settings and your server's IP under Allowed IPs.
  4. Swap the keys in your settings file, then make one small real payment to check.
Full API reference Full developer guide (sign in)
Kiswahili Report a payment problem

Talk to us