'retrieve account object in stripe and respond with bank_account or card
When calling retrieveExternalAccount from the API I'd like a response of whether or not the stripe connected account is a card or bank_account and then list the last 4 digits of account or card accordingly.
https://stripe.com/docs/api/external_account_cards/retrieve
require_once 'stripe-php-master/init.php';
//$stripe = new \Stripe\StripeClient($STRIPE_API_KEY);
$stripe = new \Stripe\StripeClient(
$STRIPE_API_KEY
);
$link = $stripe->accounts->retrieve(
$STRIPE_DEST,
[]
);
$linkaccount = $stripe->accounts->retrieveExternalAccount(
$STRIPE_DEST,
$linkaccount->id,
[]
);
if ($link->transfers_enabled == FALSE){
echo '<script>top.location.href = "https://www.website.net/oa-drive.php"</script>';
exit();
}
if ($linkaccount->object == "bank_account"){
$accounttype = 'account ending in '.$linkaccount->last4.'';
} else {
$accounttype .= 'card ending in '.$linkaccount->last4.'';
}
Solution 1:[1]
Since you didn't ask what your problem is, I can assume from the code that the problem is the empty response from the retrieveExternalAccount method.
You should pass to this metod the ID of the account to which the external account belongs and the ID of the external account to retrieve.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | seeker |
