Skip to main content

Add product coupon

Overview

Apply discount coupons to products added to the shopping cart.

Requirements

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.
coupon Required (String)
  The coupon/voucher code for a promotion impacting a product added to cart.

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/SOAP/02Authentication
require('PATH_TO_setPartner'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/Partner/00Set_partner
require('PATH_TO_addProduct'); // addProduct example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/08Place_an_order/00Add_product_to_cart

$couponCode = 'YOUR_CUPON_CODE';

try {
    $SetCoupon = $client->setCoupon ($sessionID, $couponCode);
} catch (SoapFault $e) {
    echo "Promotion: " . $e->getMessage();
    exit;
}
var_dump ("Promotion ", $SetCoupon);

Errors

Error Description

EMPTY_CART

The shopping cart is empty.

INVALID_COUPON_CODE

The coupon code is empty or invalid.

 

Search shipping methods

Overview

Use searchShippingMethods to retrieve information on the shipping methods currently defined on your account.

Search filters

Use the parameters below to filter the results of your search for shipping methods.

Parameter Type/Description
Name

String / Optional

Name of the shipping method.

Codes

Array of strings / Optional

Codes assigned to the shipping methods.

Countries

Array of strings / Optional

Countries to which the shipping method is assigned.

Active

Boolean / Optional

TRUE - active shipping methods

FALSE - inactive shipping methods

Pagination

Object / Optional

Control the results pagination.

  Page

Integer / Optional

Number of pages to display the results

  Limit

Integer / Optional

Limit the number of results of the search

Sample request

<?php

require ('PATH_TO_AUTH'); // authentication call

$SearchOptions = new \stdClass();
$SearchOptions->Name = 'ShippingMethodName'; // search for a specific shipping method
$SearchOptions->Codes = ['Code1', 'Code2', 'Code3']; // array of shipping method codes
$SearchOptions->Countries = ['US', 'UK', 'AU']; // array of country codes
$SearchOptions->Active = true; // only active shipping methods
$SearchOptions->Pagination = new \stdClass();
$SearchOptions->Pagination->Page = 1; // set display pages
$SearchOptions->Pagination->Limit = 200; // limit the results

try {
    $shippingMethods = $client->searchShippingMethods($sessionID, $SearchOptions);
}
catch (SoapFault $e) {
    echo "shippingMethods: " . $e->getMessage();
    exit;
}
var_dump("shippingMethods", $shippingMethods);

Response

Parameter Type/Description
ShippingMethod

Object

 

Subscription

Overview

The object below is returned directly or within a successful response from the following API requests:

Retrieve a subscription             Search subscriptions            Retrieve customer's subscriptions          Retrieve specific subscriptions

Subscription object

Parameters Type/Description

SubscriptionReference

String

 

Unique, system-generated subscription identifier.

StartDate

String

 

Subscription start date(YYYY-MM-DD) - StartDate is mandatory when importing subscription data. If you changed the time zone for the Avangate API by editing system settings under Account settings, then the StartDate you provide must be in accordance with your custom configuration.

ExpirationDate

String

 

Subscription expiration date(YYYY-MM-DD) - ExpirationDate is mandatory when importing subscription data. If you changed the time zone for the Avangate API by editing system settings under Account settings, then the ExpirationDate you provide must be in accordance with your custom configuration.

RecurringEnabled

Boolean

 

Possible values:

TRUE – recurring billing/automatic subscription renewals enabled

FALSE– recurring billing/automatic subscription renewals disabled

SubscriptionEnabled

Boolean

Possible values:

TRUE –subscription enabled

FALSE–subscription disabled

Product

Required (object)

 

The product for which Avangate generated the subscription. Details below.

 

ProductCode

String

 

 

Unique product identifier that you control.

 

ProductId

Int

 

 

Unique, system-generated product identifier.

 

ProductName

String

 

 

Product name.

 

ProductQuantity

Int

 

 

Ordered number of units.

 

ProductVersion

String

 

 

Product version.

 

PriceOptionCodes

Array

 

 

The product options codes the customer selected when acquiring the subscription. Pricing options codes are case sensitive.

EndUser

Object

 

The end user of the subscription. Details below.

 

Person

Object

 

 

FirstName

String

 

 

 

End user's first name

 

 

LastName

String

 

 

 

End user's last name

 

 

CountryCode

String

 

 

 

End user country code [ISO3166-1 Alpha 2].

 

 

State

String

 

 

 

End user state.

 

 

City

String

 

 

 

End user city.

 

 

Address1

String

 

 

 

End user first address line.

 

 

Address2

String

 

 

 

End user second address line.

 

 

Zip

String

 

 

 

End user zip code.

 

 

Email

String

 

 

 

End user email address.

 

 

Phone

String

 

 

 

End user phone number.

 

 

Company

String

 

 

 

Company name.

 

 

Fax  

String

 

 

End user fax.

 

 

Language  

String

 

 

Language [ISO639-2] the Avangate system uses for communications.

SKU

String

 

Stock keeping unit you defined.

DeliveryInfo

Object

 

The object contains information about the delivery/fulfillment made to the customer.

 

Description

String

 

 

Delivery description.

 

Codes

Array of objects

 

 

Code

String

 

 

 

Activation key/license code of the first order from this subscription. Use getSubscriptionHistory method if you want to retrieve the activation keys/license codes for all orders belonging to a subscription.

 

 

Description

String

 

 

 

Code description for dynamic lists from your key generator. 

 

 

ExtraInfo

Object

 

 

 

Info set by your key generator for dynamic lists only.

 

 

 

CodeExtraInfo

Object

 

 

 

Type

String

 

 

 

Label

String

 

 

 

Value

String

 

 

File

Array of objects

 

 

 

Content

String

 

 

 

 

Content of the file (base64 encoded).

 

 

 

ContentLength

Int

 

 

 

 

File size.

 

 

 

Filename

String

 

 

 

 

The name of the delivered file.

 

 

 

FileType

String

 

 

 

 

The type of the delivered file.

ReceiveNotifications

Boolean

 

1 – Subscribe: Avangate sends subscription notifications to the end user.

0 – Unsubscribe – Avangate does not send subscription notifications to the end user.

Lifetime

Boolean

 

Possible values:

  • True – the subscription is evergreen

False – the subscription has a recurring billing cycle less than or equal to three years.

PartnerCode

String

 

  • Empty: for ecommerce orders
  • Partner Code

AvangateCustomerReference

Int

 

Unique, system-generated customer identifier.

ExternalCustomerReference

String

 

Customer identifier that you control.

TestSubscription

Boolean

 

True for test subscriptions, false otherwise.

IsTrial

Boolean

 

True for trial subscriptions, false otherwise.

MerchantCode String
  Unique, system-generated ID in the Avangate system.

 

Recurring payment failed (dunning notification)

Overview

Use the variables in the list below to customize the Recurring payment failed (dunning notification) shopper email notifications according to your needs.

Check the 'Mandatory' column to see the variables that are required in your customized version of the e-mail.

Variable name Description Test Value Mandatory

BUSINESS_COMPANY

Avangate company name

Avangate Yes

BUSINESS_SUPEMAIL

Avangate support email address

0 No

BUSINESS_WEBSITE

Avangate website

0 No

COMMERCIALNAME

Merchant's commercial name

0 Yes

CURRENCY

Order billing currency

EU Yes

CURRENCY_ORIGINAL

Original order currency (applicable to refunds)

0 No

ENCRYPTED_MERCHANT_CODE

Encrypted merchant code

0 No

FIRSTNAME

Shopper's first name used on the delivery information

John No
GATEWAY_ERROR_CODE Gateway error code

GW_PROCESSING_ERROR

See the full list of Possible Values

No
GATEWAY_ERROR_MESSAGE Reason why the transaction failed. (e.g. Invalid card, insufficient funds) Error processing the card transaction. The card account has not been debited. Card data is invalid or incomplete. No

GENERALTOTAL

Total order price

0 Yes

HAS_RENEWAL_PRODUCTS

Flag that indicates whether at least one product has renewal settings

0 No

IS_RENEWAL

Flag that indicates whether at least one product has renewal settings

0 No

IS_TRIAL_RENEWAL

Flag that states if the current order comes from a trial conversion

0 No

LASTNAME

Shopper's last name used on the delivery information

0 No

MY_ACCOUNT_URL_UPDATE_CC

URL for updating credit card information in myAccount

0 Yes

NAMES_OF_PRODUCTS

Names of all products in the order, comma separated

0 No

ORDERDATE

Order placement date

11/10/2018 Yes

ORDER_AMOUNT_ORIGINAL

Original order value (applicable to refunds)

0 No

ORDER_DATE_STANDARD_FORMAT

Standard format used for the order placement date

0 No

ORDER_FLOW

Purchase flow used to place the order

0 No

ORDER_STATUS

Order status

0 No

PAYMENT_TYPE_INFO

English payment method name. Includes last four card digits (if applicable).

0 No

PAYTYPE

Identification number for the payment method selected during ordering process

0 No

PRODUCTS

0

0 No

PRODUCTS[index1].BILLING_CYCLE

Indicates how many renewals have been successfully performed so far (on the subscription)

0 No

PRODUCTS[index1].DISCOUNT

Product discount value per product line

0 No

PRODUCTS[index1].INFO

Additional product information defined by merchant when generating buy links

0 No

PRODUCTS[index1].LICENSE_TYPE

Type of purchased subscription

0 No

PRODUCTS[index1].PCODE

Product code.

0 No

PRODUCTS[index1].PID

Product ID number

0 No

PRODUCTS[index1].PNAME

Product name

0 No

PRODUCTS[index1].PRICE

Product unit price

0 No

PRODUCTS[index1].PRODUCT_OPTIONS[index2].OptionText

Ignore internal var.

0 No

PRODUCTS[index1].PROMONAME

Name of the promotion applied to the product

0 No

PRODUCTS[index1].QUANTITY

Purchased product quantity

0 No

PRODUCTS[index1].SHORT_DESCRIPTION

Short product description

0 No

PRODUCTS[index1].TOTAL

Total gross price per product line (before applying discounts)

0 No

PRODUCTS[index1].VAT

VAT/Sales tax value per product line

0 No

PRODUCTS_DATA[index1].IdProduct

Product ID number

0 No

PRODUCTS_DATA[index1].PRODUCT_SHORT_DESCRIPTION

Short product description

0 No

PRODUCTS_LIST

Products data.

0 Yes

PRODUCTS_NO

Number of products in cart

0 No

REFNO

Order reference number

9xxxxxx Yes

RETRYLINK

Payment retry link

0 No

RETRY_LINK

Payment retry link

0 No

TOTALEQUIV

The order amount converted to all the merchant's currencies

0 No

UNSUBSCRIBE_LINK

Shopper unsubscribe link

0 No

UPLOADLINK

File upload link

0 No

UPLOAD_LINK

File upload link

0 No

USER_EMAIL

Email address used by shopper to login/signup to myAccount

example@customer-email.com No

WEBSITE

Website where the shopper placed the order

http://www.software-company-website.com Yes

Cross-sell

Overview

Use the CrossSellCampaign object to retrieve information about the cross-sell campaigns you configured for your account. 

Parameters

CrossSellCampaign

Object

MasterProducts

Array

 

Array of product codes for the items you set to trigger the cross-sell campaign.

DisplayType

String

 

  • cart – Shopping cart
  • review – Review page
  • finish – Thank you page

DisplayInEmail

Boolean

 

True or false depending on whether you set the cross-sell campaign to display in payment receipt emails or not.

Products

Array of objects

 

Details below

CampaignCode

String

 

Unique, system-generated cross-sell campaign code.

Name

String

 

Campaign name.

StartDate

String

 

YYYY-MM-DD. The start date you set for the cross-sell campaign.

EndDate

String

 

YYYY-MM-DD. The end date you set for the cross-sell campaign.

 

Products

Object

ProductCode

String

 

Product code for the item you set as recommended for the cross-sell campaign.

Discount

String

 

Value of the discount. This is a percentage.

DiscountType

String

 

PERCENT – you can only set discounts as a percentage from the product price.

 

Retrieve shipping price

Overview

Use getShippingPrice to retrieve the shipping method and price available, based on a current cart configuration. This API call returns the available shipping methods defined in your Control Panel, together with the fees you configured based on order total amount/weight/country.

Requirements

It's mandatory to have tangible products defined in your Control Panel, to retrieve shipping method and price information.

Parameters

Parameters Type/Description
Items

Object / Required

Contains information on the tangible product added in cart.

  Code

String / Required

Product code defined in the Information tab from the Product level, in the Control Panel.

  Quantity

Integer / Optional

Quantity of the product that is being purchased.

Default value is 1.

BillingDetails

Object / Required

Contains customer billing information.

  CountryCode

String / Required

Two-digits code of customer billing country. Example: 'US'.

DeliveryDetails

Object / Required

Contains customer delivery information.

  CountryCode

String / Required

Two-digits code of customer delivery country. Example: 'US'.

Currency

String / Optional

Three-digits code of purchase currency. Example: 'USD'.

CouponCodes

Array of strings / Optional

Discount codes that can be applied to the purchase.

Sample request

<?php

require ('PATH_TO_AUTH'); // authentication call

$cartItems = [];
$cartItem = new stdClass();
$cartItem->Code = 'my_product_code_1'; // product code defined in the Information tab, at product level
$cartItem->Quantity = 2; // quantity that is being purchased
$cartItems[0] = $cartItem;
$billingDetails = new stdClass();
$billingDetails->CountryCode = 'US'; // billing country
$deliveryDetails = new stdClass();
$deliveryDetails->CountryCode = 'AU'; // delivery country

$currency = 'USD'; // purchase currency

$couponCode = ['TANGIBLEPROMO']; // apply discount to promotion

try {
    $shippingPrice = $client->getShippingPrice($sessionID, $cartItems, $billingDetails, $deliveryDetails, $currency);
}
catch (SoapFault $e) {
    echo "ShippingPrice: " . $e->getMessage();
    exit;
}
var_dump("ShippingPrice", $shippingPrice);

Response

Parameters Type/Description
ShippingPrice

Object

This method returns an object, containing the shipping price available for a certain cart configuration.

Retrieve product tax categories

Overview

Use the getProductTaxCategories method via SOAP API 6.0 to retrieve the available tax categories and manage them for your catalog products.

Request Parameters

Parameters Type Required/Optional Description

sessionID

String Required

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.

ProductTaxCategories

String Required The product tax category for the product.

Request Example

<?php
declare(strict_types=1);

class Configuration
{
    public const MERCHANT_CODE = '';
    public const MERCHANT_KEY = '';
    public const URL = 'http://api.2checkout.com/soap/6.0';
    public const ACTION = 'getTaxCategories';
    public const ADDITIONAL_OPTIONS = null;
    //array or JSON
    public const PAYLOAD = [];
}

class Client
{
    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ) {
        if (is_array($payload)) {
            $payload = json_encode($payload);
        }
        if (!empty($payload)) {
            // SoapClient works with objects(StdClass)
            $payload = json_decode($payload);
        }
        $soapClient = $this->getClient($url);
        $sessionId = $this->getSession($soapClient);
        $args = array_filter([$sessionId, $payload]);

        return $soapClient->$action(...$args);
    }

    public function getClient(string $url): SoapClient
    {
        return new SoapClient(
            $url.'?wsdl',
            [
                'location' => $url,
                'cache_wsdl' => WSDL_CACHE_NONE,
            ]
        );
    }

    public function getSession(SoapClient $client)
    {
        $date = gmdate('Y-m-d H:i:s');
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $string = strlen($merchantCode).$merchantCode.strlen($date).$date;
        $hash = hash_hmac('md5', $string, $key);
        $client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');

        return $client->login($merchantCode, $date, $hash);
    }
}

