Git Product home page Git Product logo

transak-sdk's Introduction

Transak SDK

A library for decentralised applications to onboard their global user base with fiat currency.

Example usage

<div id="transakMount"></div>
import { TransakConfig, Transak } from '@transak/transak-sdk';

const transakConfig: TransakConfig = {
  apiKey: '<your-api-key>', // (Required)
  environment: Transak.ENVIRONMENTS.STAGING/Transak.ENVIRONMENTS.PRODUCTION, // (Required)
  containerId: 'transakMount', // Id of the element where you want to initialize the iframe
  // .....
  // For the full list of customisation options check the link below
};

let transak = new Transak(transakConfig);

transak.init();

// To get all SDK events
Transak.on('*', (data) => {
  console.log(data);
});

// This will trigger when the user closed the widget
Transak.on(Transak.EVENTS.TRANSAK_WIDGET_CLOSE, () => {
  console.log('Transak SDK closed!');
});

/*
* This will trigger when the user has confirmed the order
* This doesn't guarantee that payment has completed in all scenarios
* If you want to close/navigate away, use the TRANSAK_ORDER_SUCCESSFUL event
*/
Transak.on(Transak.EVENTS.TRANSAK_ORDER_CREATED, (orderData) => {
  console.log(orderData);
});

/*
* This will trigger when the user marks payment is made
* You can close/navigate away at this event
*/
Transak.on(Transak.EVENTS.TRANSAK_ORDER_SUCCESSFUL, (orderData) => {
  console.log(orderData);
  transak.cleanup();
});

Refer here for the full list of customisation options

For in-depth instructions on integrating Transak, view our complete documentation.

Using Modal UI

If you want to use our modal UI, do not pass the containerId and use transak.close() instead of transak.cleanup()

React Gotchas

Do not forget to clean up by using the transak.cleanup() or transak.close()

useEffect(() => {
  return () => {
    transak.cleanup();
  };
}, []);

transak-sdk's People

Contributors

agarwalyeshu avatar debajitr avatar harshit00027 avatar prajwal-kamboj avatar reslear avatar satyasandeep007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

transak-sdk's Issues

Configurable z-indexes

Summary

I'm unable to find any way to configure the transak_modal's z-index. Looking at the codebase I don't see support for it already. For now we can manually override the CSS class and all will work on our end but I thought I would report it on this repository anyway so you are aware.

Behavior

This is causing the below issue on our site after some updates (our internal issue card)- the modal that opens the Transak modal has a higher z-index because of the way our z-index layering system is structured:

image

Suggested behavior

Should be configurable if possible.

How can I reproduce it?

Try to implement the transakSDK in an environment where something with a higher z-index than the modal is on the screen already.

Platform

Seems to be platform agnostic

Possible Solutions

Can z-index be configurable in the constructor alongside things like the widgetHeight and widgetWidth? Appreciate it might not be so simple if multiple components are using differening layered z-indexes, however in our system simply overriding the z-index of the transak_modal class seems to do the trick.

[BUG] Transak applies overflow: scroll to HTML unnecessarily

On closing a model Transak is applying overflow: scroll to the html element style attribute. I've had to override this with overflow: visible !important; in css for the time being, but ideally we should be able to control this in a normal way.

Transak L2 Rollathon Integration Bounty

Prize Title

Transak L2 Rollathon Integration Bounty

Prize Bounty

$15,000 in the stablecoin of your choice divided between the winning teams. Each winning team will also receive one month of 0% fees for their users.

Challenge Description

Integrate Transak’s fiat on/off ramp integration into your app and launch it! Transak lets mainstream users buy crypto directly in your app or website with their local fiat currency and payment method. You can onboard more users to crypto and increase your revenue through our super simple developer integration.

To be one of the winners and share in the prize you just need to integrate the staging version of Transak's fiat on-ramp into the app you build in the hackathon so there's a user flow for users to buy crypto within the app.

You don't need to go through out approval process for live fiat transactions but you're welcome to submit an application afterward if you want to!

Submission Requirements

To win share your live app with us and we'll perform a test transaction to confirm it all works.

Judging Criteria

The $15,000 will be divided between all teams that launch any product with Transak’s fiat on/off ramp integration.

Winner Announcement Date

2nd June

Resources

See our documentation and integration guide here

You can get answers to FAQs and solutions to common issues in the Transak Partner Support hub. Here you can also submit a ticket, which our round the clock support staff will respond to as soon as possible.

Alternatively you can email us:
[email protected] for support inquiries e.g. if you get lost in the process

Or Telegram:
🧑‍💻 Technical questions: https://t.me/transakfordevelopers
⚡️ General channel: https://t.me/transakfinance

separate modal and iframe

Sometimes it is necessary to embed an iframe in a document instead of a modal, but to use ready-made events that would not need to be rewritten. It's also convenient for custom modals.

my implementation started at #42

[Bug] Networks props seems to be "flipped"

Hi guys i noticed the networks props seems like "fliped"
thats is my code

let transak = new transakSDK({
    apiKey: REACT_APP_TRANSAK_API_KEY,
    environment: REACT_APP_ENVIRONMENT, // STAGING/PRODUCTION (Required)
    walletAddress: '',
    themeColor: '59A662',
    email: '',
    hostURL: window.location.origin,
    widgetHeight: '550px',
    widgetWidth: '450px',
    networks: 'arbitrum,avaxcchain,polygon,bsc,celo,fantom,moonriver',
    defaultNetwork: 'polygon',
    defaultCryptoCurrency: 'usdc',
    defaultCryptoAmount: 1,
  });

and when i open the widget, i can see a list of networks, but without my preferences
image

Example usage not working in Angular

I'm trying to use this library in Angular 9, and I tried following the Example Usage, but unfortunately I cannot import the @transak/transak-sdk, I tried different options for importing, Please refer to this stackblitz.

I also read the integration from here, it states that it's the proper way of integrating in Angular.

Please free to point where am I doing it wrong, or are there other dependencies should I install.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.