I am using ActiveMerchant gem for the stripe payment in rails and I am getting confused how to create a new customer and get the customer id for future transactions. As per Stipe documentation first we need to create Customer and then save id for future payments.
# Create a Customer:
customer = Stripe::Customer.create({
source: 'tok_mastercard',
email: '[email protected]',
})
# Charge the Customer instead of the card:
charge = Stripe::Charge.create({
amount: 1000,
currency: 'usd',
customer: customer.id,
})
# YOUR CODE: Save the customer ID and other info in a database for later.
# When it's time to charge the customer again, retrieve the customer ID.
charge = Stripe::Charge.create({
amount: 1500, # $15.00 this time
currency: 'usd',
customer: customer_id, # Previously stored, then retrieved
})
But if I am looking into the ActiveMerchant there is no method to create a customer, please anyone guide me.