Surcharge Property Retrieval
A Converge terminal has two surcharge related properties: switch for allowing surcharge and surcharge percentage. CSDK gets the properties as a part of account information retrieval from Converge during initialization. The following code examples demonstrate how a POS system can obtain the surcharge properties from CSDK.
Code Samples
CWS
// OpenPaymentGateway response
// In this example, two surcharge attributes are added to accountInfo
// "isCreditSurchargeAllowed":true,
// "creditSurchargePercent":2.55
Response
{
"requestId":"836703218",
"statusDetails":"REQUEST_ACCEPTED",
"data": {
"paymentGatewayCommand": {
"completed":true,
"eventQueue":[],
"openPaymentGatewayData": {
"result":"SUCCESS",
"paymentGatewayId":"fe2aef5a-7b06-4122-95b9-1d9d95c9424d"
},
"accountInfo": {
"businessEmail":"a@b.com",
"city":"",
"address1":"",
"postalCode":"",
"isCvvEnabled":false,
"stateProvince":"",
"isCreditSurchargeAllowed":true,
"creditSurchargePercent":2.55,
"isAvsEnabled":false,
"isGratuitySupported":false,
"name":"Joe",
"currencyCode":"USD",
"marketSegment":"RETAIL"
}
}
}
}
Java
// In the following callback interface method ECLAccountInformationRetrievalListener.accountInformationRetrievalDidSucceed(...) implementation
// First get terminal configuration (ECLTerminalConfiguration) from account interface (ECLAccountInterface).
// Then retrieve surcharge preference (ECLSurchargePreference) from the terminal configuration.
// Two properties are defined for the surcharge preference:
// A boolean variable holding the state for the terminal allowing surcharge.
// A double variable holding the surcharge percentage.
@Override
public void accountInformationRetrievalDidSucceed(ECLAccountInterface eclAccountInterface,
ECLAccountInformation accountInformation)
{
activity.accountInfo = accountInformation;
activity.displayMessageInProgressView("Account Info Retrieved:", false);
activity.displayMessageInProgressView("name: " + accountInformation.getName(), false);
activity.displayMessageInProgressView("currency: " + accountInformation.getCurrencyCode(), false);
ECLTerminalConfiguration terminalConfig = eclAccountInterface.getTerminalConfiguration();
if (terminalConfig != null)
{
ECLSurchargePreference surchargePreference = terminalConfig.getSurchargePreference();
if (surchargePreference != null)
{
activity.displayMessageInProgressView("Surcharge Allowd: " + surchargePreference.isAllowCreditSurcharge(), false);
if (surchargePreference.isAllowCreditSurcharge())
{
activity.displayMessageInProgressView("Surcharge Percentage: " + surchargePreference.getCreditSurchargePercent().doubleValue(), false);
}
}
}
}
Objective-C (iOS)
// In the [ECLAccountInformationRetrievalDelegate accountInformationRetrievalDidSucceed:accountInformation:] method implementation
// Retrieve surcharge preference (ECLSurchargePreference) from the ECLAccountInformation.
// Two properties are defined for the surcharge preference:
// A BOOL variable indicating whether the account is configured to allow surcharge.
// An NSDecimalNumber variable holding the surcharge percentage.
+ (void)accountInformationRetrievalDidSucceed:(id<ECLAccountProtocol>)account accountInformation:(ECLAccountInformation *)accountInformation {
BOOL surchargeAllowed = [accountInformation.surchargePreference creditSurchargeAllowed];
[self addStatusString:[NSString stringWithFormat:@"Surcharge: %@\n", surchargeAllowed ? @"YES" : @"NO"]];
if (surchargeAllowed) {
[self addStatusString:[NSString stringWithFormat:@"Surcharge Percent: %.02f%%\n", [[accountInformation.surchargePreference creditSurchargePercent] doubleValue]]];
}
}
C#
// Property AccountInfo of Object OpenPaymentGatewayResults has two new properites for holding surcharge properties:
// isCreditSurchargeAllowed -- the state for the terminal allowing surcharge
// creditSurchargePercent -- the surcharge percentage
private void updateAccountInformation(AccountInfo acctInfo)
{
Log("----- AccountInfo -----");
Log(String.Format("Credit Surcharge Allowed: {0}", acctInfo.isCreditSurchargeAllowed));
if (acctInfo.isCreditSurchargeAllowed)
{
Log(String.Format("Credit Surcharge Percent: {0}", acctInfo.creditSurchargePercent));
}
}