SDK Function Reference

The most relevant functions of the iDonate Client, their parameters, and the data schemas involved.

(Knowledge of JavaScript is required to understand this article.  TypeScript knowledge is also recommended.)

The iDonate SDK Client contains the functions you will need to use in order to create a transaction within iDonate.  These are written in TypeScript, a version of JavaScript that uses Java-style data types instead of JavaScript's laissez-faire approach to data types.

This means that to ensure proper function, the parameters you pass to the iDonate Client's functions must fit a very specific schema.  This article is about those functions and schemas.

As always, to see the SDK in action, and to take a look at what the code involved in a successful transaction looks like, please refer to the CHF SDK Example.

The Most Relevant Functions

The end objective of an iDonate SDK implementation is to create a transaction.  So, let's look at the functions used when creating one.  

  • Tokenize Spreedly Credit Card
  • Create Payment Method
  • Create Transaction

Table One: Functions and Parameters

Function Name Parameter(s)
tokenizeSpreedlyCreditCard()

An object comprised of the following Data Types:

  • Contact
  • Address
  • CreditCard
createPaymentMethod()

A single parameter of the following Data Type:

  • CreatePaymentMethodRequest
createTransaction()

A single parameter of the following Data Type:

  • CreateDonationRequest

Table Two: Data Types

Data Type Components (optional components listed in italics)
Contact
  • salutation: String
  • firstName: String
  • middleName: String
  • lastName: String
  • company: String
  • email: String
  • primaryPhone: String
Address
  • address1: String
  • address2: String
  • country: String
  • city: String
  • zip: String
CreditCard
  • cardNumber: String
  • verificationValue: String
  • expirationMonth: String
  • expirationYear: String
CreatePaymentMethodRequest

An object comprised of a RecaptchaSecuredRequest data type and the following components:

  • paymentGatewayId: String
  • paymentMethodType: PaymentMethodType
  • paymentMethodToken: String
  • donorId: String
  • contact: Contact
  • address: Address
RecaptchaSecuredRequest
  • recaptchaType: RecaptchaType
  • recaptchaToken: String
RecaptchaType

One of the following String values:

  • 'v2'
  • 'v3'
  • 'invisible'
  • 'organization'
  • 'nonce'
PaymentMethodType

One of the following String values:

  • 'credit_card'
  • 'bank_account'
  • 'paypal'
  • 'apple_pay'
  • 'google_pay'
CreateDonationRequest

An object comprised of a RecaptchaSecuredRequest data type and the following components:

  • paymentGatewayId: String
  • donorId: String
  • paymentMethodId: String
  • retainPaymentMethod: Boolean
  • paymentAmount: Number
  • currency: String
  • billingContact: Contact
  • billingAddress: Address
  • referenceCode: String
  • designationId: String
  • designations:
    • id: String
    • amount: Number
  • designationNote: String
  • campaignId: String
  • p2pFundraiserId: String
  • p2pFundraiserComment: String
  • p2pProgramId: String
  • organizationEventId: String
  • corporateMatchingId: String
  • advocateId: String
  • advocacyProgramId: String
  • landingPageId: String
  • customerMeta:
    • Array of:
      • key: String
  • utm: UTMData
  • tribute: TributeData
  • recurringFrequency: RecurringFrequency
  • recurringStart: Date
  • recurringEnd: Date
  • donorPaidFeeAmount: Number
  • emailOptIn: Boolean
  • anonymousOptIn: Boolean
  • giftId: String
  • giftExtra: String
  • giftSkipped: Boolean
  • embedId: String
RecurringFrequency

One of the following String values:

  • 'once'
  • 'weekly'
  • 'twicemonthly'
  • 'biweekly'
  • 'monthly'
  • 'quarterly'
  • 'semiannually'
  • 'annually'