Crypto Discount Signature

Crypto Discount

This crypto discount generates a discount signature by the admin of the buy-now on-chain contract to apply the discount on the crypto payment.

We are using on-chain buy now payment, in the on-chain case also we applying the discount part in the on-chain payments flow. that's where we are generating the discount info hash signature generated from the on-chain contract admin. this signature will be applied to the payment section.

Sample query

query applyDiscountCode(
  $discountCode: String!
  $invoiceItemID: UUID1!
  $isCryptoDiscount: Boolean
  $buyerAddress: String
) {
  applyDiscountCode(
    discountCode: $discountCode
    invoiceItemID: $invoiceItemID
    isCryptoDiscount: $isCryptoDiscount
    buyerAddress: $buyerAddress
  ) {
    onchainDiscountInfo {
      discountPercentage
      expirationTime
      nonce
      signature
      signer
      buyerAddress
    }
  }
}

Sample variable

{
  "discountCode": "VVITA23",
  "invoiceItemID": "4c987863-b2dd-4f0c-84db-c9138a4ad89f",
  "isCryptoDiscount": true,
  "buyerAddress": "0xCB50f83Ec43901Fd05866a881514D2A4B62aA4ba"
}

Sample response

{
  "data": {
    "applyDiscountCode": {
      "onchainDiscountInfo": {
        "discountPercentage": 2000,
        "expirationTime": 1691229600,
        "nonce": "9c03379e-52f2-4477-b4d3-eaa8425c4fa1",
        "signature": "0x461b68361e042f10dee3d74119d1cd195796b36a551ad2da8266c3f1ba5a058e3a8a74cdd05a553e0f8aa379719a032d9d0757621d39eb3376aa66e6afca07d51c",
        "signer": "0xaDE04b0544e25A8C23f0a57aE0b61caC8B5bfd11",
        "buyerAddress": "0xCB50f83Ec43901Fd05866a881514D2A4B62aA4ba"
      }
    }
  }
}

Arguments

NameTypeDescriptionRequired
discountCodeStringDiscount code.Yes
invoiceItemIDUUIDInvoice item id.Yes
isCryptoDiscountBooleanif need a buy now discount signature key need to pass this field to true.Yes
buyerAddressStringThe token buyer address.Yes

Fields

NameTypeDescription
DiscountedInvoiceItemObjectContains information about the discount DiscountedInvoiceItem such as signature, discount amount, total price with discount and etc.