POST | /sales/member/{MemberId}/payment/profile | Add Payment Profile for a Member |
---|
import Foundation
import ServiceStack
// @ApiResponse(Description="", ResponseType=typeof(AddPaymentProfileResponse), StatusCode=200)
public class AddPaymentAccount : AddPaymentProfileRequest, IRestrictedApiRequest
{
/**
* Api Authentication Key
*/
// @ApiMember(Description="Api Authentication Key", IsRequired=true, ParameterType="query")
public var apiKey:String
/**
* Id of the store for the user
*/
// @ApiMember(Description="Id of the store for the user", IsRequired=true, ParameterType="query")
public var storeId:Int?
/**
* Member Id of the user to update their Payment Profile
*/
// @ApiMember(Description="Member Id of the user to update their Payment Profile", IsRequired=true, ParameterType="path")
public var memberId:Int
/**
* The AcctToken provided by creating a Payment Profile with the Vault Api
*/
// @ApiMember(Description="The AcctToken provided by creating a Payment Profile with the Vault Api", IsRequired=true)
public var acctToken:String
/**
* Last 4 digits of the Payment Profile
*/
// @ApiMember(Description="Last 4 digits of the Payment Profile")
public var last4:String
/**
* 2 digit expiration month **Required for Credit Card**
*/
// @ApiMember(Description="2 digit expiration month \n**Required for Credit Card**")
public var expMonth:Int?
/**
* 2 digit expiration year **Required for Credit Card**
*/
// @ApiMember(Description="2 digit expiration year \n**Required for Credit Card**")
public var expYear:Int?
/**
* The Account Type of the Payment Profile **Required when adding Gift Card**<details><summary>Common Values</summary><table> <thead> <tr><th>Text</th><th>Numerical</th><th>Account Type</th></tr> </thead> <tbody> <tr><td>VISA</td><td>1</td><td>Visa</td></tr> <tr><td>MC</td><td>2</td><td>MasterCard</td></tr> <tr><td>Disc</td><td>3</td><td>Discover</td></tr> <tr><td>Amex</td><td>4</td><td>American Express</td></tr> <tr><td>PC</td><td>11</td><td>Personal Checking</td></tr> <tr><td>PS</td><td>12</td><td>Personal Savings</td></tr> <tr><td>BC</td><td>13</td><td>Business Checking</td></tr> <tr><td>Factor4</td><td>42</td><td>Factor4 Gift Card</td></tr> </tbody></table><p>You may use the Text or the Numerical value.</p></details>
*/
// @ApiMember(Description="\r\nThe Account Type of the Payment Profile \r\n**Required when adding Gift Card**\r\n\r\n<details>\r\n<summary>Common Values</summary>\r\n<table>\r\n <thead>\r\n <tr><th>Text</th><th>Numerical</th><th>Account Type</th></tr>\r\n </thead>\r\n <tbody>\r\n <tr><td>VISA</td><td>1</td><td>Visa</td></tr>\r\n <tr><td>MC</td><td>2</td><td>MasterCard</td></tr>\r\n <tr><td>Disc</td><td>3</td><td>Discover</td></tr>\r\n <tr><td>Amex</td><td>4</td><td>American Express</td></tr>\r\n <tr><td>PC</td><td>11</td><td>Personal Checking</td></tr>\r\n <tr><td>PS</td><td>12</td><td>Personal Savings</td></tr>\r\n <tr><td>BC</td><td>13</td><td>Business Checking</td></tr>\r\n <tr><td>Factor4</td><td>42</td><td>Factor4 Gift Card</td></tr>\r\n </tbody>\r\n</table>\r\n<p>You may use the Text or the Numerical value.</p>\r\n</details>")
public var acctType:AcctType?
/**
* Bank Routing Number **Required for Bank Accounts**
*/
// @ApiMember(Description="Bank Routing Number \n**Required for Bank Accounts**")
public var bnkRoute:Int?
/**
* Set to `true` to not set the user's Payment Type Preference when adding an on-file profile
*/
// @ApiMember(Description="Set to `true` to not set the user's Payment Type Preference when adding an on-file profile")
public var doNotUpdatePaymentTypePreference:Bool
/**
* Whether the Payment Profile is Temporary (One time transactions and Gift Cards are IsTemp = `true`)
*/
// @ApiMember(Description="Whether the Payment Profile is Temporary (One time transactions and Gift Cards are IsTemp = `true`)")
public var isTemp:Bool
public var restrictedId:Int?
public var restrictedResourceType:RestrictedResourceType
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case apiKey
case storeId
case memberId
case acctToken
case last4
case expMonth
case expYear
case acctType
case bnkRoute
case doNotUpdatePaymentTypePreference
case isTemp
case restrictedId
case restrictedResourceType
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
apiKey = try container.decodeIfPresent(String.self, forKey: .apiKey)
storeId = try container.decodeIfPresent(Int.self, forKey: .storeId)
memberId = try container.decodeIfPresent(Int.self, forKey: .memberId)
acctToken = try container.decodeIfPresent(String.self, forKey: .acctToken)
last4 = try container.decodeIfPresent(String.self, forKey: .last4)
expMonth = try container.decodeIfPresent(Int.self, forKey: .expMonth)
expYear = try container.decodeIfPresent(Int.self, forKey: .expYear)
acctType = try container.decodeIfPresent(AcctType.self, forKey: .acctType)
bnkRoute = try container.decodeIfPresent(Int.self, forKey: .bnkRoute)
doNotUpdatePaymentTypePreference = try container.decodeIfPresent(Bool.self, forKey: .doNotUpdatePaymentTypePreference)
isTemp = try container.decodeIfPresent(Bool.self, forKey: .isTemp)
restrictedId = try container.decodeIfPresent(Int.self, forKey: .restrictedId)
restrictedResourceType = try container.decodeIfPresent(RestrictedResourceType.self, forKey: .restrictedResourceType)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if apiKey != nil { try container.encode(apiKey, forKey: .apiKey) }
if storeId != nil { try container.encode(storeId, forKey: .storeId) }
if memberId != nil { try container.encode(memberId, forKey: .memberId) }
if acctToken != nil { try container.encode(acctToken, forKey: .acctToken) }
if last4 != nil { try container.encode(last4, forKey: .last4) }
if expMonth != nil { try container.encode(expMonth, forKey: .expMonth) }
if expYear != nil { try container.encode(expYear, forKey: .expYear) }
if acctType != nil { try container.encode(acctType, forKey: .acctType) }
if bnkRoute != nil { try container.encode(bnkRoute, forKey: .bnkRoute) }
if doNotUpdatePaymentTypePreference != nil { try container.encode(doNotUpdatePaymentTypePreference, forKey: .doNotUpdatePaymentTypePreference) }
if isTemp != nil { try container.encode(isTemp, forKey: .isTemp) }
if restrictedId != nil { try container.encode(restrictedId, forKey: .restrictedId) }
if restrictedResourceType != nil { try container.encode(restrictedResourceType, forKey: .restrictedResourceType) }
}
}
public class AddPaymentProfileRequest : ApiDtoBase
{
public var userId:Int
public var acctToken:String
public var last4:String
public var expMonth:Int?
public var expYear:Int?
public var acctType:AcctType?
public var bnkRoute:Int?
public var firstName:String
public var middleName:String
public var lastName:String
public var address1:String
public var address2:String
public var city:String
public var state:String
public var postalCode:String
public var countryCode:String
public var urbanization:String
public var doNotUpdatePaymentTypePreference:Bool
public var isTemp:Bool
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case userId
case acctToken
case last4
case expMonth
case expYear
case acctType
case bnkRoute
case firstName
case middleName
case lastName
case address1
case address2
case city
case state
case postalCode
case countryCode
case urbanization
case doNotUpdatePaymentTypePreference
case isTemp
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
userId = try container.decodeIfPresent(Int.self, forKey: .userId)
acctToken = try container.decodeIfPresent(String.self, forKey: .acctToken)
last4 = try container.decodeIfPresent(String.self, forKey: .last4)
expMonth = try container.decodeIfPresent(Int.self, forKey: .expMonth)
expYear = try container.decodeIfPresent(Int.self, forKey: .expYear)
acctType = try container.decodeIfPresent(AcctType.self, forKey: .acctType)
bnkRoute = try container.decodeIfPresent(Int.self, forKey: .bnkRoute)
firstName = try container.decodeIfPresent(String.self, forKey: .firstName)
middleName = try container.decodeIfPresent(String.self, forKey: .middleName)
lastName = try container.decodeIfPresent(String.self, forKey: .lastName)
address1 = try container.decodeIfPresent(String.self, forKey: .address1)
address2 = try container.decodeIfPresent(String.self, forKey: .address2)
city = try container.decodeIfPresent(String.self, forKey: .city)
state = try container.decodeIfPresent(String.self, forKey: .state)
postalCode = try container.decodeIfPresent(String.self, forKey: .postalCode)
countryCode = try container.decodeIfPresent(String.self, forKey: .countryCode)
urbanization = try container.decodeIfPresent(String.self, forKey: .urbanization)
doNotUpdatePaymentTypePreference = try container.decodeIfPresent(Bool.self, forKey: .doNotUpdatePaymentTypePreference)
isTemp = try container.decodeIfPresent(Bool.self, forKey: .isTemp)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if userId != nil { try container.encode(userId, forKey: .userId) }
if acctToken != nil { try container.encode(acctToken, forKey: .acctToken) }
if last4 != nil { try container.encode(last4, forKey: .last4) }
if expMonth != nil { try container.encode(expMonth, forKey: .expMonth) }
if expYear != nil { try container.encode(expYear, forKey: .expYear) }
if acctType != nil { try container.encode(acctType, forKey: .acctType) }
if bnkRoute != nil { try container.encode(bnkRoute, forKey: .bnkRoute) }
if firstName != nil { try container.encode(firstName, forKey: .firstName) }
if middleName != nil { try container.encode(middleName, forKey: .middleName) }
if lastName != nil { try container.encode(lastName, forKey: .lastName) }
if address1 != nil { try container.encode(address1, forKey: .address1) }
if address2 != nil { try container.encode(address2, forKey: .address2) }
if city != nil { try container.encode(city, forKey: .city) }
if state != nil { try container.encode(state, forKey: .state) }
if postalCode != nil { try container.encode(postalCode, forKey: .postalCode) }
if countryCode != nil { try container.encode(countryCode, forKey: .countryCode) }
if urbanization != nil { try container.encode(urbanization, forKey: .urbanization) }
if doNotUpdatePaymentTypePreference != nil { try container.encode(doNotUpdatePaymentTypePreference, forKey: .doNotUpdatePaymentTypePreference) }
if isTemp != nil { try container.encode(isTemp, forKey: .isTemp) }
}
}
public class ApiDtoBase : Codable
{
public var apiKey:String
public var storeId:Int?
public var chainId:Int?
required public init(){}
}
// @DataContract
public enum AcctType : Int, Codable
{
case Uninitialized = 0
case Visa = 1
case MC = 2
case Disc = 3
case Amex = 4
case Diners = 5
case JCB = 6
case enRoute = 7
case PayPal = 8
case BillMe = 9
case PC = 11
case PS = 12
case BC = 13
case BS = 14
case Becs = 15
case Bacs = 16
case Maestro = 20
case Solo = 21
case VisaElectron = 22
case CIBC = 23
case RoyalBankCa = 24
case TDCaTrust = 25
case Scotia = 26
case BMO = 27
case HSBCCa = 28
case UnionPay = 29
case InterPayment = 30
case Laser = 31
case UnknownCredit = 40
case TransArmor = 41
case Factor4 = 42
case XPass = 43
case ConnectedAccount = 44
case UnknownBank = 45
case Error = -1
}
public enum RestrictedResourceType : String, Codable
{
case Store
case Chain
case User
case Undefined
}
public class AddPaymentProfileResponse : Codable
{
public var success:String
public var message:String
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /sales/member/{MemberId}/payment/profile HTTP/1.1
Host: clubready.com
Accept: application/json
Content-Type: application/json
Content-Length: length
{"ApiKey":"String","StoreId":0,"MemberId":0,"AcctToken":"String","AuthToken":"String","Last4":"String","ExpMonth":0,"ExpYear":0,"AcctType":"Uninitialized","CardType":0,"BnkRoute":0,"DoNotUpdatePaymentTypePreference":false,"IsTemp":false,"RestrictedId":0,"RestrictedResourceType":"Chain","UserId":0,"FirstName":"String","MiddleName":"String","LastName":"String","Address1":"String","Address2":"String","City":"String","State":"String","PostalCode":"String","CountryCode":"String","Urbanization":"String","ChainId":0}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"Success":"String","Message":"String"}