Besides processing transactions, CSDK offers various on-demand features to realize different functions. The supported features are listed below:
Account Validation
We can use this function to verify if the combination of merchant ID and client ID passed to CSDK is valid.
We'll first create an instance of ECLAccountValidationDelegate, as shown below.
@interface AccountValidationDelegate : NSObject<ECLAccountValidationDelegate> @end @implementation AccountValidationDelegate - (void)accountDidValidate:(id<ECLAccountProtocol>)account { [self addStatusString:@"Account validated\n"]; } - (void)accountDidFailToValidate:(id<ECLAccountProtocol>)account error:(NSError *)error { [self addStatusString:[NSString stringWithFormat:@"Account failed to be validated: %@\n", [error debugDescription]]]; } @end
We'll then pass the instance to method validateAccount on interface ECLAccountProtocol. CSDK internally validates that the combination of merchant id and client id provided by POS System (through <Commerce-Opayo/ECLOpayoAccountDelegate.h>) is correct. If error occurs at any stage during the validation, an error with an ECLTransactionErrorCode of ECLAccountInvalidCredentials will be returned via accountDidFailToValidate:error:
AccountValidationDelegate *delegate = [[ECLAccountValidationDelegate alloc] init]; [cachedAccount validateAccount:delegate];
Get Account Information
We can use this function to retrieve information about the account under current merchant ID and client ID.
We'll first create an instance of ECLAccountInformationRetrievalDelegate, as shown below:
@interface AccountInformationRetrievalDelegate : NSObject<ECLAccountInformationRetrievalDelegate> @end @implementation AccountInformationRetrievalDelegate - (void)accountInformationRetrievalDidSucceed:(id<ECLAccountProtocol>)account accountInformation:(ECLAccountInformation *)accountInformation { // you can use accountInformation parameter to retrieve information about the account such as name and currency code } - (void)accountInformationRetrievalDidFail:(id<ECLAccountProtocol>)account error:(NSError *)error { } @end
We'll then pass the instance to method retrieveAccountInformation on interface ECLAccountProtocol.
AccountInformationRetrievalDelegate *delegate = [[AccountInformationRetrievalDelegate alloc] init]; [cachedAccount retrieveAccountInformation:delegate];
Update PIN
We can use this function to set or update the operator PIN for the current combination of merchant ID and client ID. The default value for the operator PIN is empty. If set to a different value, it must be returned in method operatorPin: of <Commerce-Opayo/ECLOpayoAccountDelegate.h> so CSDK can use it for future operations.
We'll first create an instance of <ElavonCommon/ECCSensitiveData.h> with pin data.
// newPin is NSString type, holding the new or updated pin data. ECCSensitiveData *pinData = [[ECCSensitiveData alloc] init:newPin];
Then we'll create an instance of <Commerce-Opayo/ECLGeneralOperationDelegate.h>.
@interface GeneralOperationDelegate : NSObject<ECLGeneralOperationDelegate> @end @implementation GeneralOperationDelegate - (void)progress:(ECLTransactionProgress)progress { [self addStatusString:[NSString stringWithFormat:@"progress: %@\n", [ECLDebugDescriptions descriptionOfTransactionProgress:progress]]]; } - (void)completed:(BOOL)success error:(nullable NSError *)error { // if success is NO, check error } @end
We'll then pass the instances to method changeOperatorPin:delegate: on interface <Commerce-Opayo/ECLOpayoAccountProtocol.h> and CSDK internally will send the pin data to the Opayo server. If an error occurs during the operation, an error with an ECLTransactionErrorCode of ECLPinUpdateFailure will be returned.
GeneralOperationDelegate *delegate = [[GeneralOperationDelegate alloc] init]; id<ECLOpayoAccountProtocol> opayoCachedAccount = (id<ECLOpayoAccountProtocol>) cachedAccount; [opayoCachedAccount changeOperatorPin:pinData delegate:delegate];
Upload Log
We can use this function to upload log to Opayo server. This is very helpful when troubleshooting merchant's issues.
We'll first create an instance of <Commerce-Opayo/ECLGeneralOperationDelegate.h>.
@interface GeneralOperationDelegate : NSObject<ECLGeneralOperationDelegate> @end @implementation GeneralOperationDelegate - (void)progress:(ECLTransactionProgress)progress { [self addStatusString:[NSString stringWithFormat:@"progress: %@\n", [ECLDebugDescriptions descriptionOfTransactionProgress:progress]]]; } - (void)completed:(BOOL)success error:(nullable NSError *)error { // if success is NO, check error } @end
Then we'll pass the instance to method uploadLogs: on interface <Commerce-Opayo/ECLOpayoAccountProtocol.h>. CDSK will internally upload internal operation log to Opayo server. This operation can take up to 1 minute to complete.
GeneralOperationDelegate *delegate = [[GeneralOperationDelegate alloc] init]; id<ECLOpayoAccountProtocol> opayoCachedAccount = (id<ECLOpayoAccountProtocol>) cachedAccount; [opayoCachedAccount uploadLogs:delegate];
Query Tids
We can use this function to query available client IDs for a particular merchant ID.
We'll first create an instance of <Commerce-Opayo/ECLTidQueryDelegate.h>.
@interface TidQueryDelegate : NSObject<ECLTidQueryDelegate> @end @implementation TidQueryDelegate - (void)started { [self addStatusString:@"started"]; } - (void)completed:(BOOL)success mid:(nullable NSString *)mid tids:(nullable NSArray<NSString *> *)tids error:(nullable NSError *)error { if (success) { [self addStatusString:@"Query TIDs success"]; for (NSString *tid in tids) { [self addStatusString:tid]; } } else { [self addStatusString:[NSString stringWithFormat:@"Query TIDs failure: %@\n", [error debugDescription]]]; } } @end
We'll then pass the instance to method queryTIDs:delegate on interface <Commerce-Opayo/ECLOpayoAccountProtocol.h>. CSDK internally will send request to Opayo Server to get the list of available client IDs for a given merchant ID.
TidQueryDelegate *delegate = [[TidQueryDelegate alloc] init]; id<ECLOpayoAccountProtocol> opayoCachedAccount = (id<ECLOpayoAccountProtocol>) cachedAccount; [opayoCachedAccount queryTIDs:mid delegate:delegate];