public bool Delete(Payment payment)
 {
     IDictionary<string, object> vars = new Dictionary<string, object>(2);
     vars.Add("companyId", this.companyId);
     vars.Add("paymentID", payment.Id.Value);
     Payment response = this.restTemplate.PostForObjectAsync<Payment>("/resource/payment/v2/{companyId}/{paymentID}?methodx=delete", buildDelete(payment), vars).Result;
     return (response.Id == null);
 }
 public Task<Payment> Save(Payment payment)
 {
     if (payment.Id != null && payment.Id.Value != null)
     {
         return Update(payment);
     }
     else
     {
         return Create(payment);
     }
 }
        public PaymentBuilder()
        {
            _payment = new Payment();

            PaymentHeader paymentHeader = new PaymentHeader();

            paymentHeader.DocNumber = "54";
            paymentHeader.Note = "Payment against Invoice";
            IdType customerId = new IdType();
            customerId.Value = "5";
            paymentHeader.CustomerId = customerId;
            IdType depositAccountId = new IdType();
            depositAccountId.Value = "41";
            paymentHeader.DepositToAccountId = depositAccountId;
            IdType paymentMethodId = new IdType();
            paymentMethodId.Value = "1";
            paymentHeader.PaymentMethodId = paymentMethodId;
            paymentHeader.TotalAmt = decimal.Parse("20.00");
            paymentHeader.TotalAmtSpecified = true;
            paymentHeader.ProcessPayment = false;
            paymentHeader.ProcessPaymentSpecified = true;
            paymentHeader.TxnDate = DateTime.Parse("2010-08-09");
            paymentHeader.TxnDateSpecified = true;
            _payment.Header = paymentHeader;

            PaymentLine paymentLine = new PaymentLine();
            IdType txnId = new IdType();
            txnId.Value = "8";
            paymentLine.TxnId = txnId;

            paymentLine.Amount = decimal.Parse("20.00");
            paymentLine.AmountSpecified = true;
            List<PaymentLine> lines = new List<PaymentLine>();
            lines.Add(paymentLine);

            _payment.Line = lines.ToArray();
        }
 private Payment buildDelete(Payment payment)
 {
     Payment delete = new Payment();
     delete.SyncToken = payment.SyncToken;
     delete.Id = payment.Id;
     return delete;
 }
 public Task<Payment> Update(Payment payment)
 {
     IDictionary<string, object> vars = new Dictionary<string, object>(2);
     vars.Add("companyId", this.companyId);
     vars.Add("paymentID", payment.Id.Value);
     return this.restTemplate.PostForObjectAsync<Payment>("/resource/payment/v2/{companyId}/{paymentID}", payment, vars);
 }
 public Task<Payment> Create(Payment payment)
 {
     IDictionary<string, object> vars = new Dictionary<string, object>(1);
     vars.Add("companyId", this.companyId);
     return this.restTemplate.PostForObjectAsync<Payment>("/resource/payment/v2/{companyId}", payment, vars);
 }