Skip to main content

Update proposal

Overview

Use the updateProposal method via SOAP API 6.0 to update the details of a proposal or quote.

Request parameters

Request parameters for the updateProposal method via SOAP APIv6
Parameters Type Required/Optional Description
proposalId String Required The unique merchant proposal ID generated by the 2Checkout system.
sessionId String Required Unique 2Checkout session ID code.
Name String Optional Proposal name.
UserId String Optional The unique user ID generated by the 2Checkout system.
BillTo Object Optional  The billing details associated with the proposal.
SellTo Object Optional Represents the entity using the service. Used for tax calculation.

Request sample

<?php

require ('PATH_TO_AUTH');

$proposalID = "0573e71d-38bb-4d61-88ca-b3c557517c68";

try {
    $result = $soapClient->getProposalById($sessionID, $proposalID);
    echo "Fetching Proposal ID: {$proposalID} </br>";
}
catch (SoapFault $e) {
    echo "Could not fetch proposal: " . $e->getMessage();
    exit;
}

$result->Name = "Updated proposal name";
$result->UserId = "myuser";
$result->BillTo->FirstName = "Billing Contact first name";
$result->BillTo->LastName = "Billing Contact last name";
$result->BillTo->Email = "contact@email.com";
$result->BillTo->Country = "US";
$result->BillTo->State = "California";
$result->BillTo->vatCode = "85421564";
$result->BillTo->City = "San Francisco";
$result->BillTo->Address = "Street name No. 9 San Francisco, California";
$result->SellTo->FirstName = "Contact first name";
$result->SellTo->LastName = "Contact last name";
$result->SellTo->Email = "contact@email.com";
$result->SellTo->Country = "US";
$result->SellTo->State = "California";
$result->SellTo->City = "San Francisco";
$result->SellTo->Address = "Street name No. 5 San Francisco, California";

try {
    $updateResult = $soapClient->updateProposal($sessionID, $result->ProposalId, $result);
    echo "New proposal created: </br>", 
    var_dump($updateResult);
}
catch (SoapFault $e) {
    echo "Could not create proposal: " . $e->getMessage();
    exit;
}

Request sample with prorationDate

<?php

        require ('PATH_TO_AUTH');

        $proposalID = "0573e71d-38bb-4d61-88ca-b3c557517c68";

        try {
            $result = $soapClient->getProposalById($sessionID, $proposalID);
            echo "Fetching Proposal ID: {$proposalID} </br>";
        }
        catch (SoapFault $e) {
            echo "Could not fetch proposal: " . $e->getMessage();
            exit;
        }

        $result->Content->LineItems[0]->ProrationData = "2020-11-14T15:28:56+00:00";

        try {
            $updateResult = $soapClient->updateProposal($sessionID, $result->ProposalId, $result);
            echo "New proposal created: </br>",
            var_dump($updateResult);
        }
        catch (SoapFault $e) {
            echo "Could not create proposal: " . $e->getMessage();
            exit;
        }

Request sample with vatCode

<?php

        require ('PATH_TO_AUTH');

        $proposalID = "0573e71d-38bb-4d61-88ca-b3c557517c68";

        try {
            $result = $soapClient->getProposalById($sessionID, $proposalID);
            echo "Fetching Proposal ID: {$proposalID} </br>";
        }
        catch (SoapFault $e) {
            echo "Could not fetch proposal: " . $e->getMessage();
            exit;
        }

        $result->Name = "Updated proposal name";
        $result->UserId = "myuser";
        $result->BillTo->FirstName = "Billing Contact first name";
        $result->BillTo->LastName = "Billing Contact last name";
        $result->BillTo->Email = "contact@email.com";
        $result->BillTo->Country = "US";
        $result->BillTo->State = "California";
        $result->BillTo->City = "San Francisco";
        $result->BillTo->Address = "Street name No. 9 San Francisco, California";
        $result->SellTo->FirstName = "Contact first name";
        $result->SellTo->LastName = "Contact last name";
        $result->SellTo->Email = "contact@email.com";
        $result->SellTo->Country = "US";
        $result->SellTo->State = "California";
        $result->SellTo->vatCode = "85421564";
        $result->SellTo->City = "San Francisco";
        $result->SellTo->Address = "Street name No. 5 San Francisco, California";

        try {
            $updateResult = $soapClient->updateProposal($sessionID, $result->ProposalId, $result);
            echo "New proposal created: </br>", 
            var_dump($updateResult);
        }
        catch (SoapFault $e) {
            echo "Could not create proposal: " . $e->getMessage();
            exit;
        }

Request sample with TaxExemptionId

<?php

        require ('PATH_TO_AUTH');

        $proposalID = "0573e71d-38bb-4d61-88ca-b3c557517c68";

        try {
            $result = $soapClient->getProposalById($sessionID, $proposalID);
            echo "Fetching Proposal ID: {$proposalID} </br>";
        }
        catch (SoapFault $e) {
            echo "Could not fetch proposal: " . $e->getMessage();
            exit;
        }

        $result->Name = "Updated proposal name";
        $result->UserId = "myuser";
        $result->BillTo->FirstName = "Billing Contact first name";
        $result->BillTo->LastName = "Billing Contact last name";
        $result->BillTo->Email = "contact@email.com";
        $result->BillTo->Country = "US";
        $result->BillTo->State = "California";
        $result->BillTo->City = "San Francisco";
        $result->BillTo->Address = "Street name No. 9 San Francisco, California";
        $result->SellTo->FirstName = "Contact first name";
        $result->SellTo->LastName = "Contact last name";
        $result->SellTo->Email = "contact@email.com";
        $result->SellTo->Country = "US";
        $result->SellTo->State = "California";
        $result->SellTo->TaxExemptionId = "85421564";
        $result->SellTo->City = "San Francisco";
        $result->SellTo->Address = "Street name No. 5 San Francisco, California";

        try {
            $updateResult = $soapClient->updateProposal($sessionID, $result->ProposalId, $result);
            echo "New proposal created: </br>", 
            var_dump($updateResult);
        }
        catch (SoapFault $e) {
            echo "Could not create proposal: " . $e->getMessage();
            exit;
        }

Response

The updateProposal call via SOAP API 6.0 returns the Proposal object.

 

Place orders with catalog products

Overview

Use this object to create new orders and collect payments from shoppers using catalog products defined in your Merchant Control Panel.

For orders that require physical delivery, if no shipping methods are provided, 2Checkout will add to the cart your account's default shipping configuration.

You can find a list of common errors that may arise when using the placeOrder call via API 6.0 here.

Supported payment methods/flows

Requirements

For credit card orders placed using API 6.0, you need to pass through additional parameters that support the 3D Secure flow. 3D Secure works by redirecting customers to pages provided by their banks, where they need to enter additional security tokens or passwords to trigger the completion of the charge. By using 3D Secure, you get additional protection from liability for fraudulent card payments, with customers having to go through an extra layer of authentication. Send the following parameters in the placeOrder call:

Parameters Description
Vendor3DSReturnURL Required (string)
  URL address to which customers are redirected after the 3DS details get validated by the bank and the order is successfully authorized.
Vendor3DSCancelURL Required (string)
  URL address to which customers are redirected if the 3DS details were not validated or the order could not be authorized.
WSOrder Optional (string)
  The WSOrder parameter is used to control the website URL displayed in the email messages shoppers receive after they place an order. By default, 2Checkout reports the URL set as Homepage in the Account information area. Adding WSOrder to the buy-links for your products will cause the optional website address set by using the parameter to override and replace the Homepage URL in the email notifications sent to customers. The behavior is similar to the WS_ORDER parameter supported on checkout/cart pages and described here.

Parameters

 
Parameters Type/Description
Currency String / Optional
  The currency ISO code for the payment - ISO 4217. Example: “usd.”
Country String / Optional
  Shopper country. ISO 3166 two-letter code. Example: “us.”
Language String / Optional
  ISO 639-1 two-letter code. Language used for the purchase process. Example: “en.”
ExternalReference String / Optional
  Set external reference identifiers for orders. Enables you to replicate the functionality of the REF parameter included in Buy Links. Maximum 100 characters. If there is a need for longer references, you can apply an md5 hash for any string value, resulting in a 32 characters string. You can verify the hash after the order notification, on the client-side.
Source String / Optional
 

The link source for the sales. Enables you to replicate the functionality of the SRC (separate link identifier) parameter when included in Buy Links. Use the SRC parameter to track sale sources.

 

Maximum length 255 characters.

CustomerReference Integer / Optional
  Set an external customer ID, attached to the customer.
Affiliate Object/Optional
                   AffiliateCode String/Required
  The affiliate unique code (as returned by the affiliates API methods).
                   AffiliateSource String/Optional
  The affiliate source.
Items Array of object / Required
  Details below. 
  OrderItem Object
    Details below. 
    Code String / Mandatory
      Unique product identifier your control. Max length 256 characters. Only for catalog products.
    Quantity Integer / Optional
      Number of units
    PriceOptions Array of strings / Optional
      Array of price option codes.
    SKU String / Optional
      SKU identifier.
    Price Object - Can be NULL. If Price Type is set to 'CUSTOM', dynamic pricing can be added to the order via the Amount parameter.
    CrossSell Object – Can be NULL
      Details below. 
      ParentCode String 
        The product code of the master product you set to trigger the campaign.
      CampaignCode String 
        Unique, system-generated identifier for cross-sell campaigns.
    Trial Object – Can be NULL
      Details below. 
      Period Integer 
        The length of the trial subscription lifetime in days.
      Price Double / Optional
        Total trial price in the payment currency before 2Checkout deducts any taxes, discounts, etc.
    AdditionalFields Array of objects – Can be NULL
      AdditionalFieldSet Object – Can be NULL
        Code String
          The alpha-numeric characters, underscores and dashes that are set as the field identifier.
        Value String
          Selected field value.
    SubscriptionStartDate String
     

Specify the date time stamp when the subscription becomes active. Format 2016-07-02 22:22:22 (YYYY-MM-DD HH:mm:ss). Available for JSON-RPC and REST.

Send empty or NULL to activate subscriptions on the same date when customers purchase them.

