PHP code example of codebuglab / noon-payment-laravel

1. Go to this page and download the library: Download codebuglab/noon-payment-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codebuglab / noon-payment-laravel example snippets


php artisan vendor:publish --provider="CodeBugLab\NoonPayment\NoonPaymentServiceProvider"

1- App/Http/Controllers/NoonPaymentController.php
2- config/noon_payment.php

php artisan vendor:publish --provider="CodeBugLab\NoonPayment\NoonPaymentServiceProvider" --tag=controller

$data =[
    "order" => [
        "reference" => "1",
        "amount" => "10",
        "currency" => "SAR",
        "name" => "Sample order name",
    ],
    "configuration" => [
        "locale" => "en"
     ]
]
$response = NoonPayment::getInstance()->initiate($data);

if ($response->resultCode == 0) {
    return redirect($response->result->checkoutData->postUrl);
}

 $response = NoonPayment::getInstance()->getOrder($orderId);

if (
    $response->result->transactions[0]->type == "SALE" &&
    $response->result->transactions[0]->status == "SUCCESS"
) {
    //success Message
}