Approve Transaction

This API is used to approve a transaction by validating the provided merchant ID, token, and payment ID. If the transaction is valid and the website is active, it will be marked as used.

Endpoint Details

  • URL: /api/transaction/approve

  • Method: POST

  • Content-Type: application/json

Request Parameters

Parameter

Type

Required

Description

merchant_id

string

Yes

The unique identifier of the merchant's website. Must exist in the websites table.

token

string

Yes

The transaction token associated with the payment.

payment_id

string

Yes

The unique identifier of the payment transaction.

Validation Rules

  • merchant_id must exist in the websites table.

  • token and payment_id must be valid strings.

Response

Success Response

Status Code: 200 OK

{
    "status": "success",
    "message": "Transaction approved successfully.",
    "data": {
        "token": "example_token",
        "payment_id": "example_payment_id",
        "updated_at": "2025-03-12T12:00:00Z"
    }
}

Error Responses

403 Forbidden - Inactive Website

Status Code: 403

{
    "status": "error",
    "message": "The website is not active.",
    "data": []
}

404 Not Found - Invalid or Used Transaction

Status Code: 404

{
    "status": "error",
    "message": "The requested transaction does not exist or has already been used.",
    "data": []
}

400 Bad Request - Unsuccessful Transaction

Status Code: 400

{
    "status": "error",
    "message": "The related transaction is not successful.",
    "data": []
}

Notes

  • The approveTransaction API ensures that the transaction belongs to an active website.

  • If the transaction is already used, it cannot be approved again.

  • The updated_at field in the success response indicates when the transaction was marked as used.

Example Request

curl -X POST "https://pay.oxichange.com/api/approveTransaction" \
     -H "Content-Type: application/json" \
     -d '{
         "merchant_id": "123456",
         "token": "abcde12345",
         "payment_id": "pay_78910"
     }'

Example Implementation

$response = Http::post('https://pay.oxichange.com/api/approveTransaction', [
    'merchant_id' => '123456',
    'token' => 'abcde12345',
    'payment_id' => 'pay_78910'
]);

$data = $response->json();
print_r($data);

Last updated