如何获取条纹中CONNECTED ACCOUNT支付对象的费用ID列表

时间:2019-02-28 21:58:21

标签: stripe-payments

我存储每个费用的ID并与购买相关联。 我已经在我的应用程序中关联了帐户。我想向他们展示每笔支出的购买明细。为此,我需要一种获取每次付款的charge_id列表的方法。

1 个答案:

答案 0 :(得分:0)

我收到了Stripe的官方回复,在一个查询中无法做到,但是有一种方法。

  

1)创建费用ch_xxxx和相关交易(txn_xxxxxx)   在平台帐户上

     

平台收到费用后,平台帐户将创建一个   转移到关联的帐户(tr_xxxxxx)和转移对象   也在平台帐户上

     

2)当关联帐户收到转帐时,付款对象   将创建(py_xxxxxx)和相关交易(txn_xxxxx)   连接的帐户,这些付款交易将被分组   并以“ po_xxxxxx”支付

     

因此在平台帐户和关联帐户之间,从关联   帐户付款进行收费,总体流程如下:

     

付款(po_xxxx)->交易(txn_xxxx)->付款(py_xxxx)->   转帐(tr_xxxx)->收费(ch_xxxxx)

    public static void ListTransactionsForPayout(String payout) throws StripeException {

//1. Get a list of transactions for payout in Connected account 
 Map<String, Object> balancetransactionParams = new HashMap<String, Object>();
 balancetransactionParams.put("limit", 20);
 balancetransactionParams.put("payout", "po_1Dy8ZfKxxxxxx"); 

 List<String> expandList = new LinkedList<String>();
 expandList.add("data.source");
 balancetransactionParams.put("expand", expandList);


 RequestOptions requestOptions = RequestOptions.builder()
            .setStripeAccount("acct_connected_account")
            .build();

 BalanceTransactionCollection transactions = BalanceTransaction.list(balancetransactionParams, requestOptions);

 for (BalanceTransaction txn : transactions.autoPagingIterable()) {
 if (txn.getType().equals("payment")) {
 Charge charge = (Charge) txn.getSourceObject();

// 2. Get transfers from payment and get charge from transfer 
 Transfer transfer = Transfer.retrieve(charge.getSourceTransfer());
 System.out.printf("txn %s -> payment %s -> transfer %s -> charge %s\n", txn.getId(), txn.getSource(), transfer.getId(), transfer.getSourceTransaction());
            }
        }
    }
相关问题