Implementing Chargeback Protection

Learn how to implement chargeback protection

How to Add Chargeback Protection

When merchants opt-in for chargeback protection, they will need to add our chargeback protection provider's sdk across every page of their site. This integration enables our provider to gather extra data during the customer's shopping experience. Depending on your implementation method, select from the below options to view instructions on how to implement:

React
  1. Add the <CoinflowPurchaseProtection> component to every page on your site.
  2. Add your merchantId as a property to the <CoinflowPurchaseProtection> component.
  3. In every <CoinflowPurchase> component, add the chargebackProtectionData property and input information about each purchase made via Coinflow.
React Native

Implement the nSure Mobile SDK

IOS:

  1. Drag and drop LocalPods folder from ReactNative > Resources into local IOS folder
    Add this line to the podfile “pod 'nSure', :path => 'LocalPods/nSure'“ and run pod install
  2. Drag and drop NSureSDK.h and NSureSDK.m from ReactNative > Resources into the Xcode workspace
    In NSureSDK.h change the conditional import to just “#import <React/RCTBridgeModule.h>“
  3. Add dependency AdSupport in the Xcode General tab under Frameworks, Libraries and Embedded Content
  4. In the Xcode Build Settings tab add -framework “nSure” to the Other Linker Flags
    Follow the remaining steps in the docs as is.
  5. Call `nsureSDK.sharedInstanceWithAppID` to get the `deviceId`

Android:

  1. Create a ‘libs’ folder in the android app and drag and drop Nsure.aar into the folder.
    Drag and drop NSureSDK.java and NSureSDKPackage.java into the project source (android > app > src > main > java > com > ‘project name’ >)
  2. Change the first line in NSureSDK.java and NSureSDKPackage.java from “package com.nsurereactnativesample;“ to “package com.<project name>”
    Follow the remaining steps in the docs as is.
  3. Call `nsureSDK.getDeviceId` to get the `deviceId`

Additional Steps:

  1. Pass the `deviceId` in `<CoinflowPurchase>` by implementing the following code:

  2. import { NativeModules } from 'react-native';
    var nsure = NativeModules.NSureSDK;
    var deviceId = "";
    nsureSDK.sharedInstanceWithAppID("9JBW2RHC7JNJN8ZQ", (nsure, _deviceId) => {
    this.deviceId = _deviceId;
    });
  3. In `<CoinflowPurchase>` add the `chargebackProtectionData` property and add information about every purchase that is being made via Coinflow.

SDK Repositories:

Here are the links for the public repositories of the iOS and Android SDKs:

Application ID: 9JBW2RHC7JNJN8ZQ

API
  1. Add the following code to every page on your site:
    <script src="https://sdk.nsureapi.com/sdk.js"> </script>
    <script>
      window.nSureAsyncInit = function(deviceId) {
        window.nSureSDK.init('9JBW2RHC7JNJN8ZQ');
        window.nSureSDK.init({
          appId: '9JBW2RHC7JNJN8ZQ',
          partnerId: <contact Coinflow for this> 
        });
      };
    </script>
    📘 This code will allow us to gather information on the user's device, how they interact with your website, and other info that allows the models to predict the risk of fraud or chargeback for this particular user.
  2. To each of your API calls, add the x-device-id header and pass the value which comes as a result of calling window?.nSureSDK?.getDeviceId() on your website.
    This deviceId is how the system relates the individual request to the information collected about the user's device and session from the SDK added above.
  3. In the Checkout Endpoint and the Redeem Transaction Endpoint, pass the chargebackProtectionData.
    📘 This information provides information about what is being purchased, which allows the AI models to determine the risk of chargeback for this particular purchase.

What to pass into chargebackProtectionData

Merchants that opt-in for chargeback protection are required to pass chargebackProtectionData as a prop to the <CoinflowPurchase> component or to our card checkout, saved card checkout, ach checkout , and redeem transaction endpoints.

🚧

The more information that you pass here the better the authorization rates will be, so it is in your best interest to supply as much information as possible

Example of chargebackProtectionData data structure

{
  /**
   * The name of the product
   */
  productName: string;
  /**
   * The product type. Possible values include: inGameProduct, gameOfSkill, dataStorage, computingResources, sportsTicket, eSportsTicket, musicTicket, conferenceTicket, virtualSportsTicket, virtualESportsTicket, virtualMusicTicket, virtualConferenceTicket, alcohol, DLC, subscription, fundACause, realEstate, computingContract, digitalArt, topUp
   * Contact Coinflow for the productType value.
   */
  productType: 'inGameProduct' |
    'gameOfSkill' |
    'dataStorage' |
    'computingResources' |
    'sportsTicket' |
    'eSportsTicket' |
    'musicTicket' |
    'conferenceTicket' |
    'virtualSportsTicket' |
    'virtualESportsTicket' |
    'virtualMusicTicket' |
    'virtualConferenceTicket' |
    'alcohol' |
    'DLC' |
    'subscription' |
    'fundACause' |
    'realEstate' |
    'computingContract' |
    'digitalArt' |
    'topUp';
  /**
   * The number of units sold
   */
  quantity: number;
  /**
   * Any additional data that the store can provide on the product, e.g. description, link to image, etc.
   */
  rawProductData?: { [key: string]: any };
}

Example Implementation on Coinflow's Prebuilt UI

<CoinflowPurchase
  wallet={wallet}
  merchantId={process.env.REACT_APP_MERCHANT_ID as string}
  transaction={transaction}
  amount={amount}
  blockchain={'solana'}
  chargebackProtectionData={[{
    "productName": "Sword", // Name of Product
    "productType": "inGameProduct", // Get the value from Coinflow
    "quantity": 1,
    "rawProductData": { // Adjust based on the available product data
      "productID": "sword12345",
      "productDescription": "A legendary sword with magical powers.",
      "productCategory": "Weapon",
      "weight": "15 lbs",
      "dimensions": "40 in x 5 in",
      "origin": "Ancient Kingdom",
      "craftedBy": "Master Blacksmith",
      "craftingDate": "2024-06-19"
    }
  },]}
/>

Example Implementation on Coinflow's APIs

curl --request POST \
     --url https://api-sandbox.coinflow.cash/api/checkout/ach/merchantId \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "subtotal": {
    "cents": 100
  },
  "transactionData": {
    "type": "safeMint"
  },
  "token": "5a000000-0000-0000-0000-000000000000",
  "chargebackProtectionData": [
    {
      "productType": "inGameProduct",
      "productName": "Sword",
      "quantity": 1,
      "rawProductData": {
        "productID": "sword12345",
        "productDescription": "A legendary sword with magical powers.",
        "productCategory": "Weapon",
        "weight": "15 lbs",
        "dimensions": "40 in x 5 in",
        "origin": "Ancient Kingdom",
        "craftedBy": "Master Blacksmith",
        "craftingDate": "2024-06-19"
      }
    }
  ]
}
'