2016-12-27 98 views
1

我正在使用Stripe接收來自多個用戶的貢獻的API。所以我想爲我們的客戶生成聲明,以便他們可以看到確切金額,扣費,交易計數等等。獲取條帶餘額中的零費用交易API響應

在查看Stripe API後,我發現有兩個API(Stripe::TransferStripe::BalanceTransaction)可用於fullfil我的要求。

所以按照文檔Stripe API我打電話Stripe::Transfer API和這個API返回像下面

transfer = #<Stripe::Transfer:0x3f997455ac88 id=tr_1xxxxxxxxxxxxxx> JSON: { 
"id": "tr_1xxxxxxxxxxxxxxxxx", 
"object": "transfer", 
"amount": 9510, 
"amount_reversed": 0, 
"application_fee": null, 
"balance_transaction": "txn_123", 
"created": 1477485158, 
"currency": "usd", 
"date": 1477485158, 
"description": null, 
"destination": "acct_xxxxxxxxxxxxxx", 
"destination_payment": "py_xxxxxxxxxxx", 
"failure_code": null, 
"failure_message": null, 
"livemode": false, 
"metadata": {}, 
"method": "standard", 
"recipient": null, 
"reversals": {"object":"list","data":[],"has_more":false,"total_count":0,"url":"/v1/transfers/tr_xx/reversals"}, 
"reversed": false, 
"source_transaction": "ch_xxxxxxxxx", 
"source_type": "card", 
"statement_descriptor": null, 
"status": "paid", 
"type": "stripe_account" 
} 

我打電話條紋:: BalanceTransaction API來獲取詳細信息,尤其是傳輸的數據正確的響應

balance_transaction_id = transfer.balance_transaction 
Stripe::BalanceTransaction.retrieve(balance_transaction_id) 

獲得以下回復

#<Stripe::BalanceTransaction:0x3f9974f2f1c8 id=txn_123> JSON: { 
"id": "txn_123", 
"object": "balance_transaction", 
"amount": -9510, 
"available_on": 1478044800, 
"created": 1477485158, 
"currency": "usd", 
"description": null, 
"fee": 0, 
"fee_details": [ 

], 
"net": -9510, 
"source": "tr_xxxxxxxx", 
"sourced_transfers": {"object":"list","data": [],"has_more":false,"total_count":0,"url":"/v1/transfers? source_transaction=tr_xxxx"}, 
"status": "available", 
"type": "transfer" 
} 

我設置申請費(2%)和條紋儀表板,但在上述響應我得到fee這顯示正確的是0

因此,誰能幫助/建議我我如何能得到這個響應feetotal_count

在此先感謝您的任何幫助和建議。

+0

任何人都可以幫我完成我的要求嗎? –

回答

0

你不想看看這裏的轉賬和餘額交易來獲得費用。這是目標支付賬戶之間的自動轉賬,因此不會有任何費用掛鉤。

您需要檢索source_transaction中的原始費用,然後查看此費用自己的balance_transactionapplication_fee對象。

你甚至可以使用擴展功能來做到這一點的一個API調用: https://stripe.com/docs/api#expanding_objects

關於總數你想爲這個用戶的交易數,我懷疑,那麼你需要看看這個時候上市此帳戶和所有將以下可選參數添加到請求:

:include => ['total_count'] 

,如果你不上的目的地收費頂部創建手動轉移到連接帳戶雖然這隻會工作。