You can exclude HH:mm:ss when sending the date and include only YYYY-MM-DD. In this case, 2Checkout uses 00:00:01. Default time zone GMT+02:00.

    SubscriptionCustomSettings Object/Optional
      To use this, the ExtraInformation object with AssistedSale property set to "true" is required.
   

CycleAmountType

String/Required
      Billing cycle unit NET/GROSS.
   

CycleUnit

String/Required
      DAY/MONTH. Can be NULL.
   

CycleAmount

Float/Required
      Billing cycle (renewal) price.
   

CycleLength

Integer/Required
      Billing cycle length. Can be NULL.
   

ContractLength

Integer/Optional
      Contract period length (expressed in the specified CycleUnit; must be multiple of CycleLength). Can be NULL.
   

MerchantDealAutoRenewal

Boolean/Optional
      Merchant deal auto-renewal flag.
   

ClientDealAutoRenewal

Boolean/Optional
      Client deal auto-renewal flag.
BillingDetails Object / Required
  Details below. 
  FirstName String/Required
    Shopper name.
  LastName String/Required
    Shopper surname.
  CountryCode String/Required
    Shopper country. ISO 3166 two-letter code.
  State String/Optional – Required for US, Canada, Brazil, Turkey, India and Romania
    The state in the shopper's country. Mandatory when you set the Billing Country to US, Canada, Brazil, Turkey, India and Romania. Use case insensitive utf8 strings for the full name, or just the two-letter code.
  City String/Required
    Shopper city.
  Address1 String/Required
    Shopper address.
  Address2 String / Optional
    Shopper address.
  Zip String/Required
    ZIP/ Postal code.
  Email String/Required
    Shopper email address.
  Phone String / Optional
    Shopper phone number. Mandatory when you set Brazil as the Billing Country. Can be NULL.
  Company String / Optional
    Company name. Can be null for end users. When present, you also need to provide the FiscalCode.
  FiscalCode String / Optional– Required for Brazil
   

• For companies, it needs to be the VAT ID. 2Checkout will validate the value provided and throw an error if the VAT ID is invalid/incorrect when calling setPaymentDetails. When present, you also need to provide the Company name.

• Mandatory when you set Brazil as the Billing Country. For Brazilian customers it represents the Fiscal Code (CPF/CNPJ).

Mandatory when you set India as the Billing Country, and purchase is made by a Company.

• Can be NULL for end users.

  TaxExemptionId String / Optional
    Tax Exempt Certification id used to deduct taxes for US orders.
Example: 1b80eecc349v
DeliveryDetails Object / Required
  Details below. 
    FirstName String / Required
      Shopper name from the delivery details.
    LastName String / Required
      Shopper surname from the delivery details.
    CountryCode String / Required
      Shopper country. ISO 3166 two-letter code from the delivery details.
    State String/Optional – Required for US, Canada, Brazil, Turkey, India and Romania
      The state in the shopper's country. Mandatory when you set the Billing Country to US, Canada, Brazil, Turkey, India and Romania. Use case insensitive utf8 strings for the full name, or just the two-letter code.
    City String / Optional
      Shopper city from the delivery details.
    Address1 String / Optional
      Shopper address from the delivery details.
    Address2 String / Optional
      Shopper address from the delivery details.
    Zip String / Optional
      ZIP/ Postal code from the delivery details.
    Email String / Optional
      Shopper email address from the delivery details.
    Phone String / Optional
      Shopper phone number from the delivery details. Mandatory when you set Brazil as the Billing Country. Can be NULL.
    Company String / Optional
      Company name from the delivery details. Can be null for end users. When present, you also need to provide the FiscalCode.
DeliveryInformation

Object / Optional

For products that require physical delivery, use this object to send the shipping method.

    ShippingMethod

Object

Details below

      Code String
  System-generated identified for your shipping method configuration
PaymentDetails Object / Required
  Adapt this object to the desired payment method.
  Type Required (string)
   

The payment method:

  • CC (credit/debit card - including local Brazilian cards).
  • ENCRYPTED_PAYMENT_DATA (client-side encryption)
  • PAYPAL
  • PAYPAL_EXPRESS
  • DIRECT_EBANKING 
  • TEST (for test orders).
  • PREVIOUS_ORDER(place new orders using the reference of a previous order).
  • EXISTING_PAYMENT_DATA  (use a card one of your customers already used to purchase from your account).
  • WIRE – the placeOrder response includes Wire payment details.
  • CHECK – the placeOrder response includes Check payment details.
  • WE_CHAT_PAY (for WeChat payments).
  • IDEAL (for iDEAL payments).
  • PURCHASEORDER - use for orders with POs.
  • FREE – for 0 value orders for which you’re not requiring customers to provide payment details.
  • ALIPAY
  • UNIONPAY
  • TRUSTLY (for Trustly payments)
  • EES_TOKEN_PAYMENT (2Pay.js)
  • APPLE PAY
  • BOLETO
  • GOOGLE PAY
  • Echeck/ACH
  • Stored Credit
  Currency Required (string)
    The currency ISO code for the payment - ISO 4217. Example: “usd.”
  PaymentMethod Optional (object)
   

Object structure and parameters differ according to payment method selected and API method (placing orders (POST) vs. retrieving order data (GET)).

 

NULL for 0 value orders for which you’re not requiring customers to enter payment details.

                                             RecurringEnabled Optional (boolean)
 
 

true – shopper checks the auto-renewal checkbox and 2Checkout charges subscription renewals using a recurring billing process.

false – shopper doesn’t check the auto-renewal checkbox.

      CardPayment Optional (object)
        Details below. 
        CardNumber Required (string)
          The credit/debit card number.
        CardType Required (string)
          visa, visaelectron, mastercard, maestro, amex, discover, dankort, cartebleue, jcb, hipercard, elo
        ExpirationYear Required (string)
          The year in which the card expires.
        ExpirationMonth Required (string)
          The month in which the card expires.
        HolderName Required (string)
          Card holder name.
        CCID Required (string)
          Credit Card Identification - an extra ID printed on the card, usually a 3-4 digit number, the CVC2/CVV2.
        Vendor3DSReturnURL Required (string)
          URL address to which customers are redirected after the 3DS details get validated by the bank and the order is successfully authorized.
        Vendor3DSCancelURL Required (string)
          URL address to which customers are redirected if the 3DS details were not validated or the order could not be authorized.
        HolderNameTime Optional (float)
         

The interval of time in seconds in which shoppers enter their name in the HolderName field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

        CardNumberTime Optional (float)
         

The interval of time in seconds in which shopper enter their card number in the CardNumber field. An abnormally short interval is usually a red flag for fraud attempts.

Can be NULL, but not a negative number.

        InstallmentsNumber  Optional (Int)
          Number of installments. Available only when customers un Brazil pay with Visa or MasterCard using Brazilian Real as the order currency. Use 1 or exclude the parameter for full payments. 
      PayPalExpress Optional (object)
        Details below. 
        Email Optional (string)
          Email address customers use for their PayPal account.
        ReturnURL Optional (string)
          The PayPal Express Checkout redirect URL returned by calling the getPayPalExpressCheckoutRedirectURL method. The return URL is the page on your website to which PayPal redirects yourbuyer's browser after the buyer logs into PayPal and approves the payment. Typically, this is a secure page (https://...) on your site.
        CancelURL Optional (string)
          The cancel URL is the page on your website to which PayPal redirects your buyer's browser if the buyer does not approve the payment. Typically, this is the secure page (https://...) on your site from which you redirected the buyer to PayPal.
      PreviousOrder Optional (Object)
          Details below. 
        RefNo Optional (string)
         

Order reference a previous purchase which reached the Approved/Complete status. You can use order for which customers paid with credit/debit cards or with PayPal. The status of order should be AUTHRECEIVED or COMPLETE.

 

Check the validity of references with the isValidOrderReference method.

 

The 2Checkout system blocks you from using references for fraudulent or potentially fraudulent orders.

      PurchaseOrderPaymentDetails Optional (Object)
        Details below. 
        InternalPONumber Optional (string)
          Identifier that business customers use internally in their organization to track and manage Purchase Orders (PO). Can be NULL.
        AutoApprove Optional (boolean)
         

TRUE - requires activation of the PO AutoApprove package (If the package is inactive 2Checkout returns an error). Please contact 2Checkout. When AutoApprove is TRUE, 2Checkout no longer requires that business customers upload a PO document. As such, PO orders are automatically approved for your account, without a PO doc. 2Checkout sets the PURCHASE_PENDING status for auto-approved PO orders.

FALSE - Default. Send this if the PO AUtoApprove package is not available for your account. 2Checkout uses the same flow as cart purchases with Purchase Orders for business customers placing orders with POs via API. This means that customers receive the same emails as if they made the purchase using the cart and need to update the PO document, which is reviewed by 2Checkout and that you need to approve. 2Checkout sets the AVAITING_UPLOAD status for POs andUnfinished for their orders.

 

Can be NULL.

      WE_CHAT_PAY Optional (string)
        Details below
        ReturnURL Optional (string)
          The return URL is the page to which your customers are redirected after their successful payment.
        CancelURL Optional (string)
          The cancel URL is the page to which your customers are redirected after their failed payment attempt.
      IDEAL Optional (string)
        Details below
        ReturnURL Optional (string)
          The return URL is the page to which your customers are redirected after their successful payment.
        CancelURL Optional (string)
          The cancel URL is the page to which your customers are redirected after their failed payment attempt.
        BankCode Required (string)
          String contains the SWIFT code of the bank, the plus sign "+", and the first 3 characters from the bank name. E.q.: in the case of Rabobank, code parameter is "RABONL2U+RAB".
      EXISTING_PAYMENT_DATA Optional (Object)
        By using EXISTING_PAYMENT_DAT you no longer require shoppers to enter any payment details.
        TransientToken Optional (string)
          Returned as a part of the process of retrieving customer information by SSOToken.
      TRUSTLY  Optional (string)
        Details below.
        ReturnURL Optional (string)
       

 
The return URL is the page to which your customers are redirected after their successful payment. 
      DIRECT_DEBIT_ACH Optional (object)
          Details below.
        AccountHolderName Optional (string)
          Full name of the account holder.
        BankRoutingNumber Optional (string)
          Bank Routing number consisting of up to 17 digits.
        AccountNumber Optional (string)
          Account number with fixed 9 digit length.
        AccountType Optional (string)
          Possible values are "S" for SAVINGS accounts or "C" for CHECKING accounts.
  CustomerIP Optional (string)
    Shopper IP.
Promotions Optional (Array of strings)
  Array of promotion codes.
AdditionalFields Object / Optional
  Details below. 
  Code Optional (string)
    The alpha-numeric characters, underscores, and dashes are set as the field identifier.
  Text Optional (string)
    Field text visible to shoppers in the cart.
  Value Optional (string)
    Selected field value.
LocalTime Optional (string)
 

Local shopper time in the following format: Y-m-d H:i:s.

This parameter can impact the fraud score of an order when it's missing, NULL, or incorrectly formatted.

GiftDetails Optional (object)
  Contains contact details for the recipient of gift purchase.
  FirstName Optional (string)
    First name of the gift recipient.
  LastName Optional (string)
    Last name of the gift recipient.
  Email Optional (string)
    Email of the gift recipient. 2Checkout uses this email for the delivery/fulfillment process.
  GiftNote Optional (string)
    Custom text shoppers provide a message to the gift recipient.

Request example (with Credit Card)

<?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 = 'placeOrder';
    public const ADDITIONAL_OPTIONS = null;
    //array or JSON
    public const PAYLOAD = <<<JSON
{
    "Currency": "USD",
    "Country": "US",
    "CustomerIP": "91.220.121.21",
    "Source": "testAPI.com",
    "WSOrder": "http://www.myurlfortest.com",
    "ExternalReference": null,
    "BillingDetails": {
        "Address1": "Test Address",
        "City": "London",
        "CountryCode": "US",
        "Email": "customer@2Checkout.com",
        "FirstName": "Customer",
        "LastName": "2Checkout",
        "Phone": "556133127400",
        "State": "DF",
        "Zip": "70403-900"
    },
    "PaymentDetails": {
        "Type": "CC",
        "Currency": "USD",
        "CustomerIP": "91.220.121.21",
        "PaymentMethod": {
            "CCID": "123",
            "CardNumber": "4111111111111111",
            "CardNumberTime": "12",
            "CardType": "Visa",
            "ExpirationMonth": "12",
            "ExpirationYear": "2023",
            "HolderName": "John Doe",
            "HolderNameTime": "12",
            "RecurringEnabled": true,
            "Vendor3DSReturnURL": "www.test.com",
            "Vendor3DSCancelURL": "www.test.com"
        }
    },
    "Items": [
        {
            "Code": "testprod",
            "Quantity": "1"
        }
    ]
}
JSON;
}

class Client
{
    public function call(
        string $url = Configuration::URL,
               $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?object
    {
        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);
    }
}

try {
    $client = new Client();
    var_dump($client->call());
} catch (Exception $ex) {
    var_dump($ex);
}

 

Create promotion

Overview

Use the addPromotion method to create a new promotion.

Parameters 

Parameter Type/Description
sessionID Required (string)
  Output of the Login method.
Promotion Required (object)
  Promotion object that you want to create.

Response

Parameters Type/Description
Promotion

Object

Contains promotion configuration.

Request

<?php

require ('PATH_TO_AUTH');

$promotionObject = new stdClass;
$promotionObject->Name = 'YOUR_PROMOTION_TITLE';
$promotionObject->Description = 'YOUR_PROMOTION_DESCRIPTION';
$promotionObject->StartDate = date('Y-m-d', strtotime('1 month ago'));
$promotionObject->EndDate = date('Y-m-d', strtotime('+1 month'));
$promotionObject->Type = 'REGULAR';
$promotionObject->Enabled = 1;
$promotionObject->MaximumOrdersNumber = 0;
$promotionObject->MaximumQuantity = 0;
$promotionObject->InstantDiscount = false;
$promotionObject->ChannelType = 'ECOMMERCE';
$promotionObject->ApplyRecurring = 'NONE';
$promotionObject->RecurringChargesNumber = 3;
$promotionObject->PublishToAffiliatesNetwork = 0;
$promotionObject->InstantDiscount = 0;

$couponObject = new stdClass;
$couponObject->Type = 'SINGLE';
$couponObject->Code = 'single_code';
$promotionObject->Coupon = $couponObject;

$discountObj = new stdClass;
$discountObj->Type = 'PERCENT';
$discountObj->Value = 30;
$promotionObject->Discount = $discountObj;
$promotionObject->Products = [$productsObj1, $productsObj2, $productsObj3];
//$promotionObject->Translations = [$translation1, $translation2];

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addPromotion',
'params' => array($sessionID, $promotionObject),
);

$result = callRPC((object)$jsonRpcRequest, $host);
var_dump($result);

Update promotion

Overview

Use the updatePromotion method to alter the details of an existing promotion.

Parameters

Parameter Type/Description
sessionID Required (string)
  Output of the Login method.
Promotion Required (object)
  Promotion object that you want to update.

Response

Parameter Type/Description
Promotion Updated promotion object.

Request

<?php
require ('PATH_TO_AUTH'); 

// Retrieve promotion details

$promotionCode = 'PROMOTION_CODE'; // code of the promotion that you want to update

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getPromotion',
'params' => array($sessionID, $promotionCode)
);
//var_dump (callRPC((Object)$jsonRpcRequest, $host));

// Keep the promotion you want to update in $existingPromotion
$existingPromotion = callRPC((Object)$jsonRpcRequest, $host);
// Set the fields to update 
$existingPromotion->Description = 'Updated description';

// Update the promotion
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'updatePromotion',
'params' => array($sessionID, $existingPromotion)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));

Create proposal

Overview

Use the createProposal method via SOAP API 6.0 to add/create a new quote.

Request Parameters

Parameters Type Required/Optional Description
proposal Object Required  
proposalContent Object Required  
lineItems Object Required  
sessionId String Required Unique 2Checkout session ID code.

Request sample

<?php

require ('PATH_TO_AUTH');

$proposal = new stdClass();
$proposal->Type = "acquisition";
$proposal->BillTo = new stdClass();
$proposal->BillTo->Company = "Billing company";
$proposal->Content = new stdClass();
$proposal->Content->Language = "EN";
$proposal->Content->Currency = "USD";
$proposal->Content->LineItems =  array();
$lineItem = new stdClass();
$lineItem->ProductName = "My Product Name";
$lineItem->ProductCode = "5DCB30C6B0";
$lineItem->Quantity = 1;
$lineItem->Price = 54.2;
$lineItem->DiscountedPrice = 50;
$lineItem->PriceType = "net";
$lineItem->ContractPeriod = 0;
$proposal->Content->LineItems[0] = $lineItem;
$proposal->tac = new stdClass();
$proposal->tac->content = "Lorem ipsum.";
$proposal->SellTo = new stdClass();
$proposal->SellTo->Company = "End user company";

try {
    $results = $soapClient->createProposal($sessionID, $proposal);
    echo "New proposal created: </br>", 
    var_dump($results);
}
catch (SoapFault $e) {
    echo "Could not create proposal: " . $e->getMessage();
    exit;
}

Request sample with prorationDate

<?php

        require ('PATH_TO_AUTH');

        $proposal = new stdClass();
        $proposal->Type = "amendment";
        $proposal->BillTo = new stdClass();
        $proposal->BillTo->Company = "Billing company";
        $proposal->Content = new stdClass();
        $proposal->Content->Language = "EN";
        $proposal->Content->Currency = "USD";
        $proposal->Content->Tersm = 10;
        $proposal->Content->LineItems =  array();
        $lineItem = new stdClass();
        $lineItem->ProductName = "My Product Name";
        $lineItem->ProductCode = "5DCB30C6B0";
        $lineItem->Quantity = 1;
        $lineItem->Price = 54.2;
        $lineItem->DiscountedPrice = 50;
        $lineItem->PriceType = "net";
        $lineItem->ProrationDate = "2020-11-14T15:28:56+00:00";
        $lineItem->ContractPeriod = 0;
        $lineItem->subscriptionReference ="1234567890";
        $proposal->Content->LineItems[0] = $lineItem;
        $proposal->tac = new stdClass();
        $proposal->tac->content = "Lorem ipsum.";
        $proposal->SellTo = new stdClass();
        $proposal->SellTo->Company = "End user company";

        try {
            $results = $soapClient->createProposal($sessionID, $proposal);
            echo "New proposal created: </br>",
            var_dump($results);
        }
        catch (SoapFault $e) {
            echo "Could not create proposal: " . $e->getMessage();
            exit;
        }

Request sample with vatCode

    <?php

        require ('PATH_TO_AUTH');

        $proposal = new stdClass();
        $proposal->Type = "acquisition";
        $proposal->BillTo = new stdClass();
        $proposal->BillTo->Company = "Billing company";
        $proposal->Content = new stdClass();
        $proposal->Content->Language = "EN";
        $proposal->Content->Currency = "USD";
        $proposal->Content->LineItems =  array();
        $lineItem = new stdClass();
        $lineItem->ProductName = "My Product Name";
        $lineItem->ProductCode = "5DCB30C6B0";
        $lineItem->Quantity = 1;
        $lineItem->Price = 54.2;
        $lineItem->DiscountedPrice = 50;
        $lineItem->PriceType = "net";
        $lineItem->ContractPeriod = 0;
        $proposal->Content->LineItems[0] = $lineItem;
        $proposal->tac = new stdClass();
        $proposal->tac->content = "Lorem ipsum.";
        $proposal->SellTo = new stdClass();
        $proposal->SellTo->Company = "End user company";
        $proposal->SellTo->VatCode = "854234564";

        try {
            $results = $soapClient->createProposal($sessionID, $proposal);
            echo "New proposal created: </br>", 
            var_dump($results);
        }
        catch (SoapFault $e) {
            echo "Could not create proposal: " . $e->getMessage();
            exit;
        }

Request sample with TaxExemptionId

