CryptoChill SDK example

View source of this file on github.

Follow these steps to integrate Bitcoin payments using CryptoChill SDK:

1.

Include CryptoChill SDK javascript file: https://static.cryptochill.com/static/js/sdk2.js

sdk2.js is 60.7 KB only (Gzipped). Served from AWS CloudFront (CDN).


2.

Add buttons with cryptochill-button class name and use following data attributes:
  • data-product="My Awesome Product"

    Specify product name.

  • data-amount="10"

    Specify payment amount.

  • data-currency="USD"

    Available values: BTC, USD, EUR, GBP, AUD, CAD, CHF.

  • data-passthrough="12345" optional

    Provide any data that will be returned with callbacks. Can be JSON string.

  • data-show-payment-url="true" optional

    Show additional public payment URL that can be shared or copied further.

  • data-placement="inline" optional

    Display payment widget inline instead of modal dialog.

  • data-placement-target="elementID" optional

    Specify parent element ID in which payment widget will be added to.


3.

Initialize SDK using your Account ID and Profile ID parameters (can be found in Dashboard):
CryptoChill.setup({
    account: 'YOUR_ACCOUNT_ID',
    profile: 'YOUR_PROFILE_ID'

    // -- Event callbacks (Optional)
    // onOpen: onPaymentOpen,
    // onUpdate: onPaymentUpdate,
    // onSuccess: onPaymentSuccess,
    // onIncomplete: onPaymentIncomplete,
    // onCancel: onPaymentCancel

    // -- Global Parameters (Optional. Can be specified at the button level.)
    // passthrough: JSON.stringify({test: 123}),
    // placement: 'inline',
    // placementTarget: 'elementID',
})

Following event callbacks are available: onOpen, onUpdate, onIncomplete, onSuccess, onCancel.
To close and destroy modal window: CryptoChill.destroy().

4.

VoilĂ ! You have successfully integrated Bitcoin payments!

Live examples: ...




<button class="btn cryptochill-button"
    data-amount="10"
    data-currency="USD"
    data-product="My Awesome Product">
    My Awesome Product for 10 USD
</button>

<button class="btn cryptochill-button"
    data-amount="0.01"
    data-currency="BTC"
    data-product="Another Product">
    Another Product for 0.01 BTC
</button>

<button class="btn cryptochill-button"
    data-product="Donate">
    Donate
</button>

***

Important Note!

Never fully rely on JavaScript / client-side data provided in onSuccess, onUpdate and onIncomplete events as it can easily be manipulated. When it comes to transactions data processing you should fully trust only server to server callbacks.