/// <summary> /// When the user is returned after performing/cancelling an order, the status of the transaction is not returned in the /// querystring. /// Thus the merchant needs to call the Completes method to retrieve the transaction status. /// It is important to notice that this function can only be used in combination with Initialize. /// If you at a later time want to get the transaction status you will need to call the Check function. /// Complete may only be called once for each transaction. /// Note: You have to check both errorCode and transactionStatus to be sure the transaction was successful. /// You need to save transactionRef and optionally transactionNumber as a reference to the transaction. /// The orderRef used during initialize and purchase is deleted upon completion of the transaction. /// Returns a boolean indicating if the request was successful. /// </summary> /// <param name="orderRef"></param> /// <returns>A boolean indicating if the result was transferred without errors. See also TransactionComplete.</returns> public async Task <CompleteResult> Complete(string orderRef) { // Validation if (string.IsNullOrEmpty(orderRef)) { throw new ArgumentNullException(nameof(orderRef), "orderRef is required"); } // Build string for md5 including all fields except empty strings and description field var hashInput = new StringBuilder(); hashInput.Append(Account.AccountNumber); hashInput.Append(orderRef); // Add encryption key at the end of string to be hashed hashInput.Append(Account.EncryptionKey); // Make hash string hash; MD5Hash.Hash(hashInput.ToString(), out hash); // Call web service var payexOrder = GetPxOrderClient(); var xmlReturn = await payexOrder.CompleteAsync(Account.AccountNumber, orderRef, hash); // Parse the result var result = ResultParser.ParseCompleteResult(xmlReturn); return(result); }