CalculateSurchargeAmount

Description

The CalculateSurchargeAmount method computes the surcharge fee that can be charged based on the base transaction amount and other contextual factors provided in the request.

Syntax

CalculateSurchargeAmountResponse CalculateSurchargeAmount(SecurityToken securityToken, double amount, string cardNumber, string cardZipCode, string customerInternalId, string paymentMethodId)

Arguments

Type

Name

Req.

Description

SecurityToken

securityToken

R

A unique token that is used to identify a merchant and authenticate the API request.

double

amount

R

The base transaction amount, excluding surcharge.

string

cardNumber

D

The BIN of the card to be used. The BIN is the first 6-9 digits of the card number. The full card number can also be sent in this field.

Note: Required if customerInternalId and paymentMethodId are not sent.

string

cardZipCode

D

The billing postal/zip code of the card.

Note: Required if customerInternalId and paymentMethodId are not sent.

string

customerInternalId

D

Identifies the Customer the card is saved against.

Note: Required if cardNumber and cardZipCode are not sent.

string

paymentMethodId

D

Identifies the saved PaymentMethod to use.

Note: Required if cardNumber and cardZipCode are not sent.

Return Value

TypeDescription
CalculateSurchargeAmountResponseOn success, returns the calculated surcharge amount. Otherwise, a fault is returned.

Example Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ebiz="http://eBizCharge.ServiceModel.SOAP">
   <soapenv:Header/>
   <soapenv:Body>
      <ebiz:CalculateSurchargeAmount>
         <ebiz:securityToken>
            <ebiz:SecurityId>5a*****-0be8-****-91cd-********</ebiz:SecurityId>
            <ebiz:UserId>******testing</ebiz:UserId>
            <ebiz:Password>p05****TQmW79F</ebiz:Password>
         </ebiz:securityToken>
         <ebiz:amount>100.0</ebiz:amount>
         <ebiz:cardNumber>******42820871*****</ebiz:cardNumber>
         <ebiz:cardZipCode>92618</ebiz:cardZipCode>
         <ebiz:customerInternalId></ebiz:customerInternalId>
         <ebiz:paymentMethodId></ebiz:paymentMethodId>
      </ebiz:CalculateSurchargeAmount>
   </soapenv:Body>
</soapenv:Envelope>
SecurityToken securityToken = new SecurityToken();
securityToken.SecurityId = "********-****-****-****-************";
securityToken.UserId = "********";
securityToken.Password = "********";

IeBizServiceClient client = new IeBizServiceClient();

// Send the request to calculate the surcharge amount based on amount, card number, and postal code
CalculateSurchargeAmountResponse calculateSurchargeAmountResponse = client.CalculateSurchargeAmount(
	securityToken,          // Security Token
	100.0,                  // Transaction Amount without Surcharge
	"*****0009876****",     // Full Card Number (required if not sending customerInternalId + paymentMethodId)
	"92618",                // Card Postal Code
	"",                     // Customer Internal ID (required if not sending full card number)
	""                      // Payment Method ID (required if not sending full card number)
	);

// Print out the response
Console.WriteLine("Surcharge Enabled:           " + calculateSurchargeAmountResponse.IsSurchargeEnabled);
Console.WriteLine("Surcharge Allowed for Zip:   " + calculateSurchargeAmountResponse.IsSurchargeAllowedForZipCode);
Console.WriteLine("Surcharge Allowed for Method:" + calculateSurchargeAmountResponse.IsSurchargeAllowedForPaymentMethod);
Console.WriteLine("Surcharge Percentage:        " + calculateSurchargeAmountResponse.SurchargePercentage);
Console.WriteLine("Surcharge Amount:            " + calculateSurchargeAmountResponse.SurchargeAmount);
Console.WriteLine("Surcharge Caption:           " + calculateSurchargeAmountResponse.SurchargeCaption);
Console.WriteLine("Surcharge TermsNote:         " + calculateSurchargeAmountResponse.SurchargeTermsNote); 
// Create the SOAP client
$client = new SoapClient("End Point URL");

// Set up the security token
$securityToken = array(
  'UserId' => '******',
  'SecurityId' => '********-****-****-****-***********',
  'Password' => '*******',
);
$params = [
  'securityToken'      => $securityToken,
  'amount'             => 100.0,
  'cardNumber'         => '****098765****',
  'cardZipCode'        => '92618',
  'customerInternalId' => '',
  'paymentMethodId'    => ''
];
$response = $client->CalculateSurchargeAmount($params);

Example Response

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <CalculateSurchargeAmountResponse xmlns="http://eBizCharge.ServiceModel.SOAP">
         <CalculateSurchargeAmountResult>
            <IsSurchargeEnabled>true</IsSurchargeEnabled>
            <IsSurchargeAllowedForZipCode>true</IsSurchargeAllowedForZipCode>
            <IsSurchargeAllowedForPaymentMethod>false</IsSurchargeAllowedForPaymentMethod>
            <SurchargePercentage>2.5</SurchargePercentage>
            <SurchargeAmount>0</SurchargeAmount>
            <SurchargeCaption>Surcharge</SurchargeCaption>
            <SurchargeTermsNote>If you choose to pay with a credit card, you'll be charged a 2.5% Surcharge. If you choose to pay with a debit card, you won't be charged any fee.</SurchargeTermsNote>
         </CalculateSurchargeAmountResult>
      </CalculateSurchargeAmountResponse>
   </s:Body>
</s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <s:Fault>
         <faultcode>s:InvalidCredentials</faultcode>
         <faultstring xml:lang="en-US">Invalid Credentials</faultstring>
      </s:Fault>
   </s:Body>
</s:Envelope>