/// <summary> /// Method that converts a JSON string to a Paymentobjects /// </summary> /// <param name="jsonResponse"></param> /// <returns>The Payment that the JSON object represented</returns> public static Types.Payment JsonToPayment(string jsonResponse) { if (jsonResponse == null || jsonResponse == "") { throw new ArgumentException("JSON must be provided"); } PaymentResponseJsonHelper helper = JsonConvert.DeserializeObject <PaymentResponseJsonHelper>(jsonResponse); Types.Payment payment = PaymentJsonHelperToPayment(helper.Payment); return(payment); }
protected static Types.Payment PaymentJsonHelperToPayment(PaymentJsonHelper helper) { string batchId = null; if (helper.Batch != null) { batchId = helper.Batch.Id; } Types.Recipient recipient = RecipientJsonHelperToRecipient(helper.Recipient); Types.Payment payment = new Types.Payment(recipient, helper.SourceAmount, helper.SourceCurrency, helper.TargetAmount, helper.TargetCurrency, helper.Id, helper.Memo, helper.ExchangeRate, helper.Fees, helper.RecipientFees, helper.FxRate, helper.ProcessedAt, helper.CreatedAt, helper.UpdatedAt, helper.MerchantFees, batchId, helper.Status, helper.Compliance); return(payment); }