<?php

        require ('PATH_TO_AUTH');

        $proposal = new stdClass();
        $proposal->Type = "acquisition";
        $proposal->BillTo = new stdClass();
        $proposal->BillTo->Company = "Billing company";
        $proposal->Content = new stdClass();
        $proposal->Content->Language = "EN";
        $proposal->Content->Currency = "USD";
        $proposal->Content->LineItems =  array();
        $lineItem = new stdClass();
        $lineItem->ProductName = "My Product Name";
        $lineItem->ProductCode = "5DCB30C6B0";
        $lineItem->Quantity = 1;
        $lineItem->Price = 54.2;
        $lineItem->DiscountedPrice = 50;
        $lineItem->PriceType = "net";
        $lineItem->ContractPeriod = 0;
        $proposal->Content->LineItems[0] = $lineItem;
        $proposal->tac = new stdClass();
        $proposal->tac->content = "Lorem ipsum.";
        $proposal->SellTo = new stdClass();
        $proposal->SellTo->Company = "End user company";
        $proposal->SellTo->TaxExemptionId = "854234564";

        try {
            $results = $soapClient->createProposal($sessionID, $proposal);
            echo "New proposal created: </br>", 
            var_dump($results);
        }
        catch (SoapFault $e) {
            echo "Could not create proposal: " . $e->getMessage();
            exit;
        }    

Response

The createProposal call via SOAP API returns a Proposal object.

Two-factor authentication

Overview

Two-factor authentication is a method of computer access control that grants users access to their account after validating two criteria:

  • Knowledge - represented by a security aspect the user has knowledge of, such as the username and password.
  • Possession - represented by an item that only exists in the possession of that specific user, such as a smartphone, tablet, phone number, or email address.

Through two-factor authentication, users can access the 2Checkout Merchant Control Panel using their username, password, and a security token provided either by the Google Authenticator app or sent via email (associated with their Merchant Control Panel account).

For security reasons, master account users can enable two-factor authentication for their own accounts only via Google Authenticator

2Checkout allows you to manage user access to specific features by creating and assigning user roles. This extra layer of security enables you to restrict access to the Merchant Control Panel to specific users, based on unique tokens.

Availability

All 2Checkout accounts.

Requirements

  • Two-factor authentication through Google Authenticator requires a compatible mobile device running Android 2.3.3 or newer, or iOS 7.0 or newer.
  • Two-factor authentication via email requires the user to have access to his or her email account.

Google Authenticator for Android

You can download the Google Authenticator app for Android here or by accessing Google Play Store from your Android device.

Google Authenticator for iOS

You can download the Google Authenticator app for iOS here or by accessing the App Store from your iOS device.

Two-factor authentication types

2Checkout supports two types of two-factor authentication:

  • Two-factor authentication powered by Google Authenticator. Authentication codes are delivered through the Google Authenticator app for Android and iOS.
  • Two-factor authentication via emailParticular cases where users do not have access to their smartphones, such as environments that adhere to a "clean desk" policy, require authentication codes to be sent via email. In these situations, two-factor enrollment is done by the master account. Users enrolled by the master account cannot disable two-factor authentication on their own.

Two-factor authentication via Google Authenticator

Enable two-factor authentication

Follow the steps below to enable two-factor authentication for your account.

  1. Log in to the 2Checkout Merchant Control Panel.
  2. Navigate to the Settings cogwheel in the upper right corner.
  3. Click on My details.

2FA details.png

4. Go to the Two-factor authentication tab.

5. Scan the QR code using your smart device or enter the Authentication secret in the Google Authenticator app. The app will provide an authentication code.

6. Enter the authentication code in the dedicated field in the 2Checkout Merchant Control Panel.

7. Click Activate.

From this point on, every login attempt will require an authentication code provided by Google Authenticator.

Disable two-factor authentication

Follow the steps below to disable two-factor authentication.

  1. Login to the 2Checkout Control Panel.
  2. Navigate to the Settings cogwheel in the upper right corner.
  3. Click on My details.
  4. Go to the Two-factor authentication tab.
  5. Click Deactivate.

Two-factor authentication via email

Particular cases where users do not have access to their smartphones, such as environments that adhere to a "clean desk" policy, require authentication codes to be sent via email. In these situations, two-factor enrollment is done by the master account. Users enrolled by the master account cannot disable two-factor authentication on their own.

Follow the steps below to enable two-factor authentication via email.

  1. Login to the 2Checkout Merchant Control Panel with a master account.
  2. Navigate to the Settings cogwheel in the upper right corner.
  3. Click on User management.
  4. Identify the user you wish to enable two-factor authentication for and click Edit.
  5. Check the Two-factor authentication by email option.
  6. Click Save.

Once you enable two-factor authentication for a user, 2Checkout notifies them about the change and sends an authentication code to their email address each time a login attempt is detected.

Add promotion coupon

Request

<?php 

class Client
{
    protected static $merchantCode;
    protected static $loginDate;
    protected static $hash;
    protected static $baseUrl;
    protected static $callCount = 0;
    protected static $sessionId = '';

    protected static $client;

    public static function setCredentials($code, $key)
    {
        static::$merchantCode = $code;
        static::$loginDate = gmdate('Y-m-d H:i:s');
        static::$hash = hash_hmac('md5', strlen($code) . $code . strlen(static::$loginDate) . static::$loginDate, $key);
        static::$sessionId = static::login();
    }

