Skip to main content

Subscription end user update

Overview

Use the updateSubscriptionEndUser method to update the details of a subscription’s end user. This method changes per-subscription end user data and not customer details.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

SubscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

EndUser

Required (Object)

  Use this object to update end user information.

Response

Parameters Type/Description

Boolean

true or false depending on whether the changes were successful or not.

Request


<?php
$host   = "https://api.2checkout.com";
$client = new SoapClient($host . "/soap/4.0/?wsdl", array(
    'location' => $host . "/soap/4.0/",
    "stream_context" => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false
        )
    ))
));

function hmac($key, $data)
{
    $b = 64; // byte length for md5
    if (strlen($key) > $b) {
        $key = pack("H*", md5($key));
    }
    
    $key    = str_pad($key, $b, chr(0x00));
    $ipad   = str_pad('', $b, chr(0x36));
    $opad   = str_pad('', $b, chr(0x5c));
    $k_ipad = $key ^ $ipad;
    $k_opad = $key ^ $opad;
    return md5($k_opad . pack("H*", md5($k_ipad . $data)));
}
$merchantCode = "YOUR_MERCHANT_CODE";// your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$key = "YOUR_SECRET_KEY";// your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$now          = gmdate('Y-m-d H:i:s'); //date_default_timezone_set('UTC')
$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash   = hmac($key, $string);
try {
    $sessionID = $client->login($merchantCode, $now, $hash);
}
catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage();
    exit;
}
$subscriptionreference = '8F749B63E7';
$EndUser = new stdClass ();
$EndUser->Address1 = 'Address line 1';
$EndUser->Address2 = 'Address line 2';
$EndUser->City = 'LA';
$EndUser->Company = 'Company Name';
$EndUser->CountryCode = 'us';
$EndUser->Email = 'customerAPI@2checkout.com';
$EndUser->FirstName = 'New Customer';
$EndUser->Language = 'en';
$EndUser->LastName = '2Checkout';
$EndUser->Phone = '1234567890';
$EndUser->State = 'California';
$EndUser->Zip = '90210';
$EndUser->Fax = null;
try {
    $newEndUser = $client->updateSubscriptionEndUser($sessionID, $subscriptionreference, $EndUser);
}
catch (SoapFault $e) {
    echo "newEndUser: " . $e->getMessage();
    exit;
}
var_dump("newEndUser", $newEndUser);

 

Place a renewal order

Overview

Renew a subscription and collect recurring revenue using the 2Checkout Subscription Reference. You can renew subscriptions for both catalog and dynamic products. 

For more details about how to be PCI compliant before accepting CC payments, see this page.

Requirements

To place a renewal order, you need to provide a valid subscription reference number.

Payment methods

You can place renewal orders using the following payment methods:

  • Credit cards
  • PayPal
  • WeChat Pay
  • iDEAL
  • Purchase Order
  • Wire

Use the PaymentDetails object to change the payment method used in the ordering process.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

To place an order with PayPal rather than PayPal Express, use PAYPAL as the type of the PaymentDetails object and send the shopper email and a return URL as part of the PaymentMethod object. See code sample. 

SubscriptionReference

Required (String)

2Checkout generated subscription reference number. E.q. A8C5671BFE.

Response

Edit section 
Parameters Type/Description

Order information

Object

Request

<?php

require ('PATH_TO_AUTH');

$Order = new stdClass();
$Order->Currency = 'USD';
$Order->Language = "EN";
$Order->Country = 'US';
$Order->CustomerIP = '91.220.121.21';
$Order->Source = "sourceAPI.net";
$Order->LocalTime = date('Y-m-d H:i:s');
$Order->Items = array();

/**/
$Order->Items[0]->RenewalInformation = new stdClass();
$Order->Items[0]->RenewalInformation->SubscriptionReference = 'A8C5671BFE'; //subscription used in the renewal process
$Order->Items[0]->Price = new stdClass();
$Order->Items[0]->Price->Type = 'CUSTOM';
$Order->Items[0]->Price->Amount = '10';
$Order->Items[0]->PriceOptions = array('uniqscale1=4');//

