Skip to content

STK Request

Mauko Maunde edited this page Jan 8, 2021 · 1 revision

Wrap your request in a try catch to ensure proper error handling

try {
    return $res = C2B::stk($phone, $amount, $reference);

    // Do something with $res, like save to DB with the $res["MerchantRequestID"] as key.
} catch (\Throwable $th) {
    return $th;
}

OR

try {
    return $res = STK::send($phone, $amount, $reference);

    // Do something with $res, like save to DB with the $res["MerchantRequestID"] as key.
} catch (\Throwable $th) {
    return $th;
}
Clone this wiki locally