Billhighway Cloud API

<back to all web services

CreateCardRef

The following routes are available for this service:
POST/api/creditcard/createcardrefCreates, records and returns a 'cardRef'Creates, records and returns a 'reference' to a credit card. This so called 'cardRef' can then be usedas an alternative value to pass to other credit card transactions such as Verfy or Sale potentially improving securityby not passing card numbers.
import Foundation
import ServiceStack

public class CreateCardRef : CreateCardRef
{
    required public init(){ super.init() }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
    }
}

public class CreateCardRefResponse : CreditCardCloudServiceResponse
{
    public var cardRef:String?
    public var cardType:CreditCardType?

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case cardRef
        case cardType
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        cardRef = try container.decodeIfPresent(String.self, forKey: .cardRef)
        cardType = try container.decodeIfPresent(CreditCardType.self, forKey: .cardType)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if cardRef != nil { try container.encode(cardRef, forKey: .cardRef) }
        if cardType != nil { try container.encode(cardType, forKey: .cardType) }
    }
}

public class CreditCardCloudServiceResponse : IHaveErrorField, Codable
{
    public var isDuplicate:Bool?
    public var isSuccessful:Bool?
    public var errorCode:String?
    public var message:String?
    public var gatewayId:Int?
    public var confirmationNumber:String?
    public var networkTransactionId:String?
    public var isError:Bool?

    required public init(){}
}

public enum CreditCardType : Int, Codable
{
    case AmericanExpress = 0
    case Discover = 1
    case MasterCard = 2
    case Visa = 3
    case DinersClub = 4
    case DinersCartBlanche = 5
    case Unknown = 6
}


Swift CreateCardRef DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /api/creditcard/createcardref HTTP/1.1 
Host: devapi.billhighway.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	UserId: 0,
	GroupId: 0,
	Location: String,
	CurrencyCode: String,
	CardType: 0,
	NameOnCard: String,
	CardNumber: String,
	ExpirationMonth: 0,
	ExpirationYear: 0,
	ValidationNum: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	CardRef: String,
	CardType: 0,
	IsDuplicate: False,
	IsSuccessful: False,
	ErrorCode: String,
	Message: String,
	GatewayId: 0,
	ConfirmationNumber: String,
	NetworkTransactionId: String,
	IsError: True
}