Some content on this site may not be available right now. We are aware and actively monitoring the situation.
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Retrieve eligible enrollment campaigns

Use the getEligibleEnrollmentCampaigns method to retrieve all the automatic renewal enrollment campaigns a subscription is eligible for, so you can offer the shopper a discount to enable automatic renewal. Enrollment campaigns have no translations, so this method has no Language parameter.

A subscription is eligible when automatic renewal is disabled, the subscription is active, and there is an active enrollment campaign for its product. The criteria are the same as for the existing myAccount flow.

Request parameters

Parameter
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.

Request sample

<?php

$vendorCode = 'YOUR_VENDOR_CODE';
$apiKey     = 'YOUR_API_KEY';
$date       = gmdate('Y-m-d H:i:s');
$hash       = hash_hmac(
    'md5',
    strlen($vendorCode) . $vendorCode . strlen($date) . $date,
    $apiKey
);

try {
    $client = new SoapClient(
        'https://api.2checkout.com/soap/6.0?wsdl',
        ['cache_wsdl' => WSDL_CACHE_NONE]
    );

    $sessionID = $client->login($vendorCode, $date, $hash);

    $subscriptionReference = '351D8F557E';

    $result = $client->getEligibleEnrollmentCampaigns($sessionID, $subscriptionReference);
    var_dump($result);
} catch (SoapFault $e) {
    echo 'SoapFault: ' . $e->getMessage() . PHP_EOL;
}

Response parameters

Parameter
Type

EligibleEnrollmentCampaignsResponse

Array of objects

Response sample

Error codes

Error code
Description

INVALID_SUBSCRIPTION_REFERENCE

The subscription reference is invalid or belongs to a different merchant.

Last updated

Was this helpful?