Esempio n. 1
0
        /// <summary>
        /// This method deletes an existing agreement between a customer and a merchant with given agreementRef.
        /// All recurring agreements connected to the agreementRef will also be deleted.
        /// </summary>
        /// <param name="request">Ref to an agreement that will be deleted.</param>
        public async Task <DeleteAgreementResult> DeleteAgreement(string agreementRef)
        {
            // Build string for md5 including all fields except empty strings and description field
            var hashInput = new StringBuilder();

            hashInput.Append(Account.AccountNumber);
            hashInput.Append(agreementRef);
            // Add encryption key at the end of string to be hashed
            hashInput.Append(Account.EncryptionKey);
            // Create a hash string from the parameters
            string hash;

            MD5Hash.Hash(hashInput.ToString(), out hash);

            // Invoke Initialize method on external PayEx PxOrder web service
            var payexAgreement = GetPxAgreementClient();
            var xmlReturn      = await payexAgreement.DeleteAgreementAsync(Account.AccountNumber, agreementRef, hash);

            // Parse the result
            var result = ResultParser.ParseDeleteAgreementResult(xmlReturn);

            return(result);
        }