How to integration amazon pay payment gateway in codeigniter 3 - deesoft service

How to integration amazon pay payment gateway in codeigniter 3

Deepak Tailor Image
Deepak Tailor - Feb 12 2023
How to integration amazon pay payment gateway in codeigniter  3

To integrate Amazon Pay payment gateway in CodeIgniter 3, you can follow these steps:

1. Sign up for Amazon Pay Developer Account

2. Get the necessary Amazon Pay API credentials (Seller ID, MWS Access Key ID, and Secret Key).

3. Install CodeIgniter 3 and setup your project.

4. Add the Amazon Pay SDK to your project. You can either download the SDK and add it to your project or use composer to install the SDK.

5. Write the CodeIgniter controller to handle the payment process:

o Load the Amazon Pay library in your controller.
o Initialize the Amazon Pay object with your API credentials.
o Create a payment authorization, capture the payment, and handle the response.

6. Write the CodeIgniter view to display the Amazon Pay button and show the payment status. Here is an example of the code you could use in your CodeIgniter controller:

class Payment extends CI_Controller
    public function index()
        $amazon_pay = new Amazon_pay();


        $result = $amazon_pay->authorize_and_capture();

        if ($result === false) {
            $error = $amazon_pay->get_error();
        } else {
            $payment_status = $amazon_pay->get_payment_status();

        $this->load->view('payment_view', array(
            'payment_status' => $payment_status,
            'error' => $error,

Here is an example of the payment view file, payment_view.php:

    <script type="text/javascript" src=""></script>
    <?php if (isset($payment_status) && $payment_status == 'Success'): ?>
        <h1>Payment Successful</h1>
    <?php elseif (isset($error)): ?>
        <h1>Payment Failed</h1>
        <p><?php echo $error; ?></p>
    <?php else: ?>
        <div id="AmazonPayButton"></div>
        <script type="text/javascript">
            OffAmazonPayments.Button("AmazonPayButton", "<?php echo $this->config->item('seller_id'); ?>", {
                type: "Paying",
                color: "Gold",
                size: "medium",
                authorization: function() {
                    loginOptions = {scope: "profile postal_code payments:widget payments:shipping_address", popup: true};
                    amazon.Login.authorize(loginOptions, "<?php echo site_url('payment'); ?>");
                onError: function(error) {
                    // your error handling code
    <?php endif; ?>

Additionally, you may also need to handle error cases, such as when the customer cancels the payment, when the payment fails, or when there is an error in the payment process. You can handle these cases by checking the response from Amazon Pay API and displaying appropriate messages or handling the errors accordingly.

Deepak Tailor Image
Deepak Tailor

My name is Deepak tailor as a fullstack developer. I have been in the IT industry (PHP, Nodejs, flutter) for the last 5 years. For professional and customize web development & app development, you can send inquiry on our email.
You can contact him at