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

Failing luhn test #481

Closed
steveklabnik opened this issue Jan 14, 2014 · 5 comments
Closed

Failing luhn test #481

steveklabnik opened this issue Jan 14, 2014 · 5 comments

Comments

@steveklabnik
Copy link
Contributor

  Scenario: Tokenization fails luhn test                                                                                                                           
    When I make a POST request to /cards with the body:                                                                                                            
      """                                                                                                                                                          
        {                                                                                                                                                          
          "number": "4111111111111112",                                                                                                                            
          "expiration_month": 12,                                                                                                                                  
          "expiration_year": 2016                                                                                                                                  
        }                                                                                                                                                          
      """                                                                                                                                                          
    Then I should get a 409 status code                                                                                                                            
    And the response is valid according to the "errors" schema                                                                                                     
    And the fields on this error match:                                                                                                                            
      """                                                                                                                                                          
        {                                                                                                                                                          
          "category_code": "card-not-validated"                                                                                                                    
        }                                                                                                                                                          
      """    

Yields

Card number is not valid. Card number must consist of numbers, dashes, and spaces only. Your request id is OHM3152487e7d7111e39cac02a1fe53e539..                   
<409> expected but was                                                                                                                                             
<400>. (MiniTest::Assertion)   

Which is correct?

@matthewfl
Copy link
Contributor

I think we had a long discussion about this before when it came up with 409. IIRC, the reason was this is a user entry problem, and not a problem with the payload itself.

10.4.1 400 Bad Request

The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

10.4.10 409 Conflict

The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request. The response body SHOULD include enough

information for the user to recognize the source of the conflict. Ideally, the response entity would include enough information for the user or user agent to fix the problem; however, that might not be possible and is not required.

Conflicts are most likely to occur in response to a PUT request. For example, if versioning were being used and the entity being PUT included changes to a resource which conflict with those made by an earlier (third-party) request, the server might use the 409 response to indicate that it can't complete the request. In this case, the response entity would likely contain a list of the differences between the two versions in a format defined by the response Content-Type.

@steveklabnik
Copy link
Contributor Author

Seems good, I like 409 for this purpose.

steveklabnik added a commit that referenced this issue Jan 20, 2014
@steveklabnik
Copy link
Contributor Author

@matthewfl have we moved forward on this one at all?

@matthewfl
Copy link
Contributor

steveklabnik added a commit that referenced this issue Jan 23, 2014
@matthewfl
Copy link
Contributor

this should be fixed now

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

No branches or pull requests

2 participants