---
updatedAt: 2025-07-23T05:15:13.000Z
agentTools:
  projectIndex: https://rivhit-api.readme.io/llms.txt
---

# Payment Page Process With IPN

```php PHP
<?php
  


// GetUrl Request
  
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://testicredit.rivhit.co.il/API/PaymentPageRequest.svc/GetUrl",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "accept: application/json",
    "content-type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}


//IPNListener

$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$IPNPost = array();
foreach ($raw_post_array as $keyval) {
    $keyval = explode ('=', $keyval);
    if (count($keyval) == 2)
       $IPNPost[$keyval[0]] = urldecode($keyval[1]);
}


// Verify Request

$postData = array('GroupPrivateToken' => 'a1408bfc-18da-49dc-aa77-d65870f7943e',
                        'SaleId'=>$IPNPost['SaleId'],
                        'TotalAmount'=>$IPNPost['TransactionAmount']
                        );
 
 
$jsonData = json_encode($postData);
$curlObj = curl_init();
 
curl_setopt($curlObj, CURLOPT_URL, 'https://testicredit.rivhit.co.il/API/PaymentPageRequest.svc/Verify');
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
 
$response = curl_exec($curlObj);

//change the response json string to object
$json = json_decode($response);
curl_close($curlObj);
 
// inspect IPN validation result and act accordingly
if ($json->Status == 'VERIFIED'){

////Do things after a payment is completed: 
//Change order status
//Document URL and credit card details in the order. 
//
  
}

```

```json JSON
{
  "GroupPrivateToken": "a1408bfc-18da-49dc-aa77-d65870f7943e",
  "Items": [
    {
      "Id": 0,
      "UnitPrice": 10,
      "Quantity": 1,
      "Description": "item test"
    }
  ],
  "IPNURL": "https://47d0-213-57-20-226.ngrok-free.app/test/ipn_listener.php",
  "RedirectURL": "https://www.icredit.co.il/",
  "EmailAddress": "a@a.com",
  "CustomerLastName": "Israeli",
  "CustomerFirstName": "Moshe",
  "Address": "Ben Yehuda 1",
  "City": "Tel Aviv",
  "Order": "12345",
  "PhoneNumber": "054-4444444"
}
```

```json Response Example
//GetUrl Response
{
  "DebugMessage": null,
  "PrivateSaleToken": "eedf4431-9e4d-4329-a6be-9791a92a1980",
  "PublicSaleToken": "aa11ceb8-eadc-45cd-b3ba-2e8141b0d185",
  "Status": 0,
  "URL": "https://testicredit.rivhit.co.il/payment/PaymentItems.aspx?GroupId=1beb572a-0db9-4854-908b-cdf7378e49c9&Token=aa11ceb8-eadc-45cd-b3ba-2e8141b0d185"
}


//Verify Response
{
  "Status": "VERIFIED"
}
//or
{
  "Status": "NOTVERIFIED"
}
```

# GetUrl Method - Create a payment URL

<!-- php@3-30 -->
<!-- json@ -->

Create a GetUrl request and implement the URL in  the website/system.

Basic request should include:

- GroupPrivateToken (payment page id)

- Items array - with the payment amount

- Customer details -  
  CustomerLastName, CustomerFirstName, EmailAddress, PhoneNumber atc. 

Other recommended values:

- RedirectURL - a 'Thank You' page to return the customer back to the website and also display the order details.

- IPNURL -  
  In order to activate the IPN service send the IPN link in the merchant website/system server side to receive the payment details after the charge is successful.

- Order - if the website manages orders.

# IPNListener - on the server side

<!-- php@35-44 -->
<!-- json@ -->

In order to receive the IPN array with the payment details there needs to be a Listener on the server side ready and open to receive the IPN message from iCredit server. 

- In testing it is possible to use a temporary address to get the IPN with Ngrok or a similar tool before coding the IPNListener part.

The IPNListener in the example is currently in PHP.

# Verify Method - Validate an IPN messege

<!-- php@43 -->
<!-- json@ -->

After the IPN is received with the payment info it is important to validate it's source, in order to prevent a fraud or an orders mixed up.

Verify method will include 3 values: 

- GroupPrivateToken - Same as the value in the GetUrl request.
- SaleId - the sale identifier.
- TotalAmount - The sale total amount.

Optional Responses:

- "VERIFIED"- A valid response

The order can be marked as paid -continue with the actions needed, for example:  

1. Change order status
2. Update document URL and credit card details in the order.

- "NOTVERIFIED" - Not a valid response 

The order is not paid (no action is needed)

# Implement the Redirect URL on the system/website

<!-- php@ -->
<!-- json@ -->

When the customer is redirected to the URL it will check with the server if the order is paid - in that case the order details can be display for the customer.