Git Product home page Git Product logo

Comments (4)

LiamKarlMitchell avatar LiamKarlMitchell commented on July 17, 2024

I suspect it should be this on line 10 of Mpesa.php

require 'vendor/autoload.php';

from mpesa-php-sdk.

LiamKarlMitchell avatar LiamKarlMitchell commented on July 17, 2024

Or possibly something like Carbon.php does?

$dir = __DIR__.'/..';

if (!file_exists($dir.'/autoload.php')) {
    $dir = __DIR__.'/../vendor';
}

if (!file_exists($dir.'/autoload.php')) {
    $dir = __DIR__.'/../../..';
}

if (!file_exists($dir.'/autoload.php')) {
    echo 'Autoload not found.';
    exit(1);
}

require $dir.'/autoload.php';

Or ../../autoload.php ?

I'm attempting to use this with Laravel.

from mpesa-php-sdk.

jukwahewa avatar jukwahewa commented on July 17, 2024

Lia

Or possibly something like Carbon.php does?

$dir = __DIR__.'/..';

if (!file_exists($dir.'/autoload.php')) {
    $dir = __DIR__.'/../vendor';
}

if (!file_exists($dir.'/autoload.php')) {
    $dir = __DIR__.'/../../..';
}

if (!file_exists($dir.'/autoload.php')) {
    echo 'Autoload not found.';
    exit(1);
}

require $dir.'/autoload.php';

Or ../../autoload.php ?

I'm attempting to use this with Laravel.

I gave up on this MPESA SDK as the developer(s) never replied to my opened bug request. I ended up writing custom PHP code to interact with the API. Please see MPESA API guiding docs here: https://developer.safaricom.co.ke/APIs

I wish you luck and all the best with your integration.

from mpesa-php-sdk.

LiamKarlMitchell avatar LiamKarlMitchell commented on July 17, 2024

Thanks @jukwahewa , I will probably be forced to do the same as this is not the only issue I have noticed with this code.

  1. The way env variables are loaded does not let us cache the config in Laravel.
  2. Dotenv used in the function similar to laravel, looks like it might not actually load the .env file when used in a Laravel project wrong path?
  3. self::env should be used put all the conditional checks in it.
  4. What if json_decode fails in the TransactionCallback methods?
  5. No confirmation that the response comes from their servers.
  6. No hash in response/headers to verify the message has not been tampered with.

from mpesa-php-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.