Verify Funds and Create Transfer
Overview
+-------------+ +----------+ +------------+
| Customer |----(1)--->| Customer |----(2)--->| PayMitto |
| Application |<---(7)----| API (4) |<---(3)----| API |
+-------------+ +----------+ +------------+
| | |
| | | +------------+
| | ---------(5)--->| PayMitto |
| <----------(6)----| API |
| +------------+
|
| +------------+
-----------(8)--->| PayMitto |
| SDK |
+------------+- Customer application makes a network request to the Customer API to initiate the creation of a transfer
- Customer API makes a network request to the PayMitto API to read quote details
- PayMitto API returns the quote details or an error
- Customer API performs additional prerequisites, such as verification of funds
- Customer API makes a network request to the PayMitto API to create a transfer
- PayMitto API returns the transfer details or an error
- Customer API returns the transfer details or an error
- Customer application returns the transfer details or throws an error
Contract
- Called when the SDK submits a transfer.
- Receives a PayMittoTransferRequest and must resolve to PayMittoTransferResponse or PayMittoError.
Types
See the following type documentation for details:
- PayMittoTransferRequest - The request object received by this callback
- PayMittoTransferResponse - Success response structure
- PayMittoError - Error response structure
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>
);
}