/// <summary>
 /// Records a response in the last RequestFlowItem stored in the Items list.
 /// </summary>
 /// <param name="responseObject"></param>
 public void RecordResponse(IPayPalSerializableObject responseObject)
 {
     if (responseObject != null && this.Items.Any())
     {
         this.Items.Last().Response = PayPalCommon.FormatJsonString(responseObject.ConvertToJson());
     }
 }
예제 #2
0
        /// <summary>
        /// Records an exception encountered during this portion of the flow.
        /// </summary>
        /// <param name="ex">The exception to be recorded.</param>
        public void RecordException(Exception ex)
        {
            this.IsErrorResponse = true;

            if (ex is ConnectionException)
            {
                this.Response = PayPalCommon.FormatJsonString(((ConnectionException)ex).Response);
                if (string.IsNullOrEmpty(ex.Message))
                {
                    this.RecordError(string.Format("Error thrown from SDK as type {0}.", ex.GetType().ToString()));
                }
                else
                {
                    this.RecordError(ex.Message);
                }
            }
            else if (ex is PayPalException && ex.InnerException != null)
            {
                this.RecordError(ex.InnerException.Message);
            }
            else
            {
                this.RecordError(ex.Message);
            }
        }
 /// <summary>
 /// Adds a new RequestFlowItem to the list of Items.
 /// </summary>
 /// <param name="title">Title of this flow item.</param>
 /// <param name="requestObject">(Optional) The object used for the request.</param>
 /// <param name="description">(Optional) The description of the request.</param>
 public void AddNewRequest(string title, IPayPalSerializableObject requestObject = null, string description = "")
 {
     this.Items.Add(new RequestFlowItem()
     {
         Request     = requestObject == null ? string.Empty : PayPalCommon.FormatJsonString(requestObject.ConvertToJson()),
         Title       = title,
         Description = description
     });
 }