Batch Process Transactions
Batch process transactions allow you to process multiple transactions at once. This is particularly useful when you need to handle a large volume of transactions.
How to Use
Creating a Batch
To create a new batch:
- curl
- C#
- Java
- PHP
curl -X POST --location "https://sandbox-api.payfurl.com/batch/transaction/payment_method" \
-H "x-secretkey: <secret_key>" \
-H "Content-Type: application/json" \
-d '{
"Count": 2,
"Description": "Test",
"Batch": "PaymentMethodId,Amount,Currency,Reference
fc3fb5ff9e3b42c290c740c8772b40aa,123.3,AUD,reference
fc3fb5ff9e3b42c290c740c8772b40aa,13.3,AUD,reference2",
"Webhook": {
"Url": "https://webhook.site/1752c235-7693-466b-9710-f6ca4e0f8255",
"Authorization": "Basic dXNlcjpwYXNzd29yZA=="
}
}'
var svc = new payfurl.sdk.Batch();
var batch = new NewTransactionPaymentMethod
{
Count = 1,
Description = "Test",
Batch = "PaymentMethodId,Amount,Currency,Reference
fc3fb5ff9e3b42c290c740c8772b40aa,123.4,AUD,reference",
Webhook = new WebhookConfig
{
Url = "https://webhook.site/1752c235-7693-466b-9710-f6ca4e0f8255",
Authorization = "Basic dXNlcjpwYXNzd29yZA=="
}
};
var result = svc.CreateTransactionWithPaymentMethod(batch);
PayFurlClient payFurlClient = new PayFurlClient.Builder()
.withEnvironment("sandbox")
.withSecretKey("secret_key")
.build();
BatchApi batchApi = payFurlClient.getBatchApi();
NewTransactionPaymentMethod newTransactionPaymentMethod = new NewTransactionPaymentMethod.Builder()
.withCount(1)
.withDescription("Test")
.withBatch("PaymentMethodId,Amount,Currency,Reference
fc3fb5ff9e3b42c290c740c8772b40aa,123.4,AUD,reference")
.withWebhook(new WebhookConfig("https://webhook.site/1752c235-7693-466b-9710-f6ca4e0f8255", "Basic dXNlcjpwYXNzd29yZA=="))
.build();
BatchStatus batchStatus = batchApi.createTransactionWithPaymentMethod(newTransactionPaymentMethod);
$svc = new Batch();
$batch = [
'Count' => 1,
'Description' => 'Test',
'Batch' => "PaymentMethodId,Amount,Currency,Reference\nfc3fb5ff9e3b42c290c740c8772b40aa,123.4,AUD,reference",
'Webhook' => [
'Url' => 'https://webhook.site/1752c235-7693-466b-9710-f6ca4e0f8255',
'Authorization' => 'Basic dXNlcjpwYXNzd29yZA=='
]
];
$result = $svc->CreateTransactionWithPaymentMethod($batch);
Get Status of Batch
The Status
field can have one of the following values: RECEIVED
, CREATED
, IN_PROGRESS
, SUCCESS
, FAILED
.
RECEIVED
: The batch was received by the server.CREATED
: The batch transactions were prepared for processing.IN_PROGRESS
: The batch transactions are currently being processed.SUCCESS
: The batch transactions were processed successfully.FAILED
: The batch transactions processing failed. Contact support for more information.
The Progress
field indicates the percentage of the batch processing. Its value ranges from 0 to 1.
To get the status of a batch:
- curl
- C#
- Java
- PHP
curl -X GET --location "https://sandbox-api.payfurl.com/batch/{{batchId}}/status" \
-H "x-secretkey: <secret_key>" \
-H "Content-Type: application/json"
var svc = new payfurl.sdk.Batch();
var result = svc.GetBatchStatus("123");
PayFurlClient payFurlClient = new PayFurlClient.Builder()
.withEnvironment("sandbox")
.withSecretKey("secret_key")
.build();
BatchApi batchApi = payFurlClient.getBatchApi();
BatchStatus batchStatus = batchApi.getBatchStatus("123");
$svc = new Batch();
$result = $svc->GetBatchStatus(['BatchId' => '123']);
Get Batch Information
The received batch information includes Results
field with information about batch transactions.
Results
is a csv-like string with the following format: PaymentMethodId,Amount,Currency,Reference,Status,TransactionId,FailureReason,GatewayErrorCode,GatewayErrorResponse,IsRetryable
.
The Status
field can have one of the following values: RECEIVED
, CREATED
, IN_PROGRESS
, SUCCESS
, FAILED
.
CREATED
: The batch transactions were prepared for processing.IN_PROGRESS
: The batch transactions are currently being processed.SUCCESS
: The batch transactions were processed successfully.TransactionId
field contains the transaction ID.FAILED
: The batch transactions processing failed.FailureReason
field contains the reason for the failure.GatewayErrorCode,GatewayErrorResponse,IsRetryable
fields contain information about the gateway error.
To get batch information:
- curl
- C#
- Java
- PHP
curl -X GET --location "https://sandbox-api.payfurl.com/batch/{{batchId}}" \
-H "x-secretkey: <secret_key>" \
-H "Content-Type: application/json"
var svc = new payfurl.sdk.Batch();
var result = svc.GetBatch("123");
PayFurlClient payFurlClient = new PayFurlClient.Builder()
.withEnvironment("sandbox")
.withSecretKey("secret_key")
.build();
BatchApi batchApi = payFurlClient.getBatchApi();
BatchData batchData = batchApi.getBatch("123");
$svc = new Batch();
$result = $svc->GetBatch(['BatchId' => '123']);
To explore more about batch processing, refer to the API documentation.