承接 shiftechafrica/pam-php-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shiftechafrica/pam-php-sdk

Composer 安装命令:

composer require shiftechafrica/pam-php-sdk

包简介

This library handles all the PAM - PayBill Account Manager API's,that are then linked to Safaricom M-pesa Daraja.

README 文档

README

Easy Money Manager


Introduction

This library handles all the PAM - PayBill Account Manager API's,that are then linked to Safaricom M-pesa Portals.

Installing

The recommended way to install pam-php-sdk is through Composer.

# Install package via composer
composer require shiftechafrica/pam-php-sdk

Next, run the Composer command to install the latest stable version of shiftechafrica/pam-php-sdk:

# Update package via composer
 composer update shiftechafrica/pam-php-sdk --lock

After installing, the package will be auto discovered, But if need you may run:

# run for auto discovery <-- If the package is not detected automatically -->
composer dump-autoload

Then run this, to get the config/pam.php for your own configurations:

# run this to get the configuration file at config/pam.php <-- read through it -->
php artisan vendor:publish --provider="PAM\PAMServiceProvider"

A config/.php file will be created, follow the example below to define your own configurations.

# set your account secret key api token
PAM_API_TOKEN=check_on_api_profile
PAM_APP_SHORTCODE_SECRET_KEY=check_on_the_app_pay_bill

Usage

Follow the steps below on how to use the pam-php-sdk:

How to use the Library

How to use the pam-php-sdk to initiate different levels of api's

        use PAM\API\B2C;
        use PAM\API\PayLoad;
        use PAM\API\RegC2bUrl;
        use PAM\API\ShortCode;
        use PAM\API\App;
        use PAM\API\STKPush;
        use PAM\API\Balance;
        
        /**
         * Fetch all your shortcodes
         */
        (new ShortCode())->index();

        /**
         * Get details of one shortcode
         * by passing the id
         */
        (new ShortCode())->show('id');

        /**
         * Fetch all your apps
         */
        (new App())->index();

        /**
         * Get details of one app
         * by passing the id
         */
        (new App())->show('id');

        /**
         * Fetch max <= 1000 latest transactions
         */
        (new PayLoad())->index();

        /**
         * Get details of one payload
         * by passing the id
         */
        (new PayLoad())->show('id');

        /**
         * get the validate shortcode
         * @return mixed
         */
        (new ShortCode())->validate([
            "ConsumerKey" => "",
            "ConsumerSecret" => "",
            "Environment" => "" // sandbox or production
        ]);

        /**
         * get the initiate stk
         * push
         * @return mixed
         */
        (new STKPush())->initiateSTK([
            "CallingCode" => "", // 254 or 255
            "Secret" => "",
            "TransactionType" => "", // CustomerPayBillOnline or CustomerBuyGoodsOnline
            "PhoneNumber" => "",
            "Amount" => "",
            "ResultUrl" => "",
            "Description" => ""
        ]);

        /**
         * register c2b url for lipa_na_mpesa
         * @return JsonResponse|mixed
         */
        (new RegC2bUrl())->registerC2BURL([
            "Secret" => ""
        ]);

        /**
         * check paybill/till balance
         * @return JsonResponse|mixed
         */
        (new Balance())->checkBalance([
            "Secret" => ""
        ]);

        /**
         * process the b2c transaction
         * here
         * @return mixed
         */
        (new B2C())->initiateB2C([
            "CallingCode" => "", // 254 or 255
            "Secret" => "",
            "TransactionType" => "", // SalaryPayment or BusinessPayment or PromotionPayment
            "PhoneNumber" => "",
            "Amount" => "",
            "ResultUrl" => "",
            "Description" => ""
        ]);

        /**
         * process the stk payment confirmation
         * here
         * @return mixed
         */
        return (new ConfirmPayment())->stkPayment([
            "Secret" => "",// secret for handling stk transactions
            "ReferenceNumber" => "", // the transaction number used for initiating the payment.
            "ResultUrl" => "", // url to receive the payment status
        ]);
        
            /**
             * process the withdrawal confirmation
             * here
             * @return mixed
             */
            return (new ConfirmPayment())->withdrawPayment([
                "Secret" => "", // secret for handling b2c transactions
                "ReferenceNumber" => "", // the transaction number used for initiating the payment.
                "ResultUrl" => "", // url to receive the payment status
            ]);

API Responses

These are the responses that one expects from each api requests.

