Rails and Yugu: Yugu::Subscription.create

Asked

Viewed 77 times

0

I’m trying to sign up a user with the credit card details so I can make subsequent charges to customers. Registration is done on Yugu, but credit card details are not recorded on Yugu. I am 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)

1 answer

1

Taking a look at the IUGU Csts, the customer’s credit card details do not belong directly to a subscription. The signature is related to a customer, this user, has N payment_methods, and one of them, is considered the default_payment_method, (in which subscription installments will be charged).

I recommend, follow the following steps:

  1. Create Customer and save in your bank the ID that IUGU returns to you Documentation

  2. Create a payment_method pegged to the previously created Customer, remembering to send a Boolean in the key set_as_default for the payment method to be the default for Customer Documentation

  3. Finally, create the signature Documentation

I hope I helped! Hugs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.