Create a lead
Last updated: 27-Sep-2021
Rate this article:
Overview
The lead management functionality that exists for the ConvertPlus cart can be also integrated with a self-hosted cart.
Use the addLead method to create a lead when a customer abandons the cart before placing an order.
Request Parameters
Parameters | Required | Type/Description |
---|---|---|
Items | Required | Purchased products. |
BillingDetails | Required | Array of strings. Billing information for the order. |
DeliveryDetails | Required | Array of strings. Delivery information for the order. |
Request Example
<?php
require ('PATH_TO_AUTH');
$Lead = new stdClass();
$Lead->CartId = "CartIdValue";
$Lead->Currency = "EUR";
$Lead->Language = "EN";
$Lead->ExternalReference = "REST_API_2CHECKOUT";
$Lead->Source = "testAPI.com";
$Lead->CustomerReference = "asdf1";
$Lead->MachineId = "123asd";
$Lead->Items = [];
$Item = new stdClass();
$Item->Code = "04C26C50F8";
$Item->Quantity = 2;
$Item->IsDynamic = false;
$Item->Tangible = true;
$Item->PurchaseType = "PRODUCT";
$Item->PriceOptions = [];
$priceOption = new stdClass();
$priceOption->Name = "group name 1";
$priceOption->Required = false;
$option = new stdClass();
$option->Name = 'add25';
$option->Value = 'add25';
$option->Surcharge = 100;
$priceOption->Options[] = $option;
$Item->PriceOptions[] = $priceOption;
$recurringOptions = new stdClass();
$recurringOptions->CycleLength = 6;
$recurringOptions->CycleUnit = 'MONTH';
$recurringOptions->CycleAmount = 100;
$recurringOptions->ContractLength = 2;
$recurringOptions->ContractUnit = 'YEAR';
$Item->RecurringOptions = $recurringOptions;
$marketingCampaigns = new stdClass();
$marketingCampaigns->Type = 23;
$marketingCampaigns->ParentCode = "m";
$marketingCampaigns->CampaignCode = 23;
$Item->MarketingCampaigns = $marketingCampaigns;
$Item->Price = new stdClass();
$Item->Price->Amount = 20;
$Item->Price->Type = "CUSTOM";
$additionalFields = [];
$additionalField = new stdClass();
$additionalField->Code = "TestFieldOne";
$additionalField->Text = "test text";
$additionalField->Value = "test value";
$additionalFields[] = $additionalField;
$Item->AdditionalFields = $additionalFields;
$Item->SubscriptionStartDate = date("Y-m-d H:i:s");
$Lead->Items[] = $Item;
$billingDetails = new stdClass();
$billingDetails->FirstName = "Customer";
$billingDetails->LastName = "2Checkout";
$billingDetails->Phone = null;
$billingDetails->Company = null;
$billingDetails->FiscalCode = "32423423";
$billingDetails->Email = "customer@2checkout.com";
$billingDetails->Address1 = "Test Address";
$billingDetails->Address2 = null;
$billingDetails->City = "LA";
$billingDetails->Zip = "12345";
$billingDetails->CountryCode = "RO";
$billingDetails->State = "CA";
$Lead->BillingDetails = $billingDetails;
$Lead->DeliveryDetails = clone($billingDetails);
$Lead->DeliveryInformation = new stdClass();
$Lead->DeliveryInformation->ShippingMethod = new stdClass();
$Lead->DeliveryInformation->ShippingMethod->Code = "sdfsd";
$Lead->PaymentDetails = new stdClass();
$Lead->PaymentDetails->Type = "CC";
$Lead->PaymentDetails->Currency = "EUR";
$Lead->PaymentDetails->PaymentMethod = new stdClass();
$Lead->PaymentDetails->PaymentMethod->RecurringEnabled = false;
$Lead->PaymentDetails->PaymentMethod->CardPayment = new stdClass();
$Lead->PaymentDetails->PaymentMethod->CardPayment->InstallmentsNumber = 23;
$Lead->PaymentDetails->CustomerIP = "1.2.3.4";
$Lead->LocalTime = date("Y-m-d H:i:s");
try {
$leadData = $client->addLead($sessionID, $Lead);
} catch (SoapFault $e) {
echo "addLead: " . $e->getMessage();
exit;
}
var_dump("addLead", $leadData);
Response Example
class stdClass#18 (3) {
public $LeadCode =>
string(10) "60E6C4B574"
public $CreatedAt =>
string(19) "2019-11-05T16:39:36"
public $Errors =>
array(0) {
}
}
Rate this article: