Skip to content

namphantech/alchemy-payment-gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SDK Alchemy Payment Gateway

The sdk will make easily to integrate Alchemy Pay's NFT Checkout(crypto-based) feature to enable end users/customers to purchase NFTS using both cards and local payment methods worldwide in your application.

Checkout Flow chart

Flow

Installation

You need to contact to AlchemyPay to get account as merchant before.

yarn add alchemy-payment-gateway

Integration

import { AlchemyPay } from "alchemy-payment-gateway";


class AlchemyPaymentService {
  private readonly alchemyPayService: AlchemyPay;
  constructor(appId, appSecret, redirectUrl, callbackUrl, nftCheckoutEndpoint) {
    this.alchemyPayService = new AlchemyPay({
      appId,
      appSecret,
      redirectUrl,
      callbackUrl,
      nftCheckoutEndpoint,
    });
  }

  /* generate payment url for NFT checkout */
  public createPayment({
    crypto = "crypto type",
    cryptoAmount = "crypto amount to checkout",
    targetFiat = "fiat type",
    merchantOrderNo = "your orderId",
    name = "nft name",
    picture = "nft picture url",
    quantity = "quantity",
  }) {
    try {
      const paymentUrl = this.alchemyPayService.createPayment({
        cryptoAmount,
        targetFiat,
        merchantOrderNo,
        name,
        picture,
        quantity,
      });
      return paymentUrl;
    } catch (error) {
      throw error;
    }
  }

  /* verify webhook */
  public verifyPaymentResponse({
    amount,
    orderNo,
    quantity,
    payTime,
    signature,
    type,
    merchantOrderNo,
    crypto,
    payType,
    cryptoAmount,
    appId,
    name,
    transactionRate,
    fiat,
    status,
  }) {
    try {
      const isValidSignature = this.alchemyPayService.verifySignature({
        amount,
        orderNo,
        quantity,
        payTime,
        signature,
        type,
        merchantOrderNo,
        crypto,
        payType,
        cryptoAmount,
        appId,
        name,
        transactionRate,
        fiat,
        status,
      });
      return isValidSignature;
    } catch (error) {
      throw error;
    }
  }
}

Contact

Mail: phanvanhoainam22@gmail.com

Docs

About

AlchemyPay' SDK: Easy NFT Checkout integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published