Retrieve contents with Prefill
Overview
Use the getContentsWithPreFill method to get info on all the products added to cart by the shopper in the current session, while pre-filling the customer information based on the subscription reference.
Products added in cart can be either defined in your catalog, or created with dynamic information.
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 subscription identified, generated by 2Checkout. | |
Required (Object) |
|
|
Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details. |
Response
Parameters | Type/Description |
---|---|
SessionContents | Object |
Request
<?php require('PATH_TO_AUTH'); $Order = new stdClass(); $Order->RefNo = NULL; $Order->Currency = 'usd'; $Order->Country = 'US'; $Order->Language = 'en'; $Order->CustomerIP = '91.220.121.21'; $Order->ExternalReference = NULL; $Order->Source = NULL; $Order->AffiliateId = NULL; $Order->CustomerReference = NULL; $Order->Items = array(); $Order->Items[0] = new stdClass(); $Order->Items[0]->Code = 'my_subscription_1'; // you can also send products with dynamic information $Order->Items[0]->Quantity = 1; $Order->Items[0]->PriceOptions = NULL; $Order->Items[0]->SKU = NULL; $Order->Items[0]->Price = NULL; $Order->Items[0]->CrossSell = NULL; $Order->Items[0]->Trial = false; $Order->Items[0]->AdditionalFields = NULL; $Order->Items[0]->RenewalInformation = new stdClass(); $Order->Items[0]->RenewalInformation->SubscriptionReference = '63A6FE10AD'; // subscription based on which the customer information is pre-filled $Order->PaymentDetails = new stdClass (); $Order->PaymentDetails->Type = 'CC'; $Order->PaymentDetails->Currency = 'usd'; $Order->PaymentDetails->PaymentMethod = new stdClass (); $Order->PaymentDetails->CustomerIP = '10.10.10.10'; $Order->PaymentDetails->PaymentMethod->RecurringEnabled = true; $Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111"; $Order->PaymentDetails->PaymentMethod->CardType = 'visa'; $Order->PaymentDetails->PaymentMethod->ExpirationYear = '2019'; $Order->PaymentDetails->PaymentMethod->ExpirationMonth = '12'; $Order->PaymentDetails->PaymentMethod->HolderName = 'John'; $Order->PaymentDetails->PaymentMethod->CCID = '123'; $Order->AdditionalFields = NULL; $Order->LocalTime = NULL; $Order->GiftDetails = NULL; try { $CartContents = $client->getContentsWithPreFill($sessionID, $Order); } catch (SoapFault $e) { echo "CartContents: " . $e->getMessage(); exit; } var_dump("CartContents", $CartContents); ?>