Irio / mymoip

MoIP transactions in a gem to call your own.
MIT License
31 stars 21 forks source link

CreditCard Payment with one or more installments #45

Closed JoseAurelianoJR closed 6 years ago

JoseAurelianoJR commented 10 years ago

I'm receiving this error from my request:

  
[2014-05-26T00:41:48.322588 #8360] DEBUG -- : MyMoip::TransparentRequest of #Ingresso - Teste to https://desenvolvedor.moip.com.br/sandbox/ws/alpha/EnviarInstrucao/Unica had response #{"Resposta"=>{"ID"=>"201405252203414010000005107375", "Status"=>"Falha", "Erro"=>{"__content__"=>"O Valor Máximo de Parcelas não foi corretamente especificado (é obrigatório e deve ser maior do que zero)", "Codigo"=>"123"}}}}, @response=#, @headers={"date"=>["Mon, 26 May 2014 01:03:40 GMT"], "server"=>["Apache"], "content-length"=>["331"], "vary"=>["Accept-Encoding"], "connection"=>["close"], "content-type"=>["text/xml;charset=UTF-8"]}>

in my controller have this code:


installments = [
      { min: 1, max:  1, forward_taxes: false },
      { min: 2, max: 12, forward_taxes: true,  fee: 1.99 } # 1.99 fee = 1.99% per month
    ]


    instruction = MyMoip::Instruction.new(
      id:             order.id,
      payment_reason: "Ingresso - #{@event.name}",
      values:         [order.price.to_f],
      payer:          payer,
      installments:   installments
    )

    transparent_request = MyMoip::TransparentRequest.new("Ingresso - #{@event.name}")
    transparent_request.api_call(instruction)

    credit_card_payment = MyMoip::CreditCardPayment.new(credit_card, installments: order.credit_card_information["purchase_installments"].to_i)
    payment_request     = MyMoip::PaymentRequest.new("Ingresso - #{@event.name}")
    payment_request.api_call(credit_card_payment, token: transparent_request.token)

in my webrick console appears:


MyMoip::TransparentRequest of #Ingresso - Teste with {:body=>"Ingresso - Teste220.006e1508ab89edd4c359ba88f8a5dfbfe142bae74911212true1.99Jose Aurelianojunior@bluevox.com.brab1c4733798aa17f64ca7a1835eb2581e820d88fdfgdfgdfgdfg345dfgdfgdfgsÁgua BrancaALBRA34534-544(45)3453-4545", :http_method=>:post, :requires_auth=>true, :path=>"/ws/alpha/EnviarInstrucao/Unica"}

suggestions ?

diegoqlima commented 10 years ago

The error occurs because you're passing equal parameters at min/max installments. The fix is:

installments = [
      { min: 2, max: 12, forward_taxes: true,  fee: 1.99 } # 1.99 fee = 1.99% per month
    ]