For AI agents: visit https://developer.readyremit.com/llms.txt for an index of all pages formatted in Markdown and endpoints in OpenAPI.
verifyFundsAndCreateTransfer
+-------------+ +----------+ +----------+
| 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 makes 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
((TransferRequest) async throws(PayMittoError) -> TransferDetails)?
| Type | Description |
|---|
| TransferRequest | Information that is required to include when creating the transfer |
| Type | Description |
|---|
| PayMittoError | An error value communicating the process of verifying funds and creating a transfer was not successful |
| Type | Description |
|---|
| TransferDetails | The transfer ID for the successfully created transfer |
struct CreateTransferResponse: TransferDetails {
var transferId: String
}
private func verifyFundsAndCreateTransfer(
transferRequest: TransferRequest
) async throws(PayMittoError) -> TransferDetails {
guard let url = URL(string: "https://example.com/v1/verifyFundsAndCreateTransfer") else {
throw URLError(.badURL)
}
var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "POST"
urlRequest.httpBody = try JSONEncoder().encode(transferRequest)
let (data, urlResponse) = try await URLSession.shared.data(for: urlRequest)
guard let httpURLResponse = urlResponse as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
switch httpURLResponse.statusCode {
case 200...299:
return try JSONDecoder().decode(CreateTransferResponse.self, from: data)
default:
throw PayMittoError(code: .none, message: "Insufficient Funds")
}
}