#juneid_90104

1 messages · Page 1 of 1 (latest)

jovial brookBOT
sonic briar
#

moving the rest of the question here

If we create a customer using a token then while charging what will we pass tokenId or sourceId.

#

What flow are you trying to build? Are you following a guide?

stoic agate
#

I am creating a donation system where first i create a token.

#

When donor adds card and amount information.

#

Then i use this token to vreate a customer and attac the card.

#

But for charge i need source id?

#

What i sthe normal flow ?

sonic briar
#

what are you using to collect the payment method information?
are you using card element or something else?

Is this a new integration?

stoic agate
#

I have created a UI to collect information and create a token using Create a card token api.

#

This is my first step.

sonic briar
#

Is this a new integration you're building? If so, I'd recommend switching to newer elements + APIs as the token API is considered legacy

stoic agate
#

Any workaround for apis only ?

#

i just want to know how things wor if we create atoken then what should be the next steps ?

jovial brookBOT
hollow carbon
#

@stoic agate catching up since my teammate needs to step away

stoic agate
#

lets say i have a token and now its time to create and charge customeR.

hollow carbon
#

As my teammate mentioned, if you're building a brand-new integration, we recommend using the PaymentIntents API and using the PaymentElement to collect payment details

stoic agate
#

For now i am dealing with creating a token using api

hollow carbon
#

If you insist on using the Tokens API, your next step after you have a token are to either create a charge using that token or attach the card to a customer

stoic agate
#

If we create a customer first by using the token.
then will it rerurn sourceid?

#

becuase whe i use the same token fro creating a charge it says not lined to customer.

#

linked*

hollow carbon
#

Once you use the token to create a customer, you can't use that token ever again. If you want to charge the customer later, you'd use their customer ID when creating the charge.

stoic agate
#

Can i share test customerid here ?

hollow carbon
#

Yep, that works too!

stoic agate
#

cus_P31fflm9uC3456

#

this is a successful charge.

#

steps i did

  1. created a customer by just using name email.
#
  1. then i created a source id by using a the token which basically first attach the card and then returns sourceid.
#
  1. Then i charge the customer using sourceid>
#

cus_P37RKUnuqVwWdw

#

this is not successful because for this

#
  1. i created a customer using token
#
  1. then simply passed the same token for charge becuase sourceid in returning null.
hollow carbon
#

For cus_P37RKUnuqVwWdw, you created a token and then passed that token when creating the customer. This added a Card object as the customer's default_source

stoic agate
#

what did i do wrong for second one ?

hollow carbon
#

Since the token was already used to attach the card to that customer, your request to create a source object using a token failed. That token was no longer valid/can't be reused

#

You didn't do anything wrong necessarily, but just handled the tokens differently

stoic agate
#

Yeah i already had this in my mind and came here to verify and you have done that beutifully.

#

Thank you very much.