[email protected]
+(234) 9050 327 833
Get A free Qoute
SOPDAP
  • Home
  • Pricing
  • Services
    • Web Design Services
    • eCommerce Solution
    • Website Maintenance
    • Search Engine Optimization
    • Web Hosting
    • Domain Name Registration
  • Blog
  • About Us
    • Who we are
    • Our Portfolio
  • Contact Us
Sopdap Logo
  • Home
  • Pricing
  • Services
    • Web Design Services
    • eCommerce Solution
    • Website Maintenance
    • Search Engine Optimization
    • Web Hosting
    • Domain Name Registration
  • Blog
  • About Us
    • Who we are
    • Our Portfolio
  • Contact Us
  • Home
  • Pricing
  • Services
    • Web Design Services
    • eCommerce Solution
    • Website Maintenance
    • Search Engine Optimization
    • Web Hosting
    • Domain Name Registration
  • Blog
  • About Us
    • Who we are
    • Our Portfolio
  • Contact Us
SOPDAP

No products in the cart.

  • Home
  • Pricing
  • Services
    • Web Design Services
    • eCommerce Solution
    • Website Maintenance
    • Search Engine Optimization
    • Web Hosting
    • Domain Name Registration
  • Blog
  • About Us
    • Who we are
    • Our Portfolio
  • Contact Us
Blog
Home blog How to implement the Flutterwave payment gateway using PHP
blogITProgramming

How to implement the Flutterwave payment gateway using PHP

SopdapTechMarket February 22, 2023 0 Comments

What is Flutterwave Payment Gateway?

Flutterwave is a payment gateway that enables businesses and individuals to receive and make payments using different payment methods, such as credit cards, debit cards, bank transfers, and mobile money, in various countries across Africa and around the world.

Merchants can incorporate Flutterwave’s unified payment infrastructure into their websites, mobile apps, or point-of-sale systems to take payments from customers in their native currency. With Flutterwave, businesses can securely accept payments online and control all of their transactions, refunds, and settlements from a single platform.

Other payment-related services provided by Flutterwave include fraud detection and prevention, recurring payments, invoicing, and analytics. These services enable businesses to optimize their payment processes and increase sales. In order to give its users access to a wider variety of payment methods, Flutterwave also has connections with significant payment processors including Visa, Mastercard, and PayPal.

Sample code snippets for  Flutterwave payment gateway integration on your website.

<?php

// Step 1: Set up your Flutterwave API keys and base URL
$public_key = 'your_public_key';
$secret_key = 'your_secret_key';
$base_url = 'https://api.flutterwave.com/v3';

// Step 2: Create the payment payload
$payload = array(
    'tx_ref' => uniqid('tx_ref_', true),
    'amount' => 100,
    'currency' => 'NGN',
    'redirect_url' => 'https://your-redirect-url.com/complete-payment',
    'payment_options' => 'card',
    'meta' => array(
        'user_id' => 23,
        'product_id' => 46,
    ),
    'customer' => array(
        'email' => '[email protected]',
        'phone_number' => '08160413494',
        'name' => 'Sopdap Tech',
    ),
    'customizations' => array(
        'title' => 'My Company Name',
        'description' => 'Payment for item purchased on my company website',
        'logo' => 'https://your-company-logo-url.com/logo.png',
    ),
);

// Step 3: Create the payment URL
$payment_url = $base_url.'/payments';

// Step 4: Set the headers
$headers = array(
    'Authorization: Bearer '.$secret_key,
    'Content-Type: application/json',
);

// Step 5: Send the request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $payment_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);

// Step 6: Handle the response
$response_data = json_decode($response, true);
if ($response_data['status'] == 'success') {
    // Payment was successful, redirect the user to the payment page
    header('Location: '.$response_data['data']['link']);
} else {
    // Payment failed, display an error message
    echo 'Payment failed: '.$response_data['message'];
}
//if you need assistance reach me via the above sample phone number
?>

Clone it from here: https://github.com/SopeDapo/flutterwavePaymentGateway/blob/main/payment.php

In this example code, you need to replace YOUR_PUBLIC_KEY and YOUR_SECRET_KEY with your own public and secret keys provided by Flutterwave. You also need to set the amount, currency, and txref values according to your requirements.

The code sends a request to the Flutterwave API with the payment details, generates an authorization header using your secret key, and redirects the user to the payment page URL returned by the API. If an error occurs, it prints the error message.

Get the complete source code here: https://github.com/SopeDapo/flutterwavePaymentGateway

Reference: https://developer.flutterwave.com/docs/collecting-payments/overview

Thank you for ready drop your questions via comment.

 

 

 

 

Flutterwave Flutterwave Payment Gateway integration payment gateway
0
13 Views
Aboutsope dapo
4 Ways To Block Someone on Instagram -A Complete GuidePrev4 Ways To Block Someone on Instagram -A Complete GuideJune 27, 2020

Related Posts

blogProgramming

How to Build Career Paths for Programmers

I recently interviewed a Business Analyst position with the CIO of a large...

David Enyi June 26, 2020
blog

Different Types of Advertisement Techniques

Advertising is essential for all types of businesses, be it a small one or a big...

David Enyi June 27, 2020

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts
  • How to implement the Flutterwave payment gateway using PHP
  • 4 Ways To Block Someone on Instagram -A Complete Guide
  • Sites To Buy Facebook Likes in 2020
  • Top 10 Social Media Tools for Posting and Scheduling to Save your Time
  • What is Brand Recognition and How to Build It?
Categories
  • blog 19
  • Digital Marketing 5
  • E-commerce 5
  • Hosting & Domain Name 1
  • IT 3
  • Mail Order Bride Stories 1
  • mail order brides pricing 1
  • NEWS 3
  • Others 1
  • Programming 2
  • SEO 2
  • SMM 7
  • Software Development 1
  • Tech Tools 3
  • Website Design 3

SOPDAP

Sopdap Technologies have much planned for the future, working with great clients and continued software development. If you'd like to join our team, then we'd also love to hear from you
Services
Website Design & Dev.
eCommerce Design
Search Engine Optimization
Digital Marketing
Branding & Creative
App Development
Web Hosting & Domain Name Reg.
Contacts
Address: Shop A1, NASPOLY Consultant Mini Market Ombi 1, Lafia, Nasarawa State, Nigeria.
Website: sopdap.com.ng
Email: [email protected]
Phone: +(234)9050327833
Mobile: +(234)8160413494
Newsletter

Terms of use | Privacy Policy

Copyright © 2019 by SOPDAP Technologies. All Rights Reserved.