Product Upgrade Schema
Request sample
<?php //require_once(realpath(__DIR__ . '/../../../../../') . "/lib/api/v6.0/vendor/autoload.php"); require_once("/srv/www/app/live/htdocs/lib/api/v6.0/vendor/autoload.php"); $apiVersion = '6.0'; $domain = 'api.avangate.local:8081'; $host = "http://{$domain}/soap/{$apiVersion}/"; $client = new SoapClient($host . "?wsdl", array('location' => $host, 'cache_wsdl' => WSDL_CACHE_NONE)); $client->__setCookie('XDEBUG_SESSION', 'PHPSTORM'); // AlexB Inc account #21478 $merchantCode = "120000589445"; $key = "i9u2+w8%s4^5#8%t)A8?"; $productCode = "ADEV17962UPGRADE"; // main upgrade product offered as upgrade for other products $upgradeFromProductCode1 = "ADEV17962UPOPT1"; // product that can be upgraded #1 $upgradeFromProductCode2 = "ADEV17962UPOPT12"; // product that can be upgraded #2 $date = gmdate('Y-m-d H:i:s'); $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date; $hash = hash_hmac('md5', $string, $key); try { $sessionID = $client->login($merchantCode, $date, $hash); } catch (SoapFault $e) { echo $e->getMessage(); } echo "SessionID: " . $sessionID . PHP_EOL; $upgradeSchema = new stdClass(); /** @var \Api\Resources\Product\Assets\UpgradeSettings $upgradeSettings */ $upgradeSettings = new stdClass(); $upgradeSettings->PricingScheme = \Api\Resources\Product\Assets\UpgradeSettings::PRICING_SCHEME_PRICE_DIFFERENCE; $upgradeSettings->OptionPriceOperator = \Api\Resources\Product\Assets\UpgradeSettings::OPTION_PRICE_OPERATOR_SUBSTRACT; $upgradeSettings->OptionPricePercentage = 2; $upgradeSettings->SubscriptionUpgradeType = \Api\Resources\Product\Assets\UpgradeSettings::SUBSCRIPTION_UPGRADE_TYPE_PROLONG_SUBSCRIPTION; #$upgradeSettings->SubscriptionUpgradeType = 8; // invalid value $upgradeSettings->UseProductCatalogPricing = true; #$upgradeSettings->UseProductCatalogPricing = new SoapVar(5, XSD_INTEGER); // integer value 5 => will trigger exception $upgradeSettings->ProrateIgnoreGracePeriod = false; $upgradeSchema->UpgradeSettings = $upgradeSettings; $upgradeSchema->AllowUpgradeFrom = [$upgradeFromProductCode1, $upgradeFromProductCode2]; $payload = json_encode($upgradeSchema, JSON_PRETTY_PRINT); echo PHP_EOL . 'Calling ' . $host . ' with productCode: ' . $productCode . ' and payload: ' . PHP_EOL . $payload . PHP_EOL; try { $resp = $client->setProductUpgradeSchema($sessionID, $productCode, $upgradeSchema); } catch (SoapFault $e) { echo '(SoapFault) Exception caught: ' . $e->getMessage() . PHP_EOL; die(); } echo PHP_EOL . 'SetUpgradeSchema response:' . PHP_EOL . var_export($resp, true) . PHP_EOL;