public string EncodePreauthorization(Preauthorization data) { StringBuilder sb = new StringBuilder(); String srcValue = String.Format("{0}-{1}", Paymill.GetProjectName(), Paymill.GetProjectVersion()); this.addKeyValuePair(sb, "amount", data.Amount); this.addKeyValuePair(sb, "currency", data.Currency); this.addKeyValuePair(sb, "source", srcValue); if (!string.IsNullOrEmpty(data.Token)) { this.addKeyValuePair(sb, "token", data.Token); } if (data.Payment != null && !string.IsNullOrEmpty(data.Payment.Id)) { this.addKeyValuePair(sb, "payment", data.Payment.Id); } return(sb.ToString()); }
public string EncodeTransaction(Transaction data, Fee fee) { StringBuilder sb = new StringBuilder(); String srcValue = String.Format("{0}-{1}", Paymill.GetProjectName(), Paymill.GetProjectVersion()); this.addKeyValuePair(sb, "amount", data.Amount); this.addKeyValuePair(sb, "currency", data.Currency); this.addKeyValuePair(sb, "source", srcValue); if (fee != null) { this.addKeyValuePair(sb, "fee_amount", fee.Amount); if (!string.IsNullOrEmpty(fee.Payment)) { this.addKeyValuePair(sb, "fee_payment", fee.Payment); } if (!string.IsNullOrEmpty(fee.Currency)) { this.addKeyValuePair(sb, "fee_currency", fee.Currency); } } if (!string.IsNullOrEmpty(data.Token)) { this.addKeyValuePair(sb, "token", data.Token); } if (data.Client != null && !string.IsNullOrEmpty(data.Client.Id)) { this.addKeyValuePair(sb, "client", data.Client.Id); } if (data.Payment != null && !string.IsNullOrEmpty(data.Payment.Id)) { this.addKeyValuePair(sb, "payment", data.Payment.Id); } this.addKeyValuePair(sb, "description", data.Description); return(sb.ToString()); }