/// <summary>
        /// Asynchronously Put a payment Info object with possible association to a merchant
        /// </summary>
        /// <param name="cardDetailsContent">HTTP Contennt already containing the payment Info object</param>
        /// <param name="creatorReference">On optional value to be used by the sender for future reference</param>
        /// <param name="saveCVV">Whether to save the Security code with the card</param>
        /// <param name="merchantId">Optional value allowing access to the given merchant Id (pciBooking user Id of the hotel)</param>
        /// <param name="storeMode">Where to store the card data</param>
        /// <param name="userData">User data (piggyback)</param>
        /// <param name="ct">Cancelation token</param>
        /// <param name="callback">callback method to invoke upon completion. Will be invoked also after cancelation</param>
        /// <remarks>Only bank cards are supported</remarks>
        private void PutCardDetailsAsync
        (HttpContent cardDetailsContent, string creatorReference, bool saveCVV, string merchantId, StoreMode storeMode, 
                Object userData, CancellationToken ct, Action<Entities.Result<Uri>> callback)
        {
            var baseUri = string.Format(
                "{0}?ref={1}&merchant={2}&storeMode={3}&saveCVV={4}",
                PAYCARDS_URL_PATH, 
                Uri.EscapeDataString(creatorReference),
                Uri.EscapeDataString(merchantId),
                Uri.EscapeDataString(storeMode.ToString()),
                Uri.EscapeDataString(saveCVV.ToString())
                );

            HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, baseUri);
            requestMessage.Content = cardDetailsContent;

            Entities.Result<Uri> result = new Entities.Result<Uri>();
            result.Status.userData = userData;

            sendAsync(requestMessage, result.Status, ct, (response) =>
            {
                if (result.Status.IsSuccess)
                {
                    result.responsePayload = response.Headers.Location;
                }
                if (callback != null)
                    callback(result);
            });
        }
Example #2
0
        protected override IStoreOperationResult PerformStore(StoreMode mode, string key, object value, uint expires, ref ulong cas, out int statusCode)
        {
            ulong tmp    = cas;
            var   result = base.PerformStore(mode, key, value, expires, ref cas, out statusCode);

            if (!result.Success)
            {
                StringBuilder    message      = new StringBuilder();
                StringBuilder    errorMessage = new StringBuilder();
                IOperationResult nextResult   = result;
                while (nextResult != null)
                {
                    message.Append(nextResult.Message).AppendLine();
                    if (nextResult.Exception != null)
                    {
                        errorMessage.Append(nextResult.Exception.ToString()).AppendLine();
                    }
                    nextResult = nextResult.InnerResult;
                }
                if (errorMessage.Length > 0)
                {
                    logger.Error(string.Format("缓存设置失败,key:{0},方式:{1},错误信息:{2}", key, mode.ToString(), message.ToString()), statusCode, errorMessage.ToString());
                }
                else if (mode != StoreMode.Add && tmp == 0)
                {
                    logger.Error(string.Format("缓存设置失败,key:{0},方式:{1},错误信息:{2}", key, mode.ToString(), message.ToString()), statusCode, errorMessage.ToString());
                }
            }
            return(result);
        }