$client = new Client();
$result = $client->call();
var_dump($result);

Response

Parameters Type/Description
Product Object

Pause subscription

Overview

For a paused subscription 2Checkout suspends all automatic charges for a predefined time period. When subscribers request to pause a subscription, this remains active until the end of the current billing cycle, at which point the subscription will move into a paused status.

Availability

Available free of charge for the 2Subscribe and 2Monetize accounts as part of the base package. Available for merchants on 2Sell accounts only if they have purchased the 2Bill add-on. Contact 2Checkout to request the activation of this functionality.

Benefits

For your Subscribers

Sometimes, for various reasons, your subscribers might want to interrupt their services for a period rather than just canceling them. By using the pause functionality, subscribers will be able to:

  • Pause a subscription to a service they use only infrequently.
  • Pause a subscription to a service they won't have access to for an extended period.
  • Pause a subscription to a seasonal service and renew it when they need to.
  • Pause a subscription to reduce certain costs for a period.

For you (Merchant)

As a merchant, you can benefit in multiple ways by allowing your customers to pause their subscriptions:

  • You can reduce churn​. How? Well, considering an important number of subscribers who plan to re-subscribe after canceling a subscription forget to ​do so, having an automated system in place to take care of this mishap ensures a sizable chunk of these sales would be renewed. Also, when given the alternative to pause a subscription, your customers will be less likely to cancel their subscriptions​.
  • You can reduce spillage​. You may choose to pause certain subscriptions that have payment issues likely to be resolved. This way you can simply pause the access of your subscribers to a certain service until their payment issues are solved, and thus stop spillage.
  • You can get insights on why your customers want to cancel or pause subscriptions and use that reason to offer them customized options for packaging, pricing, promotions, lead management, etc​.
  • Last but not least! You can increase customer satisfaction​, as your subscribers will be able to return to the services they like in a more simple and easier way.

