Billhighway Cloud API

<back to all web services

DonationCreditCardRequest

The following routes are available for this service:
POST/donations/creditcard
import Foundation
import ServiceStack

public class DonationCreditCardRequest : DonationRequestBase, IDonationRequestWithDonorInfo
{
    /**
    * Not required if MemberInfo is present on request
    */
    // @ApiMember(Description="Not required if MemberInfo is present on request")
    public var donorInfo:DonationDonorInfo?

    /**
    * Not required if DonorInfo is present on request
    */
    // @ApiMember(Description="Not required if DonorInfo is present on request")
    public var memberInfo:DonationMemberInfo?

    /**
    * Campaign to track donation against and to define fund allocation. Use GET /campaigns to retreive valid list of campaignIDs
    */
    // @ApiMember(Description="Campaign to track donation against and to define fund allocation. Use GET /campaigns to retreive valid list of campaignIDs")
    public var campaignId:Int?

    /**
    * CardRef returned from client-side tokenization.  Also handles raw card number if your servers are PCI-DSS-compliant, and in that case this must be a valid card number for the CardType indicated.
    */
    // @ApiMember(Description="CardRef returned from client-side tokenization.  Also handles raw card number if your servers are PCI-DSS-compliant, and in that case this must be a valid card number for the CardType indicated.", IsRequired=true, Name="CardReferenceOrCardNumber")
    public var cardReferenceOrCardNumber:String?

    public var cardType:String?
    /**
    * Credit Card Validation value. If Visa, Master Card or Discover, must be 3 digits. If AmEx, must be 4 digits.
    */
    // @ApiMember(Description="Credit Card Validation value. If Visa, Master Card or Discover, must be 3 digits. If AmEx, must be 4 digits.", Name="Cvv")
    public var cvv:String?

    // @ApiMember(IsRequired=true)
    // @ApiMember(Description="Credit Card expiration month. Valid Values 1-12.", IsRequired=true, Name="ExpirationMonth")
    public var expirationMonth:Int?

    /**
    * Credit Card expiration year. Four-digit Year. Value cannot be less than current year or more than 20 years in the future. ExpMonth + ExpYear must not be in the past.
    */
    // @ApiMember(Description="Credit Card expiration year. Four-digit Year. Value cannot be less than current year or more than 20 years in the future. ExpMonth + ExpYear must not be in the past.", IsRequired=true, Name="ExpirationYear")
    public var expirationYear:Int?

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

    private enum CodingKeys : String, CodingKey {
        case donorInfo
        case memberInfo
        case campaignId
        case cardReferenceOrCardNumber
        case cardType
        case cvv
        case expirationMonth
        case expirationYear
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        donorInfo = try container.decodeIfPresent(DonationDonorInfo.self, forKey: .donorInfo)
        memberInfo = try container.decodeIfPresent(DonationMemberInfo.self, forKey: .memberInfo)
        campaignId = try container.decodeIfPresent(Int.self, forKey: .campaignId)
        cardReferenceOrCardNumber = try container.decodeIfPresent(String.self, forKey: .cardReferenceOrCardNumber)
        cardType = try container.decodeIfPresent(String.self, forKey: .cardType)
        cvv = try container.decodeIfPresent(String.self, forKey: .cvv)
        expirationMonth = try container.decodeIfPresent(Int.self, forKey: .expirationMonth)
        expirationYear = try container.decodeIfPresent(Int.self, forKey: .expirationYear)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if donorInfo != nil { try container.encode(donorInfo, forKey: .donorInfo) }
        if memberInfo != nil { try container.encode(memberInfo, forKey: .memberInfo) }
        if campaignId != nil { try container.encode(campaignId, forKey: .campaignId) }
        if cardReferenceOrCardNumber != nil { try container.encode(cardReferenceOrCardNumber, forKey: .cardReferenceOrCardNumber) }
        if cardType != nil { try container.encode(cardType, forKey: .cardType) }
        if cvv != nil { try container.encode(cvv, forKey: .cvv) }
        if expirationMonth != nil { try container.encode(expirationMonth, forKey: .expirationMonth) }
        if expirationYear != nil { try container.encode(expirationYear, forKey: .expirationYear) }
    }
}

public class DonationRequestBase : Codable
{
    /**
    * Client value for Group. String must already be configured in Billhighway system.
    */
    // @ApiMember(Description="Client value for Group. String must already be configured in Billhighway system.", IsRequired=true, Name="GroupID")
    public var groupId:String?

    /**
    * Amount of the payment. Must be an amount less than $10,000,000.00.
    */
    // @ApiMember(Description="Amount of the payment. Must be an amount less than $10,000,000.00.", IsRequired=true, Name="Amount")
    public var amount:Double?

    /**
    * The currency the payment is being made in. Three digit currency code (see ISO 4217) for a valid currency supported by Billhighway.  Defaults to USD
    */
    // @ApiMember(Description="The currency the payment is being made in. Three digit currency code (see ISO 4217) for a valid currency supported by Billhighway.  Defaults to USD", ExcludeInSchema=true, Name="CurrencyCode")
    public var currencyCode:String?

    /**
    * Notes about the donation. Maximum 70 characters.
    */
    // @ApiMember(Description="Notes about the donation. Maximum 70 characters.", Name="Memo")
    public var memo:String?

    // @ApiMember()
    public var donationRecurringInfo:DonationRecurringInfo?

    /**
    * Custom fields
    */
    // @ApiMember(Description="Custom fields", Name="MetaData")
    public var metaData:JsonObject?

    required public init(){}
}

public class DonationRecurringInfo : Codable
{
    /**
    * How often donation is collected automatically
    */
    // @ApiMember(Description="How often donation is collected automatically", IsRequired=true, Name="Frequency")
    public var frequency:String?

    /**
    * Number of recurring donation cycles.
    */
    // @ApiMember(Description="Number of recurring donation cycles.", IsRequired=true, Name="NumberOfOccurrences")
    public var numberOfOccurrences:Int?

    /**
    * Allows the submitter to set a future date for the donation
    */
    // @ApiMember(Description="Allows the submitter to set a future date for the donation", Name="FutureDonationDate")
    public var futureDonationDate:Date?

    required public init(){}
}

public class JsonObject : List<String:String>
{
    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 DonationDonorInfo : Codable
{
    /**
    * Name of donor. Maximum 100 characters. Format must be Firstname {space} Lastname.
    */
    // @ApiMember(Description="Name of donor. Maximum 100 characters. Format must be Firstname {space} Lastname.", IsRequired=true, Name="FullName")
    public var fullName:String?

    /**
    * Billing address. Maximum 100 characters.
    */
    // @ApiMember(Description="Billing address. Maximum 100 characters.", IsRequired=true, Name="Address")
    public var address:String?

    /**
    * Billing city. Maximum 100 characters.
    */
    // @ApiMember(Description="Billing city. Maximum 100 characters.", IsRequired=true, Name="City")
    public var city:String?

    /**
    * Billing state. Two characters, must match valid US state code.
    */
    // @ApiMember(Description="Billing state. Two characters, must match valid US state code.", IsRequired=true, Name="State")
    public var state:String?

    /**
    * Credit Card billing address postal code. Maximum 10 characters.
    */
    // @ApiMember(Description="Credit Card billing address postal code. Maximum 10 characters.", IsRequired=true, Name="PostalCode")
    public var postalCode:String?

    /**
    * Email address of donor. Maximum 100 characters. If provided, must be valid email format.
    */
    // @ApiMember(Description="Email address of donor. Maximum 100 characters. If provided, must be valid email format.", Name="EmailAddress")
    public var emailAddress:String?

    /**
    * Preferred phone number. Maximum 12 characters.
    */
    // @ApiMember(Description="Preferred phone number. Maximum 12 characters.", Name="Phone")
    public var phone:String?

    required public init(){}
}

public class DonationMemberInfo : Codable
{
    // @ApiMember(IsRequired=true)
    public var bhUserId:Int?

    required public init(){}
}

public class DonationCreditCardResponse : IHaveErrorField, Codable
{
    /**
    * Legacy ErrorCode
    */
    // @ApiMember(Description="Legacy ErrorCode", ExcludeInSchema=true)
    // @Ignore()
    public var errorCode:Int?

    public var errorMessage:String?
    public var isError:Bool?
    /**
    * Donation Transaction ID
    */
    // @ApiMember(Description="Donation Transaction ID")
    public var transactionId:String?

    public var cardRef:String?

    required public init(){}
}


Swift DonationCreditCardRequest DTOs

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

HTTP + CSV

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

POST /donations/creditcard HTTP/1.1 
Host: devapi.billhighway.com 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"DonorInfo":{"FullName":"String","Address":"String","City":"String","State":"String","PostalCode":"String","EmailAddress":"String","Phone":"String"},"MemberInfo":{"BhUserId":0},"CampaignId":0,"CardReferenceOrCardNumber":"String","CardType":"String","Cvv":"String","ExpirationMonth":0,"ExpirationYear":0,"GroupId":"String","Amount":0,"CurrencyCode":"String","Memo":"String","DonationRecurringInfo":{"Frequency":"String","NumberOfOccurrences":0,"FutureDonationDate":"0001-01-01T00:00:00.0000000"},"MetaData":{"String":"String"}}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"ErrorCode":0,"ErrorMessage":"String","IsError":false,"TransactionId":"String","CardRef":"String"}