/// <summary> /// After performing an authorization, the merchant typically ensures that the customer will receive the item/service he /// ordered (i.e waits until the goods have been shipped) before performing a capture. The capture actually charges the /// customer with the authorized amount. /// </summary> /// <param name="transactionNumber">The transactionNumber of the transaction you wish to capture.</param> /// <param name="amount">The amount you wish to capture.</param> /// <param name="orderID"> /// Order Id that will be presented in PayEx report. This value have to be numeric if merchant have /// chosen to send orderId to the aquiring institution. /// </param> public async Task <CaptureResult> Capture(int transactionNumber, decimal amount, string orderID) { // Validation if (transactionNumber <= 0) { throw new ArgumentOutOfRangeException(nameof(transactionNumber), "transactionNumber is required"); } if (amount <= decimal.Zero) { throw new ArgumentOutOfRangeException(nameof(amount), "amount must be non-zero."); } // Null not allowed orderID = orderID ?? string.Empty; var vatAmount = 0; var additionalValues = string.Empty; // Build string for md5 including all fields except empty strings var hashInput = new StringBuilder(); hashInput.Append(Account.AccountNumber); hashInput.Append(transactionNumber); hashInput.Append(amount.ToPayEx()); hashInput.Append(orderID); hashInput.Append(vatAmount); hashInput.Append(additionalValues); // 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 payexOrder = GetPxOrderClient(); var xmlReturn = await payexOrder.Capture5Async( Account.AccountNumber, transactionNumber, amount.ToPayEx(), orderID, vatAmount, additionalValues, hash); // Parse the result and retrieve code-node to figure out if the service method was invoked successfully. var result = ResultParser.ParseCaptureResult(xmlReturn); return(result); }