Pause a subscription

Via the Merchant Control Panel

  1. Once the pause feature is enabled for your account, you can pause subscriptions directly from your Merchant Control Panel.
  2. Navigate to the subscription page and click on the Pause button next to the Cancel immediately option. The Pause button is displayed only for subscriptions that are eligible to be paused according to the requirements mentioned below. 
  3. When clicking the Pause button, a pop-up window opens allowing you to define the pause end date (resume date). The same pop-up notifies you of the interval during which the pause subscription is active, and when the next billing date is.
  4. Once the next billing date is reached, the subscription automatically resumes and becomes Active again if billing is successful. If billing is not successful, the status will either be Past-Due or Expired, depending on the previous expiration date, grace period, and resume date.  

Pause periods cannot be greater than 3 years.

Pause subscription events will be logged and displayed in the subscription history section of your Merchant Control Panel.

Via API 6.0

To allow pausing via API, we added the pauseSubscription method, available in the latest API version (6.0) for all protocols (JSON-RPC, SOAP, REST). 

To set pause subscription via API calls, see the following:

Via Shopper myAccount

Your shoppers can pause their subscriptions by themselves via their shopper MyAccount page as part of the churn prevention campaign flow.

Requirements

The following subscriptions cannot be paused: 

  • Inactive, Past-Due, Expired or Canceled subscriptions
  • Trial subscriptions
  • Lifetime subscriptions
  • Channel Manager subscriptions
  • Subscriptions set to manually renew
  • Subscriptions with usage billing pricing