$Order->MachineId = "MachineID";

$Order->BillingDetails = new stdClass();
$Order->BillingDetails->Address1 = 'Bil1ing address';
$Order->BillingDetails->Address2 = 'Billing address 2';
$Order->BillingDetails->City = 'Billing City';
$Order->BillingDetails->State = 'Billing State';
$Order->BillingDetails->CountryCode = 'US';
$Order->BillingDetails->Phone = 1231232123;
$Order->BillingDetails->Email = 'customer_details@test.com';
$Order->BillingDetails->FirstName = 'First';
$Order->BillingDetails->LastName = 'Customer';
$Order->BillingDetails->Company = 'Billing Company';
$Order->BillingDetails->Zip = '55104';

$Order->DeliveryDetails = new stdClass();
$Order->DeliveryDetails->Address1 = 'Bil1ing address';
$Order->DeliveryDetails->Address2 = 'Billing address 2';
$Order->DeliveryDetails->City = 'Billing City';
$Order->DeliveryDetails->State = 'Billing State';
$Order->DeliveryDetails->CountryCode = 'US';
$Order->DeliveryDetails->Phone = '12345';
$Order->DeliveryDetails->Email = 'customer_details@test.com';
$Order->DeliveryDetails->FirstName = 'First';
$Order->DeliveryDetails->LastName = 'Customer';
$Order->DeliveryDetails->Zip = "55104";

$Order->PaymentDetails = new stdClass();
$Order->PaymentDetails->Type = "CC";
$Order->PaymentDetails->Currency = $currency;

$Order->PaymentDetails->PaymentMethod = new stdClass();
/**/
$Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111";
$Order->PaymentDetails->PaymentMethod->CardType = "VISA";
$Order->PaymentDetails->PaymentMethod->ExpirationYear = "2019";
$Order->PaymentDetails->PaymentMethod->ExpirationMonth = "12";
$Order->PaymentDetails->PaymentMethod->CCID = "123";
$Order->PaymentDetails->PaymentMethod->HolderName = "John Doe";
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = TRUE;
$Order->PaymentDetails->PaymentMethod->HolderNameTime = 1;
$Order->PaymentDetails->PaymentMethod->CardNumberTime = 1;
/**/

try {
    $newOrder = $client->placeOrder($sessionID, $Order);
}
catch (SoapFault $e) {
    echo "newOrder: " . $e->getMessage();
    exit;
}

var_dump("newOrder", $Order);
Edit section
 

Retrieve product information by code

Overview

Extract information about a product from the Avangate system using its unique ID and the code of the pricing list to which it is assigned to.

Requirements

Parameters

Parameter Type/Description
sessionID Required (string)
  Session identifier, which is the output of the Login method. An exception will be thrown if the values are incorrect.
productCode Required (string)
  The unique product identifier from your system.
pricingListCode Required (string)
  The unique identifier of the pricing list.

Response

Parameter Type/Description
ProductInfo Complet object
  Complex object containing arrays of SimpleProduct and PriceOptions objects.

Request

<?php

