Hi
I need to make a payment with the card that was attached to the customer.
how could I do that?
the goal is to have some clients with saved cards and to have possibility to charge their cards, but its not a recurrent event
as I understand this action is possible in case of storing client’s cards but how to implement that?
I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:
Additional Documentation
Cards API
Save a Card on File
Create a Card on File and a Payment
If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.
Card on file - A seller can store customer profiles in the seller’s Customer Directory and then add a card on file for the customer. Applications can later charge the card on file by setting the card ID as the source_id
value in a CreatePayment
request. In this case, the customer_id
is also required in the request.
could you describe this in more details
To make a payment with a card attached to a customer, you would use the Payments API and the Cards API.
First, you would save a card on file for a customer using the Cards API’s CreateCard endpoint. This requires a payment token, which can be generated using the Web Payments SDK or In-App Payments SDK.
Once the card is saved on file, you can use the Payments API’s CreatePayment endpoint to process a payment with the saved card. In the CreatePayment request, you would set the source_id to the card ID of the saved card and the customer_id to the ID of the customer.
Remember to always ask customers for permission before saving their card information and charging their cards.
This answer was reviewed by @Bryan-Square.