intram / php-sdk
INTRAM支付网关的PHP SDK
dev-master
2022-09-22 01:09 UTC
Requires
- guzzlehttp/guzzle: ^7.0
This package is auto-updated.
Last update: 2024-09-22 05:46:50 UTC
README
这是为PHP编写的INTRAM (intram.org)库。
基于INTRAM HTTP API(beta版)构建。
通过composer安装
composer require intram/php-sdk
API配置
设置INTRAM API密钥。
$intram = new \Intram\Intram\( "5b06f06a0aad7d0163c414926b635ee9cdf41438de0f09d7", "pk_9c0410014969f276e8b3685fec7b1b2ab41fc760db29", "sk_08bd75f9468b484d8a9f24daddff4638d6513fdcf3f", "d8a9f24daddff4638d6513fdcf3f", true)
登录到您的INTRAM账户,点击开发者,然后在此级别点击API,获取API密钥,并将它们作为参数传递给控制器。通过按顺序输入以下内容初始化INTRAM PayCfa:PUBLIC_KEY
、PRIVATE_KEY
、INTRAM_SECRET
、INTRAM_MARCHAND_KEY
、MODE
。模式:使用true
表示实时模式,使用false
表示测试模式。
##配置您的部门/公司信息
设置店铺名称
(必填)
$intram->setNameStore("Suntech Store");
设置店铺Logo URL
$intram->setLogoUrlStore("https://www.suntechshop/logo.png");
设置店铺网站
$intram->setWebSiteUrlStore("https://www.suntechshop");
设置店铺电话
$intram->setPhoneStore("97000000");
设置店铺邮政地址
$intram->setPostalAdressStore("BP 35");
##创建请求支付为了允许用户在您的店铺中进行支付,您必须创建交易,然后发送支付URL或二维码供扫描。为此
添加发票项目
添加购买的不同产品(必填)
$intram->setItems([ ['name'=>"T-shirt",'qte'=>"2",'price'=>"500",'totalamount'=>"1000"], ['name'=>"trouser",'qte'=>"1",'price'=>"12500",'totalamount'=>"12500"], ]);
设置TVA金额
TVA(可选)
$intram->setTva([["name" => "VAT (18%)", "amount" => 1000],["name" => " other VAT", "amount" => 500]]);
添加自定义数据
(可选)
$intram->setCustomData([['CartID',"32393"],['PERIOD',"TABASKI"]]);
设置总金额
订单总额(必填)
$intram->setAmount(13600);
设置货币
支付货币(必填)
$intram->setCurrency("XOF");
设置描述
操作描述(必填)
$intram->setDescription("Pretty and suitable for your waterfall");
设置模板
(必填)
$intram->setTemplate("default");
设置店铺重定向URL
$intram->setRedirectionUrl("https://www.suntechshop/redirection-url");
设置店铺返回URL
$intram->setReturnUrl("https://www.suntechshop/return-url");
设置店铺取消URL
$intram->setCancelUrl("https://www.suntechshop/cancel-url");
发起支付请求
$response = json_decode($intram->setRequestPayment());
预期响应
{ +"status": "PENDING" +"transaction_id": "5f2d7a96b97d9d3fea912c11" +"receipt_url": "localhost:3000/payment/gate/5f2d7a96b97d9d3fea912c11" +"total_amount": 1000 +"message": "Transaction created successfully" +"error": false }
获取数据
$transaction_id = $response->transaction_id; $status = $response->status; $receipt_url = $response->receipt_url; $total_amount = $response->total_amount; $message = $response->message; $error = $response->error;
##获取交易状态
将交易标识符作为参数传递给函数(必填)
$intram->getTransactionStatus(5f2d7a96b97d9d3fea912c11);
预期响应
{ +"error": false +"status": "PENDING" +"transaction": { +"_status": "PENDING" +"_channels": [] +"_created_at": "2020-09-15T14:56:10.316Z" +"_id": "5f60d7a0573bc71854bf095e" +"_type": "DEBIT" +"_store": { +"name": "Sodjinnin Store" +"postal_adress": "BP 35" +"logo_url": "https://www.google.com/webhp?hl=fr&sa=X&ved=0ahUKEwi7kZ3Qpt_qAhWxC2MBHVFZDDgQPAgH" +"web_site_url": "https://www.random.org/" +"phone": "94784784" +"template": "default" } +"_reference": "SaCsEhzMFc" +"_amount": 1000 +"_country_code": "BJ" +"_qrcode": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHQAAAB0CAYAAABUmhYnAAAAAklEQVR4AewaftIAAAL9SURBVO3BQQ7jCAhFwZcvi6NyKI7KgkyWrCxZdtLdDFWv9wdrDLFGEWsUsUYRaxSxRhFrFL ▶" +"__v": 0 +"invoice": { +"custom_datas": [] +"_created_at": "2020-09-15T14:56:10.335Z" +"_id": "5f60d7a0573bc71854bf095f" +"currency": "XOF" +"items": array:1 [ 0 => { +"_id": "5f60d7a0573bc71854bf0960" +"name": "short" +"price": 500 } ] +"taxes": array:1 [ 0 => { +"_id": "5f60d7a0573bc71854bf0961" +"name": "tva" +"amount": 100 } ] +"amount": 1000 +"description": "At vero eos et accusam et justo duo dolores" +"transaction": "5f60d7a0573bc71854bf095e" +"__v": 0 } } +"message": "statut de la transaction" }
运行测试
要运行测试,只需设置API配置环境变量。某些测试需要互联网连接才能通过。
许可
MIT