JavaScript Reference

Installation

  1. Go to Integration (opens in a new tab) at Donmo Dashboard

  2. Generate API keys, activate integration, set up currency and roundup rule that you prefer (default - 10)

  3. Add to the payment page the following script and html block (where the roundup window is supposed to be):

    <script src="https://static.donmo.org/integration.js"></script>
    <div id="donmo-roundup"></div>
  4. Initialize donmo object the following way with providing appropriate attributes:

    const donmo = DonmoRoundup({
      publicKey:
        'pk_test_16d8b2364b13577fbb616719a2586b3de475eca10206739cd8a7b3b306031c7cfd8982a30be7aa4a803d55226eb404c907701e5b66ef4e572e91bad94c80d69c',
      elementId: 'donmo-roundup',
      orderId: 'store_order_id',
     
      // ECOMMERCE CALLBACKS
      addDonationAction: () => {
        // call store's method which adds donation item to the cart
        add_donation_item()
      },
      removeDonationAction: () => {
        // call store's method which removes donation item from the cart
        remove_donation_item()
      },
      getExistingDonation: () => {
        // calls store's method which returns donation item amount
        return donation_item_amount()
      },
     
      // more optional parameters below
    })

    From now on, there are two main methods of donmo that are available to you: build та refresh.

  5. Call javascript donmo.build() only once for building the integration view. Call donmo.refresh() at every change of the grand total (for example, with a help of observers):

    donmo.build()
     
    // ...
     
    // pseudocode: call refresh on every change of grand total
    this.grandTotal.subscribe(() => donmo.refresh())
  6. Confirm the donation, by making the API call from your backend server after the order payment is completed. The call must be to api.donmo.org/confirm/{orderId}. Provide the secret key in headers as sk: value. For more details and examples for different programming languages, please check the API DOCS (opens in a new tab) page.

    Possible attributes for DonmoRoundup

    OptionRequiredTypeDefaultDescription
    publicKeyRequiredstringPublic key from dashboard
    elementIdRequiredstringThe id of the element (e.g., div) to contain integration
    orderIdRequiredstringOrder ID
    addDonationActionRequiredfunctionEcommerce method that adds donation item to the cart
    removeDonationActionRequiredfunctionEcommerce method that removes donation item from the cart
    getExistingDonationRequiredfunctionEcommerce method that returns donation amount
    integrationTitleOptionalstringRound up for Ukrainian Army!Integration title
    roundupMessageOptionalstringRound upRoundup message (button)
    thankMessageOptionalstringThank you!"Thank you" message after roundup (button)
    errorMessageOptionalstringSomething happened, but please try againError message
    languageOptionaluk, enukIntegration language (Ukrainian or English)
    isBackendBasedOptionalBoolean ( true, false )falseSet true only if you store donations in-house and send them once in a month.
    When false, donations are fully handled and stored by Donmo API immediately after roundup.

How it works

  1. The client makes an order and rounds up the grand total.

  2. The donation is sent to Donmo API and later confirmed after the order is completed

  3. On the first day of every month, the email is sent to you with report and invoice for collected donations.

  4. The collected donations are equally split between three Ukrainian war-time charity funds, specifically "Come Back Alive" Foundation (opens in a new tab), United24 (opens in a new tab) and Serhiy Prytula Charity Foundation (opens in a new tab)

    In case of need to store the donations on your own server (with isBackendBased = true) and sending them all through Donmo API only once in a month , please write to us at info@donmo.org to avoid unpredictable errors.