#AlienSoft
1 messages ยท Page 1 of 1 (latest)
Hello! Can you clarify what you're trying to do?
Hi i'm trying to retreive payment details (i/e exchange rates) once a payment is complete
earlier i was forwarded to: https://stripe.com/docs/expand/use-cases#stripe-fee-for-payment
but it keeps returning NULL
it works with test mode right?
$paymentIntent = \Stripe\PaymentIntent::retrieve([
'id' => 'pi_3N4RloCjjBoJaavH1JAVCie6',
'expand' => ['latest_charge.balance_transaction'],
]);
$feeDetails = $paymentIntent->charges->data[0]->balance_transaction->fee_details;
echo var_dump($feeDetails);
echo "Amount: " . $feeDetails->amount . "\n";
echo "Currency: " . $feeDetails->currency . "\n";
any ideas ?
Sorry got caught up in some other threads - give me a minute to checkout out that payment intent
Ah - is there a reason you're checking fee details? I should've clarified a bit more - the doc I sent over was just meant to show you how to do the expansion of latest_charge.balance_transaction. Instead of fee_details you should be checking exchange_rate (https://stripe.com/docs/api/balance_transactions/object#balance_transaction_object-exchange_rate)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ahh.. let me try quickly
so we need to pass taxID rather than paymentIntent
cos I'm still getting NULL results ๐
$stripe->balanceTransactions->retrieve(
'txn_19d4fvCjjBoJaavHUpth3h7m',
[]
);
echo "Amount: " . ($stripe->amount / 100) . "\n";
echo "Currency: " . $stripe->currency . "\n";
echo "Amount: " . ($stripe->amount / 100) . "\n";
I think that's wrong - you're not storing the balance transaction you get back
i'm trying to print it to see amount, no need to store
even if that was the case, as so, still nothing
$test = $stripe->amount;
echo "Amount: " . $test . "\n";
No, that's not how it works - you need to do somethign like this:
$bt = $stripe->balanceTransactions->retrieve(
'txn_19d4fvCjjBoJaavHUpth3h7m',
[]
);
echo "Amount: " . ($bt->amount / 100) . "\n";
echo "Currency: " . $bt->currency . "\n";
oh! the main object needs to be returned to a variable.. ok let me try
voila ๐
final question is. how do i retrieve the txn_ no in the first place. as i only have the intentID
We show how to do that in the docs I send you earlier - https://stripe.com/docs/expand/use-cases#stripe-fee-for-payment
sorry but i'm missing something.. shouldn't this be returning the txn_ ID
$paymentIntent = \Stripe\PaymentIntent::retrieve([
'id' => 'pi_3N4RloCjjBoJaavH1JAVCie6',
'expand' => ['latest_charge.balance_transaction'],
]);
echo $paymentIntent->balance_transaction;
so balance_transaction should be the txn_ ID ??
Hi there ๐ taking over, as my colleague needs to step away
Give me a few minutes to get caught up.
That function should be returning the Balance Transaction as data[0].balance_transaction. You can see in the logs that this is the case: https://dashboard.stripe.com/test/payments/pi_3N4RloCjjBoJaavH1JAVCie6
Keep in mind, the Balance Transaction will only populate after money has been moved. So that means it might be null if you are trying to retrieve it at any point before a Charge is created.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
The Balance Transaction would indeed contain a txn_abc123 type of ID
ok, thanks. just figured it out