PUT Commit a Transaction
PUT /transfer/v1/transactions/{transactionId}/commit
Development Guide
The 'Commit a Transaction' endpoint executes the transactionId
and completes the transfer of funds.
1. Prepare headers & authentication:
The application must call the 'Commit a transaction' endpoint with a PUT HTTP method, providing the OAuth access_token
and all other required header values.
Note: MoneyGram uses the OAuth 2.0 framework. The application must use their OAuth client credentials to generate an
access_token
by calling the Get access token endpoint. The token is valid for 1 hour and must be passed as a header value in all subsequent API HTTP calls. Learn More
Launch Code Example
👉Transfer Commit - HeadersOpen Recipe
2. Provide the transactionId
resource as a path parameter and prepare the request body:
transactionId
resource as a path parameter and prepare the request body:The application must persist the transactionId
from the Update or Create a transaction endpoint and apply it as a path parameter to the Commit a transaction endpoint.
Launch Code Example
👉Transfer Commit - transactionID Path ParameterOpen Recipe
3. Display 'Fraud Warnings' & 'Pre-disclosure' in application UI:
It is a regulatory requirement to display Fraud Warnings (US Only, Global) and a Pre-Payment Disclosure to the consumer before the transfer of funds is executed. Both the Fraud Warnings and Pre-payment Disclosure must be displayed for all transactions (i.e. in all send countries, for all amounts, for all service options).
4. Make a request and handle the response:
The application must call the 'Commit a transaction' endpoint with a PUT HTTP method. The application must build to handle the following response scenarios:
- Success | Parse the Response | 200 OK HTTP Status
When the 'Commit a transaction' endpoint responds with a 200 HTTP Status the application has finalized and executed the transfer. The response payload, will return the following fieldsreferenceNumber
, andexpectedPayoutDate
. The funds are marked for "settlement" on the MoneyGram ledger.
- Failed | Handle the Error | 400 Bad Request HTTP Status
When the 'Commit a transaction' endpoint responds with 400 Bad Request HTTP Status a specific error message/s will be returned. The application will need to resolve these errors and resubmit the transaction for commit.
Launch Code Example
👉Transfer Commit - SuccessOpen Recipe.
👉Transfer Commit - FailureOpen Recipe
5. You're Done! Communicate the reference number to consumer:
It is recommended to prominently display the referenceNumber
on the application UI and send a notification to the consumer and provide receipts
Business Rules to Code
Idempotent: If the application does not receive a response from the Commit a Transaction API within 10-40 seconds, the application must send the request again. This must be retried up to 3 times. If the retry attempt fails, check the
transactionStatus
using the Status API to confirm if transaction was successful.Error Code 935: If error code 935 internal system error is returned on commit, it must be handled the same way as if the commit response is not received (see item 1).
Handling Errors: Other errors can be returned on commit a transaction stopping the transaction. The application must handle scenarios where the transaction fails (an error code is returned) on commit. Learn More
Receipts: Refer to Receipts module for detailed information and requirements for receipts.
Start online, fund in store: If a digital application wants to fund the transactions in store they should have market the
"fundInStore": true
on the Update API, the Commit API is not needed.Reference Number Recycling policy: MoneyGram will recycle the reference numbers after the transactions have been closed/received for 4 to 6 months. If you are storing reference numbers in your database, you should also store the transaction date. The combination of the reference number and transaction date will be the unique key for a transaction.
Video Tutorial
Code Examples
const axios = require('axios');
const { v4: uuidv4 } = require('uuid');
const commitTransaction = async () => {
// Step 1: Read configuration values with upmost security
const token = "your_access_token_from_oauth_response"
// For production - api.moneygram.com & For test - sandboxapi.moneygram.com
const transactionId = "current_transaction_id";
const host = "sandboxapi.moneygram.com";
const url = 'https://' + host + '/transfer/v1/transactions/' + transactionId + '/commit';
// Step 2: Create the PUT request headers & body
const headers = {
'Content-Type': 'application/json',
'X-MG-ClientRequestId': uuidv4(), // New UUID for each request tracing
'Authorization': 'Bearer ' + token,
};
const request = {
agentPartnerId: "your_partner_id",
targetAudience: "AGENT_FACING",
userLanguage: "en-US"
}
try {
// Step 3: Send the request and obtain the response
axios.put(url, request, { headers })
.then(function (response) {
// Step 4: Parse the success response and process further
console.log(JSON.stringify(response.data, null, 2))
})
.catch(function (error) {
// Step 5: Parse the error response and handle the errors
if (error.response) {
console.log('Response status:', error.response.status);
console.log('Response body:', error.response.data);
} else {
// TODO: handle generic errors
console.error('Error:', error.message);
}
});
} catch (error) {
// TODO: handle exception
console.error('Error:', error.message);
}
};
commitTransaction();
import requests
import uuid
import json
def commit_transaction():
# Step 1: Read configuration values with upmost security
token = "your_access_token_from_oauth_response"
# For production - api.moneygram.com & For test - sandboxapi.moneygram.com
transactionId = "current_transaction_id";
host = "sandboxapi.moneygram.com";
url = 'https://' + host + '/transfers/v1/transactions/' + transactionId + '/commit';
# Step 2: Create the POST request headers & body
headers = {
'Content-Type': 'application/json',
'X-MG-ClientRequestId': str(uuid.uuid4()), # New UUID for each request tracing
'Authorization': 'Bearer ' + token,
}
request = {
'agentPartnerId': 'your_partner_id',
'targetAudience': 'AGENT_FACING',
'userLanguage': 'en-US'
}
try:
# Step 3: Send the request and obtain the response
response = requests.put(url, json=request, headers=headers)
# Step 4: Parse the success response and process further
if response.status_code == 200:
parsed_response = json.dumps(json.loads(response.text), indent=2)
print(parsed_response)
else:
# Step 5: Parse the error response and handle the errors
print("Request failed with status code:", response.status_code)
print(json.dumps(json.loads(response.text), indent=2))
except requests.exceptions.RequestException as e:
# Print any error that occurred during the request
# TODO: handle exception
print("An error occurred:", e)
commit_transaction()
package transfers;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonWriter;
import java.io.StringWriter;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.UUID;
public class CommitTransaction {
public static void main(String[] args) {
// Step 1: Read configuration values with upmost security
String token = "your_access_token_from_oauth_response";
// For production - api.moneygram.com & For test - sandboxapi.moneygram.com
String host = "sandboxapi.moneygram.com";
String transactionId = "current_transaction_id";
String tokenEndpoint = "https://" + host + "/transfer/v1/transactions/" + transactionId + "/commit";
// Step 2: Create the PUT request headers & body
// Create a JSON object
JsonObjectBuilder requestBuilder = Json.createObjectBuilder()
.add("agentPartnerId", "your_partner_id")
.add("targetAudience", "AGENT_FACING")
.add("userLanguage", "en-US");
JsonObject jsonObject = requestBuilder.build();
// Create a StringWriter to write the JSON string
StringWriter stringWriter = new StringWriter();
try (JsonWriter jsonWriter = Json.createWriter(stringWriter)) {
jsonWriter.writeObject(jsonObject);
}
// Get the JSON string from the StringWriter
String jsonString = stringWriter.toString();
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(tokenEndpoint))
.PUT(HttpRequest.BodyPublishers.ofString(jsonString))
.setHeader("Authorization", "Bearer " + token)
.setHeader("X-MG-ClientRequestId", String.valueOf(UUID.randomUUID()))
.build();
try {
// Step 3: Send the request and obtain the response
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
// Retrieve the status code and body from the response
int statusCode = response.statusCode();
// Step 4: Parse the success response and process further
if (statusCode == 200) {
String responseBody = response.body();
System.out.println(responseBody);
} else {
// Step 5: Parse the error response and handle the errors
String responseBody = response.body();
System.out.println(responseBody);
}
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
}
Support APIs
To make your development easier, MoneyGram has provided a Reference Data APIs Module that can be queried to provide a list of supported fields, values and associated meta-data to use in your integration.
Name | HTTP Method | Endpoints | Description |
---|---|---|---|
Retrieve Enumerations | GET | /reference-data/v1/enumerations | Retrieves enumerated values for fields |
API Structure
Header Parameters
Field | Type | Required /Optional | Description |
---|---|---|---|
X-MG-ClientRequestId | String | Required | Client Request Id that can be passed by the client application. Client request Id must be unique within a single session for unique requests. This attribute can be used for ensuring idempotent request processing for some APIs. MoneyGram recommends using a UUID for the value of this field. |
X-MG-ConsumerIPAddress | String | Optional | IP Address of the system initiating the session |
Path Parameters
Path Parameter | Type | Required /Optional | Description |
---|---|---|---|
transactionId | String Max length: 36 | Required | Unique id of the transaction resource |
Request Body Fields
Field | Type | Required /Optional | Description |
---|---|---|---|
fundingSource.tenderType | String | Optional | Funding method, based on enumerations (Enumerated values) NOTE: For a full list of accepted tenderTypes. See Reference Data Enumerations endpoint |
fundingSource.provider | String | Optional | Name of the payment provider |
fundingSource.providerNetworkCode | String | Optional | Providers unique network identifier code |
fundingSource.providerAccountNumber | String | Optional | Account number of payment source |
fundingSource.accountIdentifier | String | Optional | MoneyGram's unique identifier for the consumer account |
placeOnPartnerHold | Boolean | Optional | Request MoneyGram to place the transaction on hold |
partnerTransactionId | String | Optional | Partner’s unique session identifier |
partnerSettlementId | String | Optional | Partner’s unique identifier for real time settlement only |
additionalDetails | Dynamic | Optional | Dynamic field key/values |
Response Fields
Field | Type | Required /Optional | Description |
---|---|---|---|
referenceNumber | String Length: 8 | Optional | MoneyGram's reference number for the transaction |
fundsInStoreConfirmationCode | String | Optional | MoneyGram's unique confirmation number |
expectedPayoutDate | String Format: CCYY-MM-DD | Optional Length: 10 | Date (YYYY-MM-DD) |
settlement.reconcileSendAmount | String Min length: 0 Max length: 14 Max Decimal Value: 3 | Optional | Send Amount to be settled with MoneyGram |
settlement.reconcileReceiveAmount | String Min length: 0 Max length: 14 Max Decimal Value: 3 | Optional | Receive amount to be settled with MoneyGram |
settlement.settlementAccount | String | Optional | MoneyGram settlement account/wallet details |
settlement.settlementMemo | String | Optional | MoneyGram settlement account/wallet memo |
Updated 8 days ago