Resume a subscription

Pauses associated with subscriptions can be canceled and subscriptions can be resumed before the pause starts or while the pause is in effect. When the pause is canceled, the following occurs:

  • If the pause is only scheduled, but not in effect
    • If there are other billing attempts scheduled in the time between the cancelation of the pause and the expiration of the subscription (i.e. NOW < Pre-expiration attempt < Expiration), the next billing date is set to the first billing attempt scheduled to happen.
    • If there are no other billing attempts scheduled in the time between the cancelation of the pause and the expiration of the subscription (i.e. Pre-expiration attempt < NOW < Expiration), the next billing date is set to NOW, and a billing attempt is made and the subscription status becomes ACTIVE until the subscription expiration date.
  • If the pause is in effect, the next billing date is set to NOW, and a renewal attempt is made. Depending on the success of the attempt one of the following happens:
    • If the renewal attempt is successful, the subscription status becomes ACTIVE, and the new expiration date is set to NOW() + Bill cycle length
    • If the renewal attempt is not successful, the subscription status will be based on the previous expiration date and grace period settings, in other words:
      • PAST DUE – if the moment the subscription is canceled is less than the previous expiration date + grace period.
      • EXPIRED – if the moment the subscription is canceled is greater than previous expiration date + grace period

Subscription pauses can be canceled as part of the following actions:

  • Manually
    • via Merchant Control Panel: Only for test subscriptions, using the Renew Subscription button.
    • via Manual renewal links: Redirecting to shopping cart where shoppers have a Manual renewal link
    • via API: Using the renewSubscription, placeOrder, and cancelPause methods
    • via 2Checkout Customer myAccount: Using the Renew now button and the Change credit card and payment flow.
  • Automatically
    • At a scheduled date and time – Subscription will resume automatically when the pause end date is reached.

