gpt4 book ai didi

php - Stripe : How to retrieve transfer information from a connected account

转载 作者:行者123 更新时间:2023-12-04 15:46:05 25 4
gpt4 key购买 nike

我的主账户是英镑账户,我有一个欧元关联账户。我的主账户首先收到款项,然后一部分转入欧元。

如果客户使用欧元付款,它会按照费用和汇率进入我的英镑账户。计算佣金并将其转入欧元账户。

我可以在 EURO->GBP exchange 中看到,在 EURO 账户中我可以看到 GBP->EURO exchange。

我可以从每个账户转账过程中检索所有详细信息,除了最后一次在关联账户上兑换回欧元。

这是我目前尝试过的:

// To retrieve data from main GBP account
$charge = \Stripe\Charge::retrieve($charge_id);
$transfer = \Stripe\Transfer::retrieve($transfer_id);
$balance = \Stripe\BalanceTransaction::retrieve($charge['balance_transaction']);

// To retrieve data from EURO connected account
$transfer_eur= \Stripe\Transfer::retrieve($transfer_id,[
'account' => $eur_acc_number
]);
$balance_eur= \Stripe\BalanceTransaction::retrieve($transfer_eur['balance_transaction'],[
'account' => $eur_acc_number
]);

这是我的结果:

$charge['amount'] // shows customer EUR amount
$balance['amount'] // shows the convert customers amount in GBP

$transfer_eur['amount'] // shows the GBP amount in the connect EUR account
$balance_eur['amount'] // just show the a negative GBP value of the EUR account

我希望 $balance_eur['amount'] 显示欧元值,但它只显示负的英镑值。

我就在那里,但我无法从连接的帐户中获取欧元值。可能吗?

[编辑]

我尝试过但失败的是通过某种方式使用 payment ID - py_****

来使用 destination_payment
$balance_other = \Stripe\Charge::retrieve($charge_id,[                                                                       
'account' => $row['stripe_acc'],
'destination_payment' => $payment_id
]);

最佳答案

您基本上想要进行转账,获取它的 destination_payment 以查看到达关联帐户的付款,然后获取与之关联的 balance_transaction在连接的帐户上付款。它还将有助于使用 API 的 expanding objects为此功能。

$t = \Stripe\Transfer::create([
"amount" => 400,
"currency" => "eur",
"destination" => "acct_1EPRDuFk3qO2dNo1"
]);
$transfer_id = $t->id;
$transfer_eur= \Stripe\Transfer::retrieve([
'id' => $transfer_id,
'expand' => ['destination_payment.balance_transaction']
]);
$balance_transaction_eu = $transfer_eur->destination_payment->balance_transaction;
print_r($balance_transaction_eu);

您也可以通过在进行传输时获取相关数据来大大简化此操作:

$t = \Stripe\Transfer::create([
"amount" => 400,
"currency" => "eur",
"destination" => "acct_1EPRDuFk3qO2dNo1",
'expand' => ['destination_payment.balance_transaction']
]);
$balance_transaction_eu = $t->destination_payment->balance_transaction;
print_r($balance_transaction_eu);

关于php - Stripe : How to retrieve transfer information from a connected account,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55701906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com