蝾螈 / easy-coda-pay
让Coda支付易于集成
1.1.0
2019-12-10 07:25 UTC
Requires
- php: >=5.6.4
- ext-curl: *
- ext-json: *
- ext-simplexml: *
This package is not auto-updated.
Last update: 2020-09-30 07:14:53 UTC
README
PHP Coda包
安装
使用composer安装
composer require salamander/easy-coda-pay
配置
<?php $config = [ 'airtimeURL' => 'https://sandbox.codapayments.com/airtime/', // 这里是测试地址,正式环境换成`https://airtime.codapayments.com/airtime/` 'airtimeRestURL' => 'https://sandbox.codapayments.com/airtime/api/restful/v1.0/Payment', // 这里是测试地址,正式环境换成`https://airtime.codapayments.com/airtime/api/restful/v1.0/Payment` 'apikey' => '<YOUR SITE API KEY>', 'country' => '360', // 国家,如360,文档:https://online.codapayments.com/merchant/developer/references#currency_codes 'currency' => '360', // 货币,如360 'payType' => '1', // 支付方式 => for example DCB = 1 'requestType' => 'json', ]; $payUtil = new Salamander\PhpCoda\PaymentUtil($config);
使用方法
创建订单
<?php $orderRequest = [ 'orderId' => (string) round(microtime(true) * 1000), // 商户订单号 'goods' => [ [ 'name' => 'C', // goods name 'code' => '23', // Merchant-managed item code. 'price' => 12.5, // Float ], [ 'name' => 'C', 'code' => '23', 'price' => 12.5, ], ] ]; $config = []; // above configuration $payUtil = new Salamander\PhpCoda\PaymentUtil($config); $resp = $payUtil->makeOrder($orderRequest); echo $resp->txnId; $mobileJumpUrl = $payUtil->getMobileJumpUrl($resp->txnId); // 移动端页面跳转URL
商品信息
名称 | 类型 | 长度 | 描述 |
---|---|---|---|
code | 字符串 | 128 | 商家管理的商品代码。 |
name | 字符串 | 128 | 购买商品或充值名称,例如“50钻石”。如果可以购买多个游戏或服务,请包括该名称,例如“英雄荣耀 - 200金币”。 |
price | 浮点数 | N/A | 商品价格(包含任何税费)在请求消息中指定的货币。 |
type | 数字 | N/A | 默认=1 |
交易完成通知
当支付交易完成后,Codapay使用“交易完成通知URL”通知您的应用程序。请注意,默认情况下,Coda只发送成功交易的通知(不包括待处理或失败的交易)。这是一个使用HTTP/1.1 Get方法的Web应用程序URL,具有以下HTTP参数。
名称 | 类型 | 长度 | 描述 |
---|---|---|---|
TxnId | 数字 | N/A | 从Init()方法调用返回的唯一TxnId。 |
OrderId | 字符串 | 64 | 商家通过Init()方法请求消息传递的唯一交易标识符。 |
ResultCode | 数字 | N/A | 成功或错误代码。成功 = 0。错误代码可以在此处找到。 |
TotalPrice | 浮点数 | N/A | |
PaymentType | 数字 | 3 | 客户选择的支付类型 |
Checksum | 字符串 | 512 | 参阅安全部分 |
验证校验和
<?php $config = []; // above configuration $payUtil = new Salamander\PhpCoda\PaymentUtil($config); $getParams = [ 'TxnId' => '*****', 'OrderId' => '*****', 'ResultCode' => '******', 'Checksum' => '******', ]; $checkRes = $payUtil->validateChecksum($getParams); // 校验签名