PayBill/ShortCode Credentials Validation

   # Sample 200 response
    "data": {
        "Message": "The m-pesa app keys are valid."
    },
    "success": true

Register C2B URL (confirm/validation)

     # Sample 200 response
    "data": {
        "Message": "Validation and Confirmation URLs are already registered"
    },
    "success": true

Balance Response

     # Sample 200 response
    "data": {
        "Number": XXXXX,
        "Balance": 38,000.00
    },
    "success": true

STK-PUSH/C2B LIPA NA M-PESA

    # This the response for making a successful request
    "data": {
        "Message": "Request accepted for processing...",
        "ReferenceNumber": "2BONOSBBTN"
    }
    "success": true

    # stk successful payment done.
    "data": {
        "Success": true,
        "Description": "The service request is processed successfully.",
        "ReferenceNumber": "2BONOSBBTN",
        "PhoneNumber": "254XXXXXXXXX",
        "MpesaReceiptNumber": "PBO2ZOBY44",
        "Amount": 20000
    }

    # c2b/lipa na mpesa successful payment done.
    "data": {
        "Success": true,
        "Description": "The service request is processed successfully.",
        "ReferenceNumber": "2BONOSBBTN",
        "PhoneNumber": "254XXXXXXXXX",
        "MpesaReceiptNumber": "PBO2ZOBY44",
        "Amount": 20000,
        'TransactionType': 'Pay Bill'
        'OrgAccountBalance': 50000,
        'ShortCode':xxxxxx
    }

    # stk/c2b payment not done
    "data": {
        "Success": false,
        "Description": "Request cancelled by user",
        "ReferenceNumber": "2BOXRDNMLU",
        "PhoneNumber": "254XXXXXXXXX"
    }
    
    # This the response for checking stk push payment - similar to mpesa stk push query
    "data": {
        "Message": "Accepted for processing..."
    }
    "success": true
    
    # stk push payment confirmation callback...
    "data": {
        "Success": true or false,
        "Description": "The service request is processed successfully.",
        "ReferenceNumber": "2BONOSBBTN",
        "PhoneNumber": "254XXXXXXXXX",
        "MpesaReceiptNumber": "PBO2ZOBY44",
        "Amount": 20000
    }

B2C/BULK PAYMENT

    # This the response for making a successful request
    "data": {
        "Message": "Request accepted for processing...",
        "ReferenceNumber": "2BO6BCTLYF"
    },
    "success": true

    # b2c successful withdraw payment done.
    "data": {
       'Success' => true,
       'Description' => 'Salary payment',
       'ReferenceNumber' => '2BO6BCTLYF',
       'PhoneNumber' => '254XXXXXXXXX',
       'MpesaReceiptNumber' => 'PBO2ZOBY44',
       'Amount' => 50000,
       'B2CUtilityAccountAvailableFunds' => 70000,
       'B2CWorkingAccountAvailableFunds' => 70000,
       'B2CChargesPaidAccountAvailableFunds' => 70000
    }

    # b2c withdraw payment not done.
    "data": {
        "Success": false,
        "Description": "The initiator information is invalid.",
        "ReferenceNumber": "2BO6BCTLYF",
        "PhoneNumber": "254XXXXXXXXX"
    }   
     
    # This the response for checking withdrawal payment
    "data": {
        "Message": "Accepted for processing..."
    }
    "success": true
    
    # withdrawal payment confirmation callback...
    "data": {
       'Success' => true or false,
       'Description' => 'Salary payment',
       'ReferenceNumber' => '2BO6BCTLYF',
       'PhoneNumber' => '254XXXXXXXXX',
       'MpesaReceiptNumber' => 'PBO2ZOBY44',
       'Amount' => 50000,
       'B2CUtilityAccountAvailableFunds' => 70000,
       'B2CWorkingAccountAvailableFunds' => 70000,
       'B2CChargesPaidAccountAvailableFunds' => 70000
    }

Version Guidance

Version Status Packagist Namespace Repo
1.x Latest shiftechafrica/pam-php-sdk PAM v1.4.9

Security Vulnerabilities

For any security vulnerabilities, please email to Shiftech Africa.

License

This package is open-source, licensed under the MIT License.

shiftechafrica/pam-php-sdk 适用场景与选型建议

shiftechafrica/pam-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 683 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 11 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「B2C」 「m-pesa」 「c2b」 「paybill account manager」 「pam」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 shiftechafrica/pam-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 shiftechafrica/pam-php-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 shiftechafrica/pam-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 683
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-11