<?php

namespace App\Utils\API;

use GuzzleHttp\Client;

/**
 * 第三方api转账
 */
class Payment
{
    /**
     * 转账
     */
    public static function pushMoney($money,$payeeAccountName,$payeeAccountNumber,$payeeBankName)
    {
        $client = new Client(); // 创建 Guzzle 客户端

        // 请求数据
        $data = [
            "Amount" => $money,
            "CurrencyId" => 11,
            "IsTest" => false,
            "PayeeAccountName" => $payeeAccountName,
            "PayeeAccountNumber" => $payeeAccountNumber,
            "PayeeBankName" => $payeeBankName,
            "PayeeIFSCCode" => "abc123",
            "PaymentChannelId" => 34,
            "ShopInformUrl" => "https://www.google.com",
            "ShopOrderId" => "10",
            "ShopRemark" => "", // 留空时可不给此参数
            "ShopUserLongId" => "776ae472-d4fc-435c-9639-be5763138d95"
        ];

        // 发送 POST 请求
        $response = $client->post('https://example.com/api/createPaymentOrder', [
            'json' => $data, // 以 JSON 格式发送数据
        ]);

        // 获取响应体内容
        $body = $response->getBody();
        $responseData = json_decode($body, true); // 如果返回的是 JSON 格式，解析它
        return $responseData;
    }
}
