netoxygen/proxypay 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

netoxygen/proxypay

最新稳定版本:1.9.1

Composer 安装命令:

composer require netoxygen/proxypay

包简介

ProxyPay library. Provides methods to compose SHA signatures and to check ProxyPay responses.

README 文档

README

Latest Stable Version Build Status Coverage Status

ProxyPay library

Provides methods to compose SHA signatures and to check ProxyPay responses.

Full documentation can be found here

Requirements:

  • PHP 5.5+

Installation:

The library is PSR-4 compliant and the simplest way to install it is via composer:

 composer require netoxygen/proxypay

Description

Request and Responses signature

All the communication between your server and ProxyPay is signed using HMAC SHA256.

Keys

You have been provided two keys:

  • key_in: use it to sign your requests
  • key_out: use it to check ProxyPay responses signature

Usage

Signing your requests to ProxyPay

You have to add in your request a param named sha_sign (or SHA_SIGN). The easier way to sign your requests is to use the PaymentRequest class.

use Netoxygen\ProxyPay\PaymentRequest;

/**
  * We assume that $_POST contains all your request parameters:
  * - seller
  * - amount
  * - description
  * - success_url
  * - error_url
  * - cancel_url
  *
  * All the other parameters will be filtered.
  */
$request = new PaymentRequest($_POST, 'my_key_in');

// You can loop over all your parameters in the $request
foreach ($request->get_parameters() as $key => $value) {
    echo $key . '=' . $value;
}

// You can retrieve the SHA_SIGN
$sha_sign = $request->compose_sha_sign();

Check ProxyPay responses signature

At the end of the process, you receive a signed GET callback from ProxyPay. To ensure that the request is correctly signed, just use the Paymentresponse class.

use Netoxygen\ProxyPay\PaymentResponse;

$response = new PaymentResponse($_GET, 'my_key_out');
if ($response->is_valid()) {
    // $response signature is verified, now check the transaction status
    $params         = $response->get_parameters();
    $payment_status = $params['STATUS'];
    switch($payment_status) {
        case 'SUCCESS':
            // Complete the transaction on your side
            break;
  
        case 'CANCEL':
            // The transaction has been cancelled by the user
            break;
  
        case 'ERROR':   /* FALLTHROUGH */
        default:
            // An error occured
            break;
} else {
    // Bad request: throw away
}

统计信息

  • 总下载量: 2.72k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固