| 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 .xml suffix or ?format=xml
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: application/xml
Content-Type: application/xml
Content-Length: length
<DonationAchRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BH.CloudAPI.Common4.DTO.Donations">
<Amount>0</Amount>
<CurrencyCode>String</CurrencyCode>
<DonationRecurringInfo>
<Frequency>String</Frequency>
<FutureDonationDate>0001-01-01T00:00:00</FutureDonationDate>
<NumberOfOccurrences>0</NumberOfOccurrences>
</DonationRecurringInfo>
<GroupId>String</GroupId>
<Memo>String</Memo>
<MetaData xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:KeyValueOfstringstring>
<d2p1:Key>String</d2p1:Key>
<d2p1:Value>String</d2p1:Value>
</d2p1:KeyValueOfstringstring>
</MetaData>
<AccountNumber>String</AccountNumber>
<AchRef>String</AchRef>
<CampaignId>0</CampaignId>
<DonorInfo>
<Address>String</Address>
<City>String</City>
<EmailAddress>String</EmailAddress>
<FullName>String</FullName>
<Phone>String</Phone>
<PostalCode>String</PostalCode>
<State>String</State>
</DonorInfo>
<MemberInfo>
<BhUserId>0</BhUserId>
</MemberInfo>
<RoutingNumber>String</RoutingNumber>
</DonationAchRequest>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <DonationAchResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BH.CloudAPI.Common4.DTO.Donations"> <ErrorCode>0</ErrorCode> <ErrorMessage>String</ErrorMessage> <IsError>false</IsError> <TransactionId>String</TransactionId> </DonationAchResponse>