iepay/iepay-sdk

Iepay PHP SDK 版本 3.x

v1.0.3 2022-06-02 01:40 UTC

This package is not auto-updated.

Last update: 2024-10-03 12:50:05 UTC


README

Iepay PHP SDK 版本 3.x API。

安装 / 安装

composer require iepay/iepay-sdk

使用方法 / 使用方法

添加环境配置 / 添加环境变量

MYPAY_ID={YOUR_IEPAY_ID}		#IEPAY账号下的MID
MYPAY_KEY={YOUR_IEPAY_API_KEY}	#IEPAY账号下的API-KEY

MYPAY_RETURN_URL={PAYMENT_SUCCESS_PAGE}			#交易成功页面地址
MYPAY_NOTIFY_URL={PAYMENT_SUCCESS_NOTIFY_URL}	#交易成功异步通知地址

添加命名空间 / 添加文件命名空间

use IEPaySDK\Payment;

支付 / 支付

$paymentType = 'IE0012';			// Payment Type see types table (支付类别,参考支付类别表)
$orderId = '20220210001';			// Your order id (随机生成的订单号)
$amount = 100;						// Cent (分)
$subject = 'test subject';			// Item subject (商品标题)
$details = 'test details';			// Item details (商品详情)
$response = Payment::make($paymentType)->payment($orderId, $amount, $subject, $details);

自定义返回链接或通知链接 / 自定义返回链接

$returnUrl = 'https://xxx.xxx.xxx/return';
$notifyUrl = 'https://xxx.xxx.xxx/notify';
$response = Payment::make($paymentType, $returnUrl, $notifyUrl)->payment($orderId, $amount, $subject, $details);

响应 / 返回值

{
    "success": true,
    "status": true,
    "error_code": 0,
    "message": "OK",
    "data": {
        "pay_type": "IE0012",
        "pay_type_str": "Alipay Web",
        "out_trade_no": "20220210001",
        "trade_no": null,
        "amount": 102,
        "status": 0,
        "status_str": "Unpay",
        "pay_url": "https://intlmapi.alipay.com/gateway.do?xxxxxxxx=xxxxxxxx&xxxxxxxx=xxxxxxxx"
    }
}
{
    "success": true,
    "status": true,
    "error_code": 0,
    "message": "OK",
    "data": {
        "pay_type": "IE0026",
        "pay_type_str": "Wechat Mini",
        "out_trade_no": "20220210001",
        "trade_no": null,
        "amount": 102,
        "status": 0,
        "status_str": "Unpay",
        "pay_param": {
            "appId": "wx123123",
            "timeStamp": 1644978320,
            "nonceStr": "cpxg8dl123123mi4oysnfx",
            "package": "prepay_id=wx123456",
            "signType": "MD5",
            "paySign": "96DB44xxxxxxxxxxx"
        },
        "pay_url": null
    }
}

查询 / 查询

$paymentType = 'IE0012';			// Payment Type see types table (支付类别,参考支付类别表)
$orderId = '20220210001';			// Your order id (需要查询的订单号)
$response = Payment::make($paymentType)->query($orderId);

响应 / 返回值

{
    "success": true,
    "status": true,
    "error_code": 0,
    "message": "OK",
    "data": {
        "pay_type": "IE0061",
        "pay_type_str": "Windcave Host Page Payment",
        "out_trade_no": "20220210005",
        "trade_no": "000001011336275001f9e4140da76641",
        "amount": 101,
        "status": 1,
        "status_str": "Paid",
        "refunded_amount": 0,
        "pay_url": "https://sec.windcave.com/pxmi3/F7F7CF323F53968E56CA0650BE713B347D965FA2CC2827399D145DE371986332500051BD83B6BCC7B8D21D53BAB554800"
    }
}
{
    "success": true,
    "status": true,
    "error_code": 0,
    "message": "OK",
    "data": {
        "pay_type": "IE0026",
        "pay_type_str": "Wechat Mini",
        "out_trade_no": "20220210001",
        "trade_no": null,
        "amount": 102,
        "status": 0,
        "status_str": "Unpay",
        "pay_param": {
            "appId": "wx123123",
            "timeStamp": 1644978320,
            "nonceStr": "cpxg8dl123123mi4oysnfx",
            "package": "prepay_id=wx123456",
            "signType": "MD5",
            "paySign": "96DB44xxxxxxxxxxx"
        },
        "pay_url": null
    }
}

退款 / 退款

$paymentType = 'IE0012';			// Payment Type see types table (支付类别,参考支付类别表)
$orderId = '20220210001';			// Your order id (需要退款的订单号)
$amount = 100;						// Cent (分)
$response = Payment::make($paymentType)->refund($orderId, $amount);

响应 / 返回值

{
    "success": true,
    "status": true,
    "error_code": 0,
    "message": "OK",
    "data": {
        "pay_type": "IE0061",
        "pay_type_str": "Windcave Host Page Payment",
        "out_trade_no": "20220210005",
        "trade_no": "000001011336275001f9e4140da76641",
        "amount": 101,
        "status": 2,
        "status_str": "Refund",
        "refunded": 10
    }
}

支付类型表 / 支付类别表