mirror of
http://124.126.16.154:8888/singularity/hdk-pay.git
synced 2026-01-15 07:35:09 +08:00
100 lines
2.9 KiB
PHP
100 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* LuxPayCallbackTest.php@Pay
|
|
*
|
|
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
|
* Powered by PhpStorm
|
|
* Created on 2025/8/20
|
|
*/
|
|
|
|
use Hyperf\Codec\Json;
|
|
use Singularity\HDK\Pay\Domain\Transaction\Aggregate\TransactionRecord;
|
|
use Singularity\HDK\Pay\Domain\Transaction\Service\CallbackDomainSvc;
|
|
|
|
use function Hyperf\Support\make;
|
|
|
|
dataset('cases', [
|
|
'recharge' => [
|
|
<<<JSON
|
|
{
|
|
"order_no": "202508191929138659DTB",
|
|
"uid": "cn3321",
|
|
"pay_type": "card",
|
|
"action": "recharge",
|
|
"status": "created",
|
|
"source": "LuxDesign",
|
|
"items": [
|
|
{
|
|
"name": "Starter Pack",
|
|
"unit_price": 399,
|
|
"quantity": 1
|
|
}
|
|
],
|
|
"transactions": [
|
|
{
|
|
"pay_type": "card",
|
|
"type": "stripe.checkout",
|
|
"amount": 399,
|
|
"status": "created"
|
|
}
|
|
],
|
|
"refunds": [],
|
|
"external": [],
|
|
"external_id": "",
|
|
"created_at": "2025-08-20 10:44:46",
|
|
"occurred_at": null,
|
|
"last_refunded_at": null
|
|
}
|
|
JSON,
|
|
],
|
|
'consumption' => [
|
|
<<<JSON
|
|
{
|
|
"order_no": "202508190441101116DTB",
|
|
"uid": "cn3321",
|
|
"pay_type": "hybrid",
|
|
"action": "consumption",
|
|
"status": "created",
|
|
"source": "LuxDesign",
|
|
"items": [
|
|
{
|
|
"name": "Design - retainer",
|
|
"quantity": 1,
|
|
"unit_price": 3
|
|
}
|
|
],
|
|
"transactions": [
|
|
{
|
|
"pay_type": "card",
|
|
"type": "stripe.checkout",
|
|
"amount": 3,
|
|
"status": "created"
|
|
},
|
|
{
|
|
"pay_type": "point",
|
|
"type": "lux-point",
|
|
"amount": 3.05,
|
|
"status": "created"
|
|
}
|
|
],
|
|
"refunds": [],
|
|
"external": [],
|
|
"external_id": "",
|
|
"created_at": "2025-08-20 10:44:46",
|
|
"occurred_at": null,
|
|
"last_refunded_at": null
|
|
}
|
|
JSON,
|
|
]
|
|
]);
|
|
|
|
it(
|
|
'should parse request recharge body to TransactionRecord Entity',
|
|
function ($data) {
|
|
$data = Json::decode($data);
|
|
$entity = make(CallbackDomainSvc::class)->callback($data);
|
|
expect($entity)->toBeInstanceOf(TransactionRecord::class);
|
|
},
|
|
)->with('cases');
|