Credit card handling at the backend

We can use the Stripe API to process credit card transactions as follows:

  1. Create an object of the *stripe.CustomerParams type, which can then take the credit card token that's provided by the frontend. The credit card token is ingested using a method called SetToken().
  2. Create an object of the *stripe.Customer type, which takes the object of the stripe.CustomerParams type as input. This is done through the customer.New() function.
  3. Create an object of the *stripe.ChargeParams type, which takes information about our transaction, such as the amount, the currency, and the description of the purchase.
  4. The *stripe.ChargeParams object must also receive a field, which represents the Stripe customer ID. This is ...

Get Hands-On Full Stack Development with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.