Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Payment API version 1.3

Norbert Schuler edited this page Sep 23, 2019 · 1 revision

Here just a short description of the new API. The API for v1.1 has not changed and supports only Stripe card tokens and no recurrent donations.

The documentation can be found here: https://devel.trilliontreecampaign.org/api/doc/donation

Donations are created via 3 API calls:

  1. create the donation
  2. pay for the donation
  3. fetch and merge the finalized donation

1 Donation Creation

To create a donations there are 4 different APIs due to the fact that donations can either be public or authenticated and they can be either regular donations or gifts.

2 Donation Payment

Donation payment APIs are common for both donation types but there are 2 APIs, one for public and one for authenticated.

PaymentIntents

PaymentIntents are created based on PaymentMethods. PaymentMethods must only be attached to the customer if the user has select save for later (see Zeplin). The attachment must occur just before the payment API call is submitted.

Payment API

The documentation for the payment API is incomplete and is therefor documented here:

Request Body

{
  "paymentProviderRequest": {
    "account": "stripe_DE",
    "gateway": "stripe",
    "source": {
      "id": "pm_1FCUSBGhHD5xN1UqlUVCTHdM",
      "object": "payment_method"
    }
  }
}

Request Response

{
    "donationId": 241596,
    "status": "success",
    "message": null,
    "response": null
}

status can be one of the following:

  • success
  • action_required the data to handle perform the action can be found under the key response
  • failed the key message will contain the reason for the failureresponse

After the donation was successful, the locally stored donationId must be destroyed so it cannot be reused.

Donation Finalize

The last step of the donation process consists of fetching the finalized donation and merging it into Redux.

The donation fetch APIs are common for both donation types but there are 2 APIs, one for public and one for authenticated.

For devs without access to Zeplin, here the UI: @sagararyal please provide link to Zeplin