Verify Funds and Create Transfer

Overview

    +-------------+           +----------+           +------------+
    |  Customer   |----(1)--->| Customer |----(2)--->| PayMitto |
    | Application |<---(7)----| API (4)  |<---(3)----|    API     |
    +-------------+           +----------+           +------------+
           |                      | |
           |                      | |                +------------+
           |                      |  ---------(5)--->| PayMitto |
           |                       <----------(6)----|    API     |
           |                                         +------------+
           |
           |                  +------------+
            -----------(8)--->| PayMitto |
                              |    SDK     |
                              +------------+
  1. Customer application makes a network request to the Customer API to initiate the creation of a transfer
  2. Customer API makes a network request to the PayMitto API to read quote details
  3. PayMitto API returns the quote details or an error
  4. Customer API performs additional prerequisites, such as verification of funds
  5. Customer API makes a network request to the PayMitto API to create a transfer
  6. PayMitto API returns the transfer details or an error
  7. Customer API returns the transfer details or an error
  8. Customer application returns the transfer details or throws an error

Contract


Types

See the following type documentation for details:

export type PayMittoTransferRequest = {
  fields?: [PayMittoTransferRequestField] | undefined;
  quoteBy: string;
  quoteHistoryId: string;
  recipientAccountId?: string | undefined;
  recipientId: string;
  sourceAccountId?: string | undefined;
}

export type PayMittoTransferRequestField = {  
  id: string;
  type: string;
  value: string;
}

export interface PayMittoTransferResponse {
  transferId: string;
}

Sample Implementation

import type { PayMittoTransferRequest, PayMittoTransferResponse, PayMittoError } from 'react-native-paymitto-sdk';

export const verifyFundsAndCreateTransfer = async (
  request: PayMittoTransferRequest,
): Promise<PayMittoTransferResponse | PayMittoError> => {
  const url = 'https://example.com/v1/verifyFundsAndCreateTransfer';
  const response = await fetch(url, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(request),
  });

  if (!response.ok) {
    return { code: 'UNEXPECTED_ERROR', message: String(response.status) };
  }

  return (await response.json()) as PayMittoTransferResponse;
};
...


import React from 'react';
import { Button, View } from 'react-native';
import {
  startSDK,
  PayMittoEnvironment
} from 'react-native-paymitto-sdk';

export default function App() {
  const onPress = () => {
    startSDK({
      configuration: { environment: PayMittoEnvironment.Sandbox },
      fetchAccessTokenDetails: fetchAccessTokenDetails,
      verifyFundsAndCreateTransfer: verifyFundsAndCreateTransfer
      ...
  };

  return (
    <View style={{ padding: 24 }}>
      <Button title="Start PayMitto" onPress={onPress} />
    </View>
  );
}