Rails and Iugu: Iugu :: Subscription.create

0

I'm trying to sign up for a user with my credit card details so I can bill my customers for later. Registration is done in Iugu, but the credit card details are not registered in Iugu. I'm using the calls below.

Has anyone done this kind of implementation before?

Thank you.

customer = Iugu::Customer.create(email: @usuario.email, name: @usuario.nome_cartao)

Iugu::Subscription.create(plan_identifier: 'cadastro_cartao', payable_with: "credit_card", name: @usuario.nome_cartao, number: @usuario.cartao.delete(' '), verification_value: @usuario.cvv, month: @usuario.validade[0..1], year: @usuario.validade[2..6], customer_id: customer.id)
    
asked by anonymous 12.11.2018 / 15:47

1 answer

1

Taking a look at the IUGU docs, the customer's credit card data does not belong directly to a subscription. The signature is related to a customer , this user has N payment_methods, one of which is considered the default_payment_method , (in which the subscription installments will be charged).

I recommend following the steps below:

  • Create Customer and save the ID that IUGU returns to your bank Documentation < a>

  • Create a payment_method linked to the customer created earlier, remembering to send a boolean in the set_as_default key for the payment method to be the customer default Documentation

  • Finally, create the Documentation subscription.

  • I hope I have helped! Hugs.

        
    16.11.2018 / 14:08