#cdubs44-retreive-external-account

1 messages ยท Page 1 of 1 (latest)

nocturne saddle
#

Hello ๐Ÿ‘‹
Do you have a request ID for this that I can look into?

pearl pendant
#

What is a request ID? Where can I find it?

nocturne saddle
pearl pendant
#

Thansk @nocturne saddle. Here it is req_syeNs0GrwRpjQf

#

any update @nocturne saddle?

nocturne saddle
#

Sorry juggling between a few threads
Give me a few

pearl pendant
#

no worries. Thanks!

nocturne saddle
#

Apologies for the delay here
Appreciate your patience ๐Ÿ™‚

pearl pendant
#

no worries!

nocturne saddle
pearl pendant
#

Nope. Here is what returns:
{
"cards": [
{
"account": null,
"accountId": "acct_1KopyhQsucnnMpCP"
}
]
}

nocturne saddle
#

Are you sure that card is set as an external account?

pearl pendant
#

yeah, says it right there

nocturne saddle
#

okay gotcha.
Can you share your sample code that's trying retrieving the object?

pearl pendant
#

[HttpPost("retrieveStripeAccount")]
public async Task<IActionResult> retrieveStripeAccount(AspNetUsers ap){
var trainerDb = await _stripeCustRepository.GetByUserIdAsync(ap.Id);

        var service = new AccountService();
        var acct = service.Get(trainerDb.StripeId);
        return Ok(new
            {
                Account = acct,
            }
        );
    }
#

So I pass the user object, then I find the stripeId from the userId and use that

#

Or if you want the cards one:
[HttpPost("test")]
public async Task<IActionResult> sendTest(AspNetUsers ap){
var trainerDb = await _stripeCustRepository.GetByUserIdAsync(ap.Id);

        var options = new ExternalAccountListOptions {
            Limit = 3,
        };

        var service = new ExternalAccountService();
        var cards = service.List(trainerDb.StripeId, options);
        return Ok(new
            {
                cards = cards,
            }
        );
    }
nocturne saddle
#

gotcha.
Let me take a look

#

I'm pretty sure i'm overlooking something simple here
Let me ask my colleagues

pearl pendant
#

Thank you!

nocturne saddle
pearl pendant
#

I'm not using CURL? I am using .NET?

nocturne saddle
#

Yes but can you try the curl request? This would help us confirm if the issue is with the code or the API

pearl pendant
#

Yeah, looks like the CURL request worked

#

I had to change the sk_test key to the full key and type in my password, but it did work

nocturne saddle
#

Gotcha. so it is the code.
Not sure if we have any example code for this but you're likely looking at the wrong object.

pearl pendant
#

StripeConfiguration.ApiKey = "KEY"

var service = new AccountService();
service.Get("acct_1KopyhQsucnnMpCP");

#

Thats whats in the docs for .NET and what I am using

#

I'll keep messing around and let you know if I find anything for future reference

nocturne saddle
#

Try this

var account = service.Get("acc ID");

Console.WriteLine(account.Id);
Console.WriteLine("Number of external accounts: " + account.ExternalAccounts.Data.Count);

var externalAccount = account.ExternalAccounts.Data[0];
if(externalAccount.Object == "card")
{
  Card card = (Card) account.ExternalAccounts.Data[0];
  Console.WriteLine("Card id: " + card.Id);
  Console.WriteLine("Card last4: " + card.Last4);
}
else if(externalAccount.Object == "bank_account")
{
  BankAccount bankAccount = (BankAccount) account.ExternalAccounts.Data[0];
  Console.WriteLine("BankAccount id: " + bankAccount.Id);
  Console.WriteLine("BankAccount last4: " + bankAccount.Last4);
}
else
{
  Console.WriteLine("External account with unknown type: " + externalAccount.Object);

}```
pearl pendant
#

Oh yeah that worked

#

Console:
acct_1KopyhQsucnnMpCP
Number of external accounts: 1
Card id: card_1KopzPQsucnnMpCP8HsgfGMh
Card last4: 5556

nocturne saddle
#

Perfect! ๐Ÿ™‚

pearl pendant
#

You are the freaking man Hanzo!!

nocturne saddle
#

Happy to help ๐Ÿ˜„