    public static function setBaseUrl($url)
    {
        static::$baseUrl = $url;
    }

    public static function login()
    {
        $client = static::getClient();
        return $client->login(static::$merchantCode, static::$loginDate, static::$hash);
    }

    public static function __callStatic($name, $arguments = array())
    {
        $client = static::getClient();

        array_unshift($arguments, static::$sessionId);
        $response = call_user_func_array(array($client, $name), $arguments);

        return $response;
    }

    protected static function getClient()
    {
        $opts = array(
            'http'=> ['user_agent' => 'PHPSoapClient'],
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false,
            ],
        );

        if (null === static::$client) {
            static::$client = new \SoapClient(static::$baseUrl . '?wsdl', [
                'location' => static::$baseUrl,
                'cache_wsdl' => WSDL_CACHE_NONE,
                'stream_context' => stream_context_create($opts),
            ]);
        }

        return static::$client;
    }
}

Client::setBaseUrl('https://api.avangate.com/soap/3.1/');
Client::setCredentials('YOUR_MERCHANT_CODE', 'YOUR_SECRET_KEY');
Client::login();

$promotionCode = 'YOUR_PROMOTION_CODE'; // code of the promotion that you want to update

// // Define single coupon object
// $promotionCoupon = new stdClass;
// $promotionCoupon->Type = 'SINGLE';
// $promotionCoupon->Code = 'YOUR_CODE_HERE';

// Define multiple coupon object
// $promotionCoupon = new stdClass;
// $promotionCoupon->Type = 'MULTIPLE';
// $promotionCoupon->Codes = ['YOUR_CODE_1', 'YOUR_CODE_2'];

$response = Client::addPromotionCoupon ($promotionCode,$promotionCoupon); // Add coupons to the existing promotion
var_dump($response);

Enable a subscription

Overview

Use the enableSubscription method to enable 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 sessionID expires in 10 minutes.

subscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

Response

Parameters Type/Description

Boolean

true or false depending on whether the changes were successful or not.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

try {
    $enabledSubscription = $client->enableSubscription($sessionID, $SubscriptionReference);
}
catch (SoapFault $e) {
    echo "enabledSubscription: " . $e->getMessage();
    exit;
}
var_dump("enabledSubscription", $enabledSubscription);

Enable a subscription

Overview

Use the enableSubscription method to enable a subscription.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. Avangate throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

subscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

Response

Parameters Type/Description

Boolean

true or false depending on whether the changes were successful or not.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';

$jsonRpcRequest = array (
'method' => 'enableSubscription',
'params' => array($sessionID, $subscriptionReference),
'id' => $i++,
'jsonrpc' => '2.0');

var_dump (callRPC((Object)$jsonRpcRequest, $host, true));

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 sessionID expires 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.

You cannot set an expiration date from the past.

  ActivationDate String
   

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

This field is optional. If provided, it cannot be set lower than the subscription start date (creation/purchase date) and it can be changed only while the subscription is in pending activation status.

  SubscriptionEnabled Boolean
    Possible values: TRUE/FALSE
  RecurringEnabled Boolean
    Possible values: TRUE/FALSE
  ExternalCustomerReference String
   

Unique customer alphanumeric (string) identifiers that you control. Use this to 

move a subscription from under a customer to another customer entity. 2Checkout moves subscription under the customer for which you provide the External 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 to which the subscription is associated with.

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.

ChurnReasons Array
 

This payload can be sent only when the Subscription object (from above) will have RecurringEnabled set as TRUE. Possible values for this field are:
CHURN_REASON_NOT_SATISFIED_PRODUCT

CHURN_REASON_ENABLED_BY_MISTAKE

CHURN_REASON_PREFER_MANUAL

CHURN_REASON_ALREADY_RENEWED

CHURN_REASON_DONT_NEED

CHURN_REASON_WANT_PAUSE

CHURN_REASON_COVID

CHURN_REASON_HIGH_PRICE

CHURN_REASON_NOT_SATISFIED_SUPPORT

CHURN_REASON_EXTRAORDINARY

CHURN_REASON_OTHER

ChurnReasonOther String
  This field should have a value only if the ChurnReasons has the CHURN_REASON_EXTRAORDINARY or CHURN_REASON_OTHER values

 

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

Parameters Type/Description
Boolean true or false depending on whether the changes were successful or not.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReferenceTest = 'YOUR_SUBSCRIPTION_REFERENCE';

try{
    $retrievedSubscription = $client->getSubscription($sessionID, $subscriptionReferenceTest);
}

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

var_dump ($updatedSubscription);


$retrievedSubscription->RecurringEnabled = false;
$retrievedSubscription->SubscriptionEnabled = false;
$retrievedSubscription->ExpirationDate = '2026-12-12';

$churnReasons = ['CHURN_REASON_OTHER'];
$churnReasonOther = 'I refuse to continue the subscription';

try {
    $updatedSubscription = $client->updateSubscription($sessionID, $retrievedSubscription);
}
catch (SoapFault $e) {
    echo "updatedSubscription: " . $e->getMessage();
    exit;
}
var_dump("updatedSubscription", $updatedSubscription);

?>

 

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