Reporting

Pause subscription events will be logged and displayed in the subscription history section of your Merchant Control Panel. You can see all your paused subscriptions by navigating to your Merchant Control Panel - Orders & customers - Subscriptions and checking the Paused filter in the Subscription status field.

FAQ

1. Can paused subscriptions still be manually renewed?

Yes. There are several ways to manually renew a subscription scheduled to pause.

2. Can I cancel a subscription that is already paused?

Yes. You can always cancel a subscription that is already paused either via your Merchant Control Panel or via API or as part of the Refund/Chargeback process. Canceling the subscription from any of these sources will cause any pauses associated with the subscription to be marked as canceled only after the subscription itself is canceled.

Update a subscription

Overview

Change specific details about a subscription. Use the updateSubscription method to change specific details about a subscription. 

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 sessionIDexpires in 10 minutes.

Subscription

Required (Object)

 

You need to include the entire Subscription object keeping its structure unchanged (retrieve it using getSubscription) but you can update only specific parameters enumerated below.

 

EndUser

Object

 

 

End user details.

 

ExpirationDate

String

 

 

Subscription expiration date - If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then 2Checkout calculates the ExpirationDate according to your custom configuration. Note: The default 2Checkout API time zone is GMT+02:00.

 

SubscriptionEnabled

Boolean

 

 

Possible values: TRUE/FALSE

 

RecurringEnabled

Boolean

 

 

Possible values: TRUE/FALSE

 

ExternalCustomerReference

String

 

 

Unique customer alphanumeric (string) identifiers that you control. 

Move a subscription from under a customer to another customer entity.

Use the updateSubscription method. 2Checkout moves subscription under the customer for which you provide the 2Checkout customer reference or theExternal customer reference during the subscription update process. View example.

 

ProductId

Int

 

 

System-generated unique product ID. Needs to be the ID of an existing product in the 2Checkout system created under your account.

The product ID governs the product with which the subscription is associated.

Product types must match Regular - Regular or Bundle - Bundle.

IDs must identify products with the renewal system enabled (max billing cycle 36 months).

 

ProductName

String

 

 

The name of the product for identifier used under ProductID.

 

ProductQuantity

Int

 

 

Ordered quantity.

 

PriceOptionCodes

Array

 

 

Array of product options codes. Pricing options codes are case-sensitive.

To impact the renewal price, the PriceOptionsCodes need to belong to price options of pricing configurations used for the product with which the subscription is associated.

  ActivationKey String
    The subscription activation key.

All other parameters of the Subscription object are non-editable.

The 2Checkout system uses the updated subscription information for:

  • Manual and automatic renewals
  • Upgrades
  • Trial conversions

Response

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;
}
$SubscriptionReferenceTest = '0177AAA92B';
try {
    $retrievedSubscription = $client->getSubscription($sessionID, $SubscriptionReferenceTest);
}
catch (SoapFault $e) {
    echo "retrievedSubscription: " . $e->getMessage();
    exit;
}
var_dump("retrievedSubscription", $retrievedSubscription);
var_dump ($retrievedSubscription);
$retrievedSubscription->RecurringEnabled = false;
$retrievedSubscription-> SubscriptionEnabled = true;
$retrievedSubscription->ExpirationDate = '2020-12-12';
try {
    $updatedSubscription = $client->updateSubscription($sessionID, $retrievedSubscription);
}
catch (SoapFault $e) {
    echo "updatedSubscription: " . $e->getMessage();
    exit;
}
var_dump("updatedSubscription", $updatedSubscription);

Assign price option group

Overview

Use the assignPricingConfigurationOptionGroup method to assign a PricingOption Group to a PricingConfiguration.

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.

PricingConfigurationCode

Required (string)

 

Unique, system-generated pricing configuration identifier.  

PriceOptionsGroupAssigned

Required (Object)

 

Details below.

 

Parameters Type/Description

PriceOptionsGroupAssigned

Object

Code

Required (string)

 

PricingOption Group identifier.

Required

Required (Object)

 

True or false depending on whether the pricing options group is required during the purchase process or not.

Response

bool(true)

Request

<?php

require ('PATH_TO_AUTH');

$PricingConfigurationCode = 'YOUR_CODE';
$PriceOptionsGroupAssigned = new stdClass();
$PriceOptionsGroupAssigned->Code = 'USERSUSERS';
$PriceOptionsGroupAssigned->Required = TRUE;

try {
    $AssignedOption = $client-> assignPricingConfigurationOptionGroup ($sessionID, $PricingConfigurationCode, $PriceOptionsGroupAssigned);
}

catch (SoapFault $e) {
    echo "Options: " . $e->getMessage();
    exit;
}

var_dump("Options", $AssignedOption);

?>

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