Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagar.me gateway: transactions are failing due to invalid card_expiration_date format #2534

Open
vitork opened this issue Aug 3, 2017 · 2 comments · May be fixed by #3583
Open

Pagar.me gateway: transactions are failing due to invalid card_expiration_date format #2534

vitork opened this issue Aug 3, 2017 · 2 comments · May be fixed by #3583

Comments

@vitork
Copy link

vitork commented Aug 3, 2017

I'm trying to integrate a store application with the Pagar.me gateway using ActiveMerchant 1.69.0 but all transactions are failing with an error in the card_expiration_date parameter.

This is happening probably because of a change in the /transactions API. I checked the docs and found out the endpoint accepts card_expiration_date in the format MMYY (I tried with MMYYYY and also worked), rather than MM/YY.

https://docs.pagar.me/reference#criar-transacao

Steps to reproduce:

gateway = ActiveMerchant::Billing::PagarmeGateway.new(api_key: my_api_key)

cc = ActiveMerchant::Billing::CreditCard.new(
  number: "4242424242424242",
  month: 12,
  year: 2020,
  verification_value: "123",
  first_name: "Tom",
  last_name: "Jobim"
)

response = gateway.purchase(1000, cc)
=> #<ActiveMerchant::Billing::Response:0x007fcdbdb44500 @params={"errors"=>[{"parameter_name"=>"card_expiration_date", "type"=>"invalid_parameter", "message"=>"Data de expiração inválida"}], "url"=>"/transactions", "method"=>"post"}, @message="Data de expiração inválida", @success=false, @test=true, @authorization=nil, @fraud_review=nil, @error_code="processing_error", @emv_authorization=nil, @avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil}, @cvv_result={"code"=>nil, "message"=>nil}>

After I remove the slash:

response = gateway.purchase(1000, cc)
=> #<ActiveMerchant::Billing::Response:0x007fa8fe8145f8 @params={"object"=>"transaction", "status"=>"paid", "refuse_reason"=>nil, "status_reason"=>"acquirer", "acquirer_response_code"=>"00", "acquirer_name"=>"development", "acquirer_id"=>"1234", "authorization_code"=>"530022", "soft_descriptor"=>nil, "tid"=>"1790259", "nsu"=>nil, "date_created"=>"2017-08-03T21:53:44.767Z", "date_updated"=>"2017-08-03T21:53:44.961Z", "amount"=>1000, "authorized_amount"=>1000, "paid_amount"=>1000, "refunded_amount"=>0, "installments"=>1, "id"=>1790259, "cost"=>65, "card_holder_name"=>"Tom Jobim", "card_last_digits"=>"4242", "card_first_digits"=>"424242", "card_brand"=>"visa", "card_pin_mode"=>nil, "postback_url"=>nil, "payment_method"=>"credit_card", "capture_method"=>"ecommerce", "antifraud_score"=>nil, "boleto_url"=>nil, "boleto_barcode"=>nil, "boleto_expiration_date"=>nil, "referer"=>"api_key", "ip"=>"10.2.13.21", "subscription_id"=>nil, "phone"=>nil, "address"=>nil, "customer"=>nil, "billing"=>nil, "shipping"=>nil, "items"=>[], "card"=>{"object"=>"card", "id"=>"card_cj5wzaiwj00ukqb6dwxkai1iv", "date_created"=>"2017-08-03T21:53:44.756Z", "date_updated"=>"2017-08-03T21:53:45.010Z", "brand"=>"visa", "holder_name"=>"Tom Jobim", "first_digits"=>"424242", "last_digits"=>"4242", "country"=>"UNITED STATES", "fingerprint"=>"1234", "valid"=>true, "expiration_date"=>"1220"}, "split_rules"=>nil, "metadata"=>{}, "antifraud_metadata"=>{}, "reference_key"=>nil}, @message="Transação aprovada", @success=true, @test=true, @authorization=1790259, @fraud_review=nil, @error_code=nil, @emv_authorization=nil, @avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil}, @cvv_result={"code"=>nil, "message"=>nil}>
@kaiomagalhaes
Copy link

@vitork any news on this?

@bpollack
Copy link
Contributor

We'd be happy to accept a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants