Preloader

Initiate Payment

Initiates a new payment transaction.

Endpoint: POST {{base_url}}/api/paymentApi/v2
Parameter Type Details
amount decimal Your Amount , Must be rounded at 2 precision.
merchant_email string Enter your merchant email
client_id string Enter your merchant client Id
client_secret string Enter your merchant client secret
mode string Enter your merchant api mode (sandbox|production)
user_email string Enter your user email
first_name string Enter user first name
last_name string Enter your user last name
mobile_code string Enter user mobile code
mobile string Enter user mobile number
country string Enter country name
city string Enter city Name
zip string Enter zip code
Currency Code string Enter currency code, USD|EUR
return_url: string Enter your return or success URL
cancel_url: string Enter your cancel or failed URL
custom: string (optional) Transaction id which can be used your project transaction
                        
                            Request Example (guzzle)
                            

<?php
require_once('vendor/autoload.php');
// Instantiate Guzzle HTTP client
$client = new GuzzleHttp\Client();
// Define API URL
$api_url = {{base_url}}'/api/paymentApi/v2';
// Define success and cancel URLs
$success_url = 'http://your_domain.com/successUrl';
$cancel_url = 'http://your_domain.com/cancelUrl';
// Prepare POST request parameters
$post_data = [
'form_params' => [
  'success_url' => $success_url,
  'cancel_url' => $cancel_url,
  'custom' => '123456789ABCD',
  'amount' => 100.00,
  'merchant_email' => 'merchant@gmail.com',
  'client_id' => 'your client id',
  'client_secret' => 'your client secret',
  'mode' => 'sandbox',
  'user_email' => 'user@gmail.com',
  'first_name' => 'user firstName',
  'last_name' => 'user lastName',
  'mobile_code' => "+16",
  'mobile' => '04751886',
  'country' => 'Germany',
  'city' => 'Berlin',
  'zip' => '10115',
  'currency_code' => 'USD',
 ]
];
// Send POST request
$response = $client->post($api_url, $post_data);
// Handle response as needed
echo $response->getBody();
?>
                    
                        
**Response: SUCCESS (200 OK)**
{
 "code": "200",
 "status": "success",
 "message": "api call successful",
 "custom": "123456789ABCD",
 "merchant_email": "merchant@gmail.com",
 "username": "userFirstName userLastName",
 "email": "user@gmail.com",
 "token":"MRmT3KeYT2BWMAyGhqEfuw4tOYOfGXKeyKq",
 "payment_url":"https://www.payitwise.co.paymentApi/initiate-payment/v2",
}

//on success redirect to
$response['payment_url'] .'?token='.$response['token']
                    
                        
**Response: ERROR (422 FAILED)**
{
 "code": "422",
 "status": "error",
 "message": { "fieldName:["error message"]" },
 "custom": "123456789ABCD",
 "merchant_email": "merchant@gmail.com",
 "username": "userFirstName userLastName",
 "email": "user@gmail.com",
}