require('PATH_TO_AUTH'); // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/02Authentication
require('PATH_TO_setPartner'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/Partner/00Set_partner

$productCode = 'YOUR_PRODUCT_CODE';
$pricingListCode = 'YOUR_PRICING_LIST_CODE';

try {
    $ProductbyCODE= $client->getProductByCode ($sessionID, $productCode, $pricingListCode);
} catch (SoapFault $e) {
    echo "ProductInfo: " . $e->getMessage();
    exit;
}
var_dump ("ProductInfo", $ProductbyCODE);

Errors

Error Description

INVALID_PARTNER

No partner is set.

INVALID_PRODUCT

Provide a valid product ID.

INVALID_PRICING_LIST_CODE

Provide a valid pricing list code.

PARTNER_PRICING_LISTS_NOT_FOUND

There are no pricing lists with the provided code.

PRODUCT_NOT_FOUND

There is no product with this ID in the given pricing list.

 

Values accepted for EXPORT_TIMEZONE_REGION in ISE

Overview

The list below contains the values accepted in the EXPORT_TIMEZONE_REGION parameter for Instant Order Search Export (ISE). Find more about ISE here.

Column "Timezone region value" holds the strings allowed in the ISE service, as a value for the EXPORT_TIMEZONE_REGION parameter. Use column "Offset hour from UTC" to check the difference in timezone between each region and UTC (Coordinated Universal Time). Column "Country / State timezone" references the country / state / capital from each respective timezone region.  

Timezone region value Offset hour from UTC Country / State timezone

Pacific/Midway

-11:00

Midway Island

Pacific/Honolulu

-10:00

Hawaii

America/Anchorage

-09:00

Alaska

America/Tijuana

-08:00

Tijuana

America/Los_Angeles

-08:00

Pacific Time (US & Canada)

America/Denver

-07:00

Mountain Time (US & Canada)

America/Chihuahua

-07:00

Chihuahua

America/Chihuahua

-07:00

Chihuahua

America/Phoenix

-07:00

Arizona

America/Regina

-06:00

Saskatchewan

America/Mexico_City

-06:00

Guadalajara

America/Mexico_City

-06:00

Guadalajara

America/Chicago

-06:00

Central Time (US & Canada)

America/Managua

-06:00

Central America

America/Indiana/Knox

-05:00

Indiana (East)

America/New_York

-05:00

Eastern Time (US & Canada)

America/Bogota

-05:00

Bogota

America/Caracas

-04:30

Caracas

America/Santiago

-04:00

Santiago

America/Manaus

-04:00

Manaus

America/La_Paz

-04:00

La Paz

America/Halifax

-04:00

Atlantic Time (Canada)

America/St_Johns

-03:30

Newfoundland

America/Montevideo

-03:00

Montevideo

America/Godthab

-03:00

Greenland

America/Guyana

-03:00

Georgetown

America/Argentina/Buenos_Aires

-03:00

Buenos Aires

America/Sao_Paulo

-03:00

Brasilia

Atlantic/South_Georgia

-02:00

Mid-Atlantic

Atlantic/Cape_Verde

-01:00

Cape Verde Is.

Atlantic/Azores

-01:00

Azores

Africa/Casablanca

+00:00

Casablanca

Europe/London

+00:00

Greenwich Mean Time : Dublin

Africa/Monrovia

+00:00

Monrovia

Europe/Amsterdam

+01:00

Amsterdam

Europe/Belgrade

+01:00

Belgrade

Europe/Brussels

+01:00

Brussels

Europe/Sarajevo

+01:00

Sarajevo

Africa/Porto-Novo

+01:00

West Central Africa

Asia/Amman

+02:00

Amman

Europe/Bucharest

+02:00

Athens

Asia/Beirut

+02:00

Beirut

Africa/Cairo

+02:00

Cairo

Africa/Harare

+02:00

Harare

Europe/Helsinki

+02:00

Helsinki

Asia/Jerusalem

+02:00

Jerusalem

Europe/Minsk

+02:00

Minsk

Africa/Windhoek

+02:00

Windhoek

Asia/Baghdad

+03:00

Baghdad

Asia/Kuwait

+03:00

Kuwait

Europe/Moscow

+03:00

Moscow

Africa/Nairobi

+03:00

Nairobi

Asia/Tbilisi

+03:00

Tbilisi

Asia/Tehran

+03:30

Tehran

Asia/Muscat

+04:00

Abu Dhabi

Asia/Baku

+04:00

Baku

Asia/Baku

+04:00

Caucasus Standard Time

Indian/Mauritius

+04:00

Port Louis

Asia/Yerevan

+04:00

Yerevan

Asia/Kabul

+04:30

Kabul

Asia/Yekaterinburg

+05:00

Ekaterinburg

Asia/Karachi

+05:00

Islamabad

Asia/Tashkent

+05:00

Tashkent

Asia/Kolkata

+05:30

Chennai

Asia/Colombo

+05:30

Sri Jayawardenepura

Asia/Kathmandu

+05:45

Kathmandu

Asia/Almaty

+06:00

Almaty

Asia/Dhaka

+06:00

Astana

Asia/Rangoon

+06:30

Yangon (Rangoon)

Asia/Bangkok

+07:00

Bangkok

Asia/Krasnoyarsk

+07:00

Krasnoyarsk

Asia/Hong_Kong

+08:00

Beijing

Asia/Irkutsk

+08:00

Irkutsk

Asia/Kuala_Lumpur

+08:00

Kuala Lumpur

Australia/Perth

+08:00

Perth

Asia/Taipei

+08:00

Taipei

Asia/Tokyo

+09:00

Osaka

Asia/Seoul

+09:00

Seoul

Asia/Yakutsk

+09:00

Yakutsk

Australia/Adelaide

+09:30

Adelaide

Australia/Darwin

+09:30

Darwin

Australia/Brisbane

+10:00

Brisbane

Australia/Canberra

+10:00

Canberra

Pacific/Guam

+10:00

Guam

Australia/Hobart

+10:00

Hobart

Asia/Vladivostok

+10:00

Vladivostok

Asia/Magadan

+11:00

Magadan

Pacific/Auckland

+12:00

Auckland

Pacific/Fiji

+12:00

Fiji

 

Product group

Overview

Use the ProductGroup object to create/add and update/edit product groups.

Parameters

Parameters Type/Description

Name

Required (string)

 

The name of the product group.

TemplateName

Optional (string)

 

Leave empty to assign the Default Template to the product.

 

Or use the name of an active shopping cart template.

Description

Optional (string)

 

The description of the product group.

 

UnitPrice Object structure

Structure

Parameters Type/Description
Currency String
  Partner currency ISO code - ISO 4217.
NetPricePerUnit Double
  The net price per unit of product, representing the costs incurred by the partner, minus the margin and taxes (if applicable).
PartnerMarginPerUnit Double
  New purchase partner margin calculated per unit of product.
VatPerUnit Double
  VAT or sales taxes applied to the value of a single product unit.

 

Create products and sync to Salesforce

Overview

Before creating and sending a proposal (offer) you first need to create your products in the Merchant Control Panel and then sync them to Salesforce by following the instructions below.

In the Verifone CPQ app, under Products, you can find the products that are synced with 2Checkout.

Only products synced in 2Checkout can be used to send out offers. Using products created in Salesforce to send an offer will result in error on the Add Line Item page.

Workflow

For this integration you need your credentials for both the Merchant Control Panel and the Salesforce admin at hand.

1. Log in to your 2Checkout Merchant Control Panel.

2. Navigate to Setup → Products and click on the Add product button.

create products in Merchant Control Panel and sync to Salesforce_1.png

create products in Merchant Control Panel and sync to Salesforce_2.png

3. Add the product:

  • Name
  • Code 
  • Product Group (You can create a B2B group by clicking on View all product groups and then on the Add product group button.)
  • Tax category (Set the Product Tax Category to one of the following: Electronically Delivered Software, Digital Products or SaaS.)
  • Product External Reference (if the case)

4. Fill in the rest of the product fields with any options you want and click on the Add product button at the bottom of the page to save it.

5. Edit the created product by clicking on the Edit icon, as shown in the image below:

  • Edit pricing and price options
  • Edit Renewal & upgrade as needed
  • Disregard fulfillment

create products in Merchant Control Panel and sync to Salesforce_3.png

create products in Merchant Control Panel and sync to Salesforce_4.png

6. Log in to the Salesforce admin panel.

7. Create an Opportunity, by navigating to the Opportunities tab and clicking on New Opportunity. 

create products in Merchant Control Panel and sync to Salesforce_5.png

8. Create an Offer, by clicking on Offers → New Offer.

create products in Merchant Control Panel and sync to Salesforce_6.png

9. On the next page, search and select the parent opportunity.

create products in Merchant Control Panel and sync to Salesforce_7.png

10. Fill in the details of the offer and click on the Add Line Item button.

create products in Merchant Control Panel and sync to Salesforce_8.png

11. Search and select the product you have created earlier in the Merchant Control Panel.

create products in Merchant Control Panel and sync to Salesforce_9.png

12. Once you find the created product, you can start editing it.

create products in Merchant Control Panel and sync to Salesforce_10.png

Add product to cart

Overview

Use this method to add products to cart, during the current cart session.

Requirements

This method requires you to set a specific partner using setPartner.

Parameters

Parameter Type/Description
sessionID Required (string)
  Session identifier, which is the output of the Login method. An exception is thrown if the values are incorrect.
productId Required (integer)
  Unique product identifier from the 2Checkout system.
pricingListCode Required (string)
  The unique identifier of a partner price list.
quantity Optional (integer)
 

Defines the amount of product units to be ordered. If no quantity info is provided, the minimum available number of units is included in the order.

 

If the quantity provided is not available for purchase, such as in the case of volume discounts, en error message is displayed.

 

When NULL, quantity = 1 is added automatically.

priceOptions Optional (StringArray)
 

Array of price options codes. If no price options info is provided, the default, required pricing options of the product are ordered. These identifiers mark the individual options inside pricing options configuration groups.

 

Can be NULL.

Response

Parameter Type/Description
Result Boolean
  True or false

Request

<?php

require ('PATH_TO_AUTH');  // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/02Authentication
require ('PATH_TO_SET_PARTNER'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/06Reference/Partner/00Set_partner

$productId = 'YOUR_PRODUCT_ID';
$pricingListCode = 'YOUR_PRICING_LIST_CODE';
$quantity = YOUR_PRODUCT_QUANTITY;
$priceOptions = array(
'PRICING_OPTION_1',
'PRICING_OPTION_2'
);

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addProduct',
'params' => array($sessionID, $productId, $quantity, $priceOptions, $pricingListCode)
);

var_dump (callRPC((Object)$jsonRpcRequest, $host));

Errors

Error Description

INVALID_PARTNER

No partner is set.

PRODUCT_ERROR

Invalid product ID.

PARTNER_PRICING_LISTS_NOT_FOUND

There are no pricing lists with the provided code.

PRODUCT_NOT_FOUND

There is no active product with the specified product ID in the given pricing list.

INVALID_QUANTITY

Quantity is not available for purchase.

 

Error handling for issueRefund

Overview

Learn how to tackle the common errors that may arise when issuing refunds via 2Checkout API.

Common error codes 

Error code Description

ORDER_REF missing or format incorrect 

The order reference number was not provided, or has an invalid format. Check the order reference provided.

ORDER_AMOUNT missing or format incorrect 

Refundable amount was not provided, or it has an invalid format. Check the order amount provided.

Order already canceled 

Order is already canceled.

Invalid ORDER_REF 

The order reference number is not correct. Check the order reference provided.

Invalid ORDER_AMOUNT 

The refundable amount is invalid. Check the order amount provided.

PRODUCTS_CODES missing or format incorrect 

Products codes were not provided, or have an invalid format. Check the product codes provided.

PRODUCTS_QTY missing or format incorrect 

Product quantity was not provided, or has an invalid format. Check the product quantity provided.

Invalid PRODUCTS_QTY 

The product quantity is not correct. Check the product quantity provided.

You have already placed a Total refund for this order. 

Order has been already refunded in total. Check again the current refund status of the order.

You already have a pending refund request. 

The order already has a pending refund request. Before issuing a new refund, the current request needs to be settled.

The maximum refundable amount for this order has been exceeded. 

The refundable amount cannot exceed the order amount. Check the refundable amount.

You cannot place a refund request due to the order's current status. 

The order needs to be in FINISHED status, before being refunded. Check the current order status.

You cannot place a refund request due to the order's payment details. 

The current customer payment details do not allow refund requests. Contact 2Checkout for additional details.

The allowed period to request a new refund for this order has expired. 

You are not able to issue a refund for this order at this moment. Contact 2Checkout for additional details.

Multiple refunds are not supported by this order's payment type. 

The payment method on this order does not allow multiple refunds.

Refunding not supported for this Cross Vendor Sale order. 

The order type does not allow refunds. Contact 2Checkout for additional details.

Order total is negative. 

The order total is negative. Send only positive order amounts.

You cannot place a refund request due to the order's approval status. 

The order cannot be refunded due to its approval status. Contact 2Checkout for additional details.

Multiple refunds are not supported by this order's terminal. 

The order cannot be refunded to due to its payment method terminal. Contact 2Checkout for additional details.

Partial reverse is not supported. 

Partial refunds are not supported on this payment method. Contact 2Checkout for additional details.

Invalid product type. Refunds are available only for the following product types: REGULAR / BUNDLE / MEDIA / DOWNLOAD_INSURANCE, but not for DISCOUNT / SHIPPING. 

The product item cannot be refunded. Contact 2Checkout for additional details.

You cannot request a refund because a chargeback dispute was open for the order. 

You cannot issue a refund for orders that have a chargeback dispute open. 

Invalid REFUND_REASON

The refund reasons provided is not valid. In case you have custom refund reasons created, send one of their names as values. 

Partial refund

Overview

Use the issueRefund method to issue a partial refund for an order processed by 2Checkout.

Requirements 

The payment for the refundable order needs to be collected.

You cannot issue a refund for an amount higher than the total order amount.

We recommend you create a new order with placeOrder to have one that can be refunded.

The order’s status must be ’COMPLETE’ and it should have a TotalPrice > 0.

The OrderDate cannot be older than a year from the current date.

To obtain the LineItemReference, use the getOrder method: https://knowledgecenter.2checkout.com/API-Integration/JSON-RPC_API_6.0/Reference/14Retrieve-an-order

Request

<?php

/**
 * @throws JsonException
 */
function callRPC($Request, $host) {
    $curl = curl_init($host);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($curl, CURLOPT_VERBOSE, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($curl, CURLOPT_SSLVERSION, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
    $RequestString = json_encode($Request, JSON_THROW_ON_ERROR);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);

    $ResponseString = curl_exec($curl);

    if (!empty($ResponseString)) {
        echo($ResponseString);
        $Response = json_decode($ResponseString, false, 512, JSON_THROW_ON_ERROR);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            echo("Method: {$Request->method}" . PHP_EOL);
            echo("Error: {$Request->error}" . PHP_EOL);
        }
    } else {
        return null;
    }
    return null;
}

$host = 'https://api.avangate.com/rpc/6.0/';

$merchantCode = "MERCHANT_CODE"; // your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$key = "SECRET_KEY"; // your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php

$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$algo = "sha256";
$hash = hash_hmac($algo, $string, $key);

$i = 1;

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = array($merchantCode, gmdate('Y-m-d H:i:s'), $hash, $algo);
$jsonRpcRequest->id = $i++;

try {
    $sessionID = callRPC($jsonRpcRequest, $host);
    echo("Auth token: {$sessionID}" . PHP_EOL);
} catch (JsonException $e) {
    echo("Error: {$e->getMessage()}" . PHP_EOL);
}

$orderReference = "73152871";

$items = [];
$item = new stdClass();
$item->Quantity = 1;
$item->LineItemReference = "a439c84a4b1e8ad1d7bf38407f5ea7473433ce7b";
$item->Amount = 29.99;

$items[] = $item;

$comment = "This is a comment";
$reason = "Fraud";

$jsonRpcRequest          = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method  = 'issueRefund';
$jsonRpcRequest->params  = array($sessionID, $orderReference, null, $items, $comment, $reason);
$jsonRpcRequest->id      = $i++;

$partialRefund = callRPC($jsonRpcRequest, $host);

var_dump ($partialRefund); 

Response

Response Type/Description
Boolean

TRUE is the refund was processed successfully

FALSE otherwise

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo