#AlienSoft

1 messages ยท Page 1 of 1 (latest)

late hemlockBOT
last flicker
#

Hello! Can you clarify what you're trying to do?

cunning imp
#

Hi i'm trying to retreive payment details (i/e exchange rates) once a payment is complete

#

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 ?

last flicker
#

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)

cunning imp
#

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";
last flicker
#

echo "Amount: " . ($stripe->amount / 100) . "\n";
I think that's wrong - you're not storing the balance transaction you get back

cunning imp
#

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";

last flicker
#

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";
cunning imp
#

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

last flicker
late hemlockBOT
cunning imp
#

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 ??

cedar orchid
#

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.

#

The Balance Transaction would indeed contain a txn_abc123 type of ID

cunning imp
#

ok, thanks. just figured it out