| POST | /donations/ach |
|---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DonationRecurringInfo:
# @ApiMember(Description="How often donation is collected automatically", IsRequired=true, Name="Frequency")
frequency: Optional[str] = None
"""
How often donation is collected automatically
"""
# @ApiMember(Description="Number of recurring donation cycles.", IsRequired=true, Name="NumberOfOccurrences")
number_of_occurrences: int = 0
"""
Number of recurring donation cycles.
"""
# @ApiMember(Description="Allows the submitter to set a future date for the donation", Name="FutureDonationDate")
future_donation_date: Optional[datetime.datetime] = None
"""
Allows the submitter to set a future date for the donation
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class JsonObject(Dict[str,str]):
pass
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DonationRequestBase:
# @ApiMember(Description="Client value for Group. String must already be configured in Billhighway system.", IsRequired=true, Name="GroupID")
group_id: Optional[str] = None
"""
Client value for Group. String must already be configured in Billhighway system.
"""
# @ApiMember(Description="Amount of the payment. Must be an amount less than $10,000,000.00.", IsRequired=true, Name="Amount")
amount: Decimal = decimal.Decimal(0)
"""
Amount of the payment. Must be an amount less than $10,000,000.00.
"""
# @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")
currency_code: Optional[str] = None
"""
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="Notes about the donation. Maximum 70 characters.", Name="Memo")
memo: Optional[str] = None
"""
Notes about the donation. Maximum 70 characters.
"""
# @ApiMember()
donation_recurring_info: Optional[DonationRecurringInfo] = None
# @ApiMember(Description="Custom fields", Name="MetaData")
meta_data: Optional[JsonObject] = None
"""
Custom fields
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DonationAchResponse(IHaveErrorField):
# @ApiMember(Description="Legacy ErrorCode", ExcludeInSchema=true)
# @Ignore()
error_code: Optional[int] = None
"""
Legacy ErrorCode
"""
error_message: Optional[str] = None
is_error: Optional[bool] = None
# @ApiMember(Description="Donation Transaction ID")
transaction_id: Optional[str] = None
"""
Donation Transaction ID
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DonationDonorInfo:
# @ApiMember(Description="Name of donor. Maximum 100 characters. Format must be Firstname {space} Lastname.", IsRequired=true, Name="FullName")
full_name: Optional[str] = None
"""
Name of donor. Maximum 100 characters. Format must be Firstname {space} Lastname.
"""
# @ApiMember(Description="Billing address. Maximum 100 characters.", IsRequired=true, Name="Address")
address: Optional[str] = None
"""
Billing address. Maximum 100 characters.
"""
# @ApiMember(Description="Billing city. Maximum 100 characters.", IsRequired=true, Name="City")
city: Optional[str] = None
"""
Billing city. Maximum 100 characters.
"""
# @ApiMember(Description="Billing state. Two characters, must match valid US state code.", IsRequired=true, Name="State")
state: Optional[str] = None
"""
Billing state. Two characters, must match valid US state code.
"""
# @ApiMember(Description="Credit Card billing address postal code. Maximum 10 characters.", IsRequired=true, Name="PostalCode")
postal_code: Optional[str] = None
"""
Credit Card billing address postal code. Maximum 10 characters.
"""
# @ApiMember(Description="Email address of donor. Maximum 100 characters. If provided, must be valid email format.", Name="EmailAddress")
email_address: Optional[str] = None
"""
Email address of donor. Maximum 100 characters. If provided, must be valid email format.
"""
# @ApiMember(Description="Preferred phone number. Maximum 12 characters.", Name="Phone")
phone: Optional[str] = None
"""
Preferred phone number. Maximum 12 characters.
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DonationMemberInfo:
# @ApiMember(IsRequired=true)
bh_user_id: int = 0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DonationAchRequest(DonationRequestBase, IDonationRequestWithDonorInfo):
# @ApiMember(Description="Not required if MemberInfo is present on request")
donor_info: Optional[DonationDonorInfo] = None
"""
Not required if MemberInfo is present on request
"""
# @ApiMember(Description="Not required if DonorInfo is present on request")
member_info: Optional[DonationMemberInfo] = None
"""
Not required if DonorInfo is present on request
"""
# @ApiMember(Description="Use GET /campaigns to retreive valid list of campaignIDs")
campaign_id: Optional[int] = None
"""
Use GET /campaigns to retreive valid list of campaignIDs
"""
# @ApiMember(Description="RoutingNumber and AccountNumber are not required if AchRef is provided")
ach_ref: Optional[str] = None
"""
RoutingNumber and AccountNumber are not required if AchRef is provided
"""
# @ApiMember(Description="Required if AchRef is not provided")
routing_number: Optional[str] = None
"""
Required if AchRef is not provided
"""
# @ApiMember(Description="Required if AchRef is not provided")
account_number: Optional[str] = None
"""
Required if AchRef is not provided
"""
Python DonationAchRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /donations/ach 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,"AchRef":"String","RoutingNumber":"String","AccountNumber":"String","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"}