JavaScript Reference
Installation
-
Go to Integration (opens in a new tab) at Donmo Dashboard
-
Generate API keys, activate integration, set up currency and roundup rule that you prefer (default -
10
) -
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>
-
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
. -
Call
javascript donmo.build()
only once for building the integration view. Calldonmo.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())
-
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 assk: 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
Option Required Type Default Description publicKey Required string – Public key from dashboard elementId Required string – The id of the element (e.g., div
) to contain integrationorderId Required string – Order ID addDonationAction Required function – Ecommerce method that adds donation item to the cart removeDonationAction Required function – Ecommerce method that removes donation item from the cart getExistingDonation Required function – Ecommerce method that returns donation amount integrationTitle Optional string Round up for Ukrainian Army! Integration title roundupMessage Optional string Round up Roundup message (button) thankMessage Optional string Thank you! "Thank you" message after roundup (button) errorMessage Optional string Something happened, but please try again Error message language Optional uk
,en
uk
Integration language (Ukrainian or English) isBackendBased Optional Boolean ( true
,false
)false
Set true
only if you store donations in-house and send them once in a month.
Whenfalse
, donations are fully handled and stored by Donmo API immediately after roundup.
How it works
-
The client makes an order and rounds up the grand total.
-
The donation is sent to Donmo API and later confirmed after the order is completed
-
On the first day of every month, the email is sent to you with report and invoice for collected donations.
-
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.