Orders-orderId-account-paymentInfo:PUT

From Hostway API Documentation
Revision as of 01:47, 9 September 2014 by Pa.dinh (Talk)
Jump to: navigation, search

PUT /orders/{orderId}/account/paymentInfo

Set the account's payment information for a given order.

Contents


Request

PUT /orders/{orderId}/account/paymentInfo

Request Parameters

orderId - string
The unique order Id. The URI of the order is returned by the POST /orders call.
contact_type - string
Contact Type (regular, billing, administrator or technical)

URI Parameters

None.

Request Headers

Content-Type
Required. Set this header to application/json; charset=UTF-8
Cookie
A cookie named OwnerId to identify the client (for most browser clients, the browser will do this automatically, depending on the browser configuration). The value of the cookie would come from the response to the create order request in the Set-Cookie response header.

Request Body

The request format depends on the type of payment method that is added. The following format is required for credit cards.

{
  "paymentInfoType": "credit_card",
  "accountNumber": "4111111111111111",
  "cardHolderName": "John Smith",
  "creditCardType": "visa",
  "expirationDate": "2012-08",
  "verificationNumber": "123",
  "billingAddress": {
    "city": "Chicago",
    "countryCode": "US",
    "postalCode": "60606",
    "stateOrProvince": "IL",
    "street1": "100 N Riverside",
    "street2": ""
  } 
}

Parameters

paymentInfoType - string
The type of payment method that will be used. Allowed value(s) are:
credit_card
accountNumber - string
Credit card number. Must consist of numbers only. Required if paymentInfoType is set to credit_card.
cardHolderName - string
The owner name as it appears on the card. Required if paymentInfoType is set to credit_card.
creditCardType - string
The type of credit card - visa, mastercard, discover, amex, discover, switch, solo, delta, korean, jcb. Required if paymentInfoType is set to credit_card.
expirationDate - string
The credit card expiration date in YYYY-MM format. Should exceed the current date. Required if paymentInfoType is set to credit_card.
verificationNumber - string
The credit card security code. This is only used to validate the credit card and will not be stored. Required if paymentInfoType is set to credit_card.
billingAddress - dictionary
Contains the credit card's billing address. Required if paymentInfoType is set to credit_card.


Response

Status Code

Status Code Error Message Description
204 No Content - The operation was successfully completed.
400 Bad Request POST data error A required attribute for the payment info type is missing.
paymentInfoType can only be credit_card.
Invalid date format Wrong expirationDate format
Validation Error
... Code: cc_auth_failed, invalid number or type creditCardType can be only one of visa, mastercard, amex, discover.
cc number with wrong length
cc number does not comply with visa rules
expirationDate set in past
...: Input strings must be a multiple of 16 in length hyphens or spaces in cc number are not allowed
401 Unauthorized - No owner Id specified or the specified owner is not authorized to add payment info.
404 Not Found Resource not found The specified order does not exist.
502 Bad Gateway - An account has not been added to the given order.

Response Body

None.


Example

Success

Request

PUT /orders/{orderId}/account/paymentInfo
Cookie: OwnerId={owner_id}; Path=/

{
  "paymentInfoType": "credit_card",
  "creditCardType": "visa",
  "accountNumber": "4111111111111111",
  "cardHolderName":
  "John Jello",
  "expirationDate":
  "2015-06",
  "verificationNumber": "505",
  "billingAddress": {
    "street1": "100 n riverside",
    "street2": "ste 800",
    "city": "Chicago",
    "stateOrProvince": "IL",
    "postalCode": "60606",
    "countryCode": "US"
  }
}

Response

204 No Content

Invalid payment info type

Request

PUT /orders/{orderId}/account/paymentInfo
Cookie: OwnerId={owner_id}; Path=/

{
  "paymentInfoType": "direct_debit",
  "creditCardType": "visa",
  "accountNumber": "4111111111111111",
  "cardHolderName":
  "John Jello",
  "expirationDate":
  "2015-06",
  "verificationNumber": "505",
  "billingAddress": {
    "street1": "100 n riverside",
    "street2": "ste 800",
    "city": "Chicago",
    "stateOrProvince": "IL",
    "postalCode": "60606",
    "countryCode": "US"
  }
}

Response

400 Bad Request
Content-Type : application/json; charset=UTF-8

{
  "badRequest": {
    "guid": "7ca8b2cc-88d5-4e5b-aab8-e4015a5b3ad8",
    "message": "POST data error",
    "code": 400,
    "details": {
      "paymentInfoType": "\"direct_debit\" is not one of credit_card, vz_payment"
    }
  }
}

Missing attribute for paymentInfoType credit_card

Request

PUT /orders/{orderId}/account/paymentInfo
Cookie: OwnerId={owner_id}; Path=/

{
  "paymentInfoType": "credit_card",
  "accountNumber": "4111111111111111",
  "cardHolderName": "John Smith",
  "creditCardType": "visa",
  "expirationDate": "2012-08",
  "billingAddress": {
    "city": "Chicago",
    "countryCode": "US",
    "postalCode": "60606",
    "stateOrProvince": "IL",
    "street1": "100 N Riverside",
    "street2": ""
  }
}

Response

400 Bad Request
Content-Type : application/json; charset=UTF-8

{
  "badRequest": {
    "guid": "2829e9e2-04e1-4fe2-8e05-be738b4c467c",
    "message": "POST data error",
    "code": 400,
    "details": {
      "verificationNumber": "Required"
    }
  }
}

Credit card number with hyphens

Request

PUT /orders/{orderId}/account/paymentInfo
Cookie: OwnerId={owner_id}; Path=/

{
  "paymentInfoType": "credit_card",
  "accountNumber": "4111-1111-1111-1111",
  "cardHolderName": "John Smith",
  "creditCardType": "visa",
  "expirationDate": "2012-08",
  "billingAddress": {
    "city": "Chicago",
    "countryCode": "US",
    "postalCode": "60606",
    "stateOrProvince": "IL",
    "street1": "100 N Riverside",
    "street2": ""
  }
}

Response

400 Bad Request
Content-Type : application/json; charset=UTF-8

{
  "badRequest": {
    "guid": "f5ed5738-086d-4751-8ad5-0dfead39ea3a",
    "message": "<class 'order_builder.bl.validation.ValidationError.ValidationError'>: Code: cc_auth_failed,  
traceBack:   File \"/var/lib/python-support/python2.5/hwm/encryption/encryptDecrypt.py\", line 106, in decrypt\n    
dtext = self.encryptor.decrypt(cc)\n   File \"build/bdist.linux-x86_64/egg/Crypto/Cipher/blockalgo.py\", line 295, in decrypt\n    
return self._cipher.decrypt(ciphertext)\nValueError'>: Input strings must be a multiple of 16 in length\n",
    "code": 400,
    "details": ""
  }
}

Credit card number with wrong length

Request

PUT /orders/{orderId}/account/paymentInfo
Cookie: OwnerId={owner_id}; Path=/

{
  "paymentInfoType": "credit_card",
  "accountNumber": "411111111111111122",
  "cardHolderName": "John Smith",
  "creditCardType": "visa",
  "expirationDate": "2012-08",
  "billingAddress": {
    "city": "Chicago",
    "countryCode": "US",
    "postalCode": "60606",
    "stateOrProvince": "IL",
    "street1": "100 N Riverside",
    "street2": ""
  }
}

Response

400 Bad Request
Content-Type : application/json; charset=UTF-8

{
  "badRequest": {
    "guid": "ced1a8a8-21dc-4a10-9d36-5a201214a5ce",
    "message": "<class 'order_builder.bl.validation.ValidationError.ValidationError'>: Code: cc_auth_failed, invalid number or type",
    "code": 400,
    "details": ""
  }
}

Invalid date format

Request

PUT /orders/{orderId}/account/paymentInfo
Cookie: OwnerId={owner_id}; Path=/

{
  "paymentInfoType": "credit_card",
  "accountNumber": "4111111111111111",
  "cardHolderName": "John Smith",
  "creditCardType": "visa",
  "expirationDate": "15-06",
  "billingAddress": {
    "city": "Chicago",
    "countryCode": "US",
    "postalCode": "60606",
    "stateOrProvince": "IL",
    "street1": "100 N Riverside",
    "street2": ""
  }
}

Response

400 Bad Request
Content-Type : application/json; charset=UTF-8

{
  "badRequest": {
    "guid": "30e66cfe-649c-4b1c-bfaf-c65caf47b99d",
    "message": "Invalid date format",
    "code": 400,
    "details": ""
  }
}

Unset account for the order

Request

PUT /orders/{orderId}/account/paymentInfo
Cookie: OwnerId={owner_id}; Path=/

{
  "paymentInfoType": "credit_card",
  "creditCardType": "visa",
  "accountNumber": "4111111111111111",
  "cardHolderName":
  "John Jello",
  "expirationDate":
  "2015-06",
  "verificationNumber": "505",
  "billingAddress": {
    "street1": "100 n riverside",
    "street2": "ste 800",
    "city": "Chicago",
    "stateOrProvince": "IL",
    "postalCode": "60606",
    "countryCode": "US"
  }
}

Response

502 Bad Gateway
Content-Type : application/json; charset=UTF-8

{
  "computeFault": {
    "guid": "a4f6b310-11d9-4263-8482-81bccf261df7",
    "timestamp": "2014-09-08 08:34:20",
    "code": 502,
    "errorRefId":
    "a4f6b310-11d9-4263-8482-81bccf261df7"
  }
}

See also


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox