Socket
Socket
Sign inDemoInstall

@utorgapp/deeplinks-generator

Package Overview
Dependencies
1
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @utorgapp/deeplinks-generator

Provides an API for deep link generation. The links are used to onboard users with invoices to UTORG mobile app.


Version published
Maintainers
4
Install size
200 kB
Created

Readme

Source

Provides an API for deep link generation. The links are used to onboard users with invoices to UTORG mobile app.

  • Installation
  • Usage
  • API
  • Support
  • License

Installation

npm i @utorg-invoicing/deeplinks-generator
yarn add @utorg-invoicing/deeplinks-generator

Usage

import { generateDeepLink } from '@utorg-invoicing/deeplinks-generator'

// User pays 100 USDT (Polygon) 
generateDeepLink(
  'https://link.utorg.com/${template}/${templatePath}',
  {
    address: 'some crypto wallet address',
    externalId: 'merchant-invoice-1',
    merchantId: 'merchant id',
    paymentType: 'crypto',
    amount: 100,
    currency: 'USDT',
    chain: 'POLYGON',
    paymentCurrency: 'EUR',
    paymentMethodId: 'payment method id',
    postbackUrl: 'https://merchant.com/utorg/callback',
    email: 'test@test.com',
  }
)
  .then((cryptoDeepLink) => {})
  .catch((error) => {})
import { generateDeepLink } from '@utorg-invoicing/deeplinks-generator'

// User pays 200 EUR in USDT (Polygon) 
generateDeepLink(
  'https://link.utorg.com/${template}/${templatePath}',
  {
    address: 'some crypto wallet address',
    externalId: 'merchant-invoice-2',
    postbackUrl: 'https://merchant.com/utorg/callback',
    currency: 'USDT',
    chain: 'POLYGON',
    paymentCurrency: 'EUR',
    email: 'test@test.com',
    merchantId: 'merchant id',
    paymentMethodId: 'payment method id',
    paymentType: 'fiat',
    paymentAmount: 200,
  }
)
  .then((fiatDeepLink) => {})
  .catch((error) => {})

const url = 'https://link.utorg.com/${template}/${templatePath}?deep_link_value=N4IghgtgdgLiBcBGADMgNCADmAngQWjiVQzABMyAnBcCygUwGdGQMBjACyhrwDU8AMngByAYQASAUVYg2AV2rwQfPAA0Z2HKIU8AqgBEQAXyA'
const searchParams = new URLSearchParams(new URL(url).search);
const deepLinkValue = searchParams.get('deep_link_value'); // N4IghgtgdgLiBcBGADMgNCADmAngQWjiVQzABMyAnBcCygUwGdGQMBjACyhrwDU8AMngByAYQASAUVYg2AV2rwQfPAA0Z2HKIU8AqgBEQAXyA

parseDeepLinkValue(deepLinkValue)
  .then((options) => {
    const crypto = `${options.currency} (${options.chain})`
    if (options.paymentType === 'crypto') {
        return `User pays ${options.amount} ${crypto}`
    }
    return `User pays ${options.paymentAmount} ${options.paymentCurrency} in ${crypto}`
  })
  .catch((err) => {
    console.error('deep link parsing error', err)
  })

API

async function generateDeepLink(
  baseUrl: string,
  options: DeepLinkOptions,
  attributes: Record<string, string> = {}
): Promise<string> {}

Appends compressed and encoded options string as deep_link_value query param to the baseUrl. Attributes are reserved for AppsFlyer OneLink attributes and added without compression

Rejects a promise if options are invalid

Deep link example: https://link.utorg.com/${template}/${templatePath}?deep_link_value=N4IghgtgdgLiBcBGADMgNCADmAngQWjiVQzABMyAnBcCygUwGdGQMBjACyhrwDU8AMngByAYQASAUVYg2AV2rwQfPAA0Z2HKIU8AqgBEQAXyA

  • baseUrl - https://link.utorg.com/${template}/${templatePath} where template and templatePath determine the way the link will be handled by the UTORG app. Please contact support to get the template values.
  • options - deep links options object
MandatoryTypeDescription
addresstruestringCrypto wallet address of a customer
currency *truestringPayment crypto currency
chain *truestringPayment blockchain
paymentTypetrue'fiat' or 'crypto'Specifies the payment amount type
paymentAmount or amounttruenumberIf paymentType is 'fiat' then paymentAmount should be passed. For 'crypto' pass amount
externalId *truestringInvoice identifier prvided by merchant
merchantId *truestringMerchant's identifier
postbackUrl *falsestringA URL for sending data via postback
paymentCurrency *falsestringPayment fiat currency
emailfalsestringCustomer's email
paymentMethodId *falsestringPayment method external identifier

 * Please contact support to get specific values

parseDeepLinkValue

function parseDeepLinkValue(deepLinkValue: string): Promise<DeepLinkOptions> {}

Parses the value of deep_link_value to an object shaped as DeepLinkOptions

Support

If any questions occur please contact us support@utorg.pro

License

MIT

FAQs

Last updated on 21 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc