PHP
PHP copied to clipboard
No Payment Method Available at the moment. Please reach out to support
Description
When I try to make any payment method like Card or Mpesa I get this error.
No Payment Method Available at the moment. Please reach out to support
Reproduces how often
This is my code
public function initiateMpesaPayment($amount, $customer, $redirectUrl, $sale_id)
{
$transactionRef = "TEST-" . uniqid() . time();
$data = [
"amount" => $amount,
"currency" => Currency::KES,
"tx_ref" => $transactionRef,
"redirectUrl" => $redirectUrl
];
$mpesaPayment = Flutterwave::create("mpesa");
$customerObj = $mpesaPayment->customer->create([
"full_name" => $customer->name,
"email" => $customer->email,
"phone" => $customer->phone
]);
$data['customer'] = $customerObj;
$payload = $mpesaPayment->payload->create($data);
return $mpesaPayment->initiate($payload);
}
public function initiateCardPayment($amount, $customer, $cardDetails, $redirectUrl, $sale_id)
{
$transactionRef = "TEST-" . uniqid() . time();
$data = [
"amount" => $amount,
"currency" => Currency::KES,
"tx_ref" => $transactionRef,
"redirectUrl" => $redirectUrl,
"additionalData" => [
"subaccounts" => [
["id" => "RSA_345983858845935893"]
],
"meta" => [
"unique_id" => uniqid() . uniqid()
],
"preauthorize" => false,
"payment_plan" => null,
"card_details" => $cardDetails
],
];
$cardPayment = Flutterwave::create("Card");
$customerObj = $cardPayment->customer->create([
"full_name" => $customer->name,
"email" => $customer->email,
"phone" => $customer->phone
]);
$data['customer'] = $customerObj;
$payload = $cardPayment->payload->create($data);
return $cardPayment->initiate($payload);
}
Hi @Jimmy-kiarie8 Please kindly call the bootstrap method in your constructor Flutterwave::bootstrap(). For a custom configuration, please use the guide here