public override string Serialize()
{
string xml = "\r\n<credit";
xml += " id=\"" + SecurityElement.Escape(id) + "\"";
if (customerId != null)
{
xml += " customerId=\"" + SecurityElement.Escape(customerId) + "\"";
}
xml += " reportGroup=\"" + SecurityElement.Escape(reportGroup) + "\"";
xml += ">";
if (litleTxnIdSet)
{
xml += "\r\n<litleTxnId>" + litleTxnIdField + "</litleTxnId>";
if (amountSet) xml += "\r\n<amount>" + amountField + "</amount>";
if (secondaryAmountSet) xml += "\r\n<secondaryAmount>" + secondaryAmountField + "</secondaryAmount>";
if (surchargeAmountSet) xml += "\r\n<surchargeAmount>" + surchargeAmountField + "</surchargeAmount>";
if (customBilling != null) xml += "\r\n<customBilling>" + customBilling.Serialize() + "</customBilling>";
if (enhancedData != null) xml += "\r\n<enhancedData>" + enhancedData.Serialize() + "</enhancedData>";
if (processingInstructions != null) xml += "\r\n<processingInstructions>" + processingInstructions.Serialize() + "</processingInstructions>";
if (pos != null) xml += "\r\n<pos>" + pos.Serialize() + "</pos>";
if (pinSet) { xml += "\r\n<pin>" + pin + "</pin>"; }
}
else
{
xml += "\r\n<orderId>" + SecurityElement.Escape(orderId) + "</orderId>";
xml += "\r\n<amount>" + amountField + "</amount>";
if (secondaryAmountSet) xml += "\r\n<secondaryAmount>" + secondaryAmountField + "</secondaryAmount>";
if (surchargeAmountSet) xml += "\r\n<surchargeAmount>" + surchargeAmountField + "</surchargeAmount>";
if (orderSource != null) xml += "\r\n<orderSource>" + orderSource.Serialize() + "</orderSource>";
if (billToAddress != null) xml += "\r\n<billToAddress>" + billToAddress.Serialize() + "</billToAddress>";
if (card != null) xml += "\r\n<card>" + card.Serialize() + "</card>";
else if (token != null) xml += "\r\n<token>" + token.Serialize() + "</token>";
else if (mpos != null) xml += "\r\n<mpos>" + mpos.Serialize() + "</mpos>";
else if (paypage != null) xml += "\r\n<paypage>" + paypage.Serialize() + "</paypage>";
else if (paypal != null)
{
xml += "\r\n<paypal>";
if (paypal.payerId != null) xml += "\r\n<payerId>" + SecurityElement.Escape(paypal.payerId) + "</payerId>";
else if (paypal.payerEmail != null) xml += "\r\n<payerEmail>" + SecurityElement.Escape(paypal.payerEmail) + "</payerEmail>";
xml += "\r\n</paypal>";
}
if (customBilling != null) xml += "\r\n<customBilling>" + customBilling.Serialize() + "</customBilling>";
if (taxTypeSet) xml += "\r\n<taxType>" + taxTypeField + "</taxType>";
if (billMeLaterRequest != null) xml += "\r\n<billMeLaterRequest>" + billMeLaterRequest.Serialize() + "</billMeLaterRequest>";
if (enhancedData != null) xml += "\r\n<enhancedData>" + enhancedData.Serialize() + "</enhancedData>";
if (processingInstructions != null) xml += "\r\n<processingInstructions>" + processingInstructions.Serialize() + "</processingInstructions>";
if (pos != null) xml += "\r\n<pos>" + pos.Serialize() + "</pos>";
if (amexAggregatorData != null) xml += "\r\n<amexAggregatorData>" + amexAggregatorData.Serialize() + "</amexAggregatorData>";
if (merchantData != null) xml += "\r\n<merchantData>" + merchantData.Serialize() + "</merchantData>";
}
if (payPalNotes != null) xml += "\r\n<payPalNotes>" + SecurityElement.Escape(payPalNotes) + "</payPalNotes>";
if (actionReason != null) xml += "\r\n<actionReason>" + SecurityElement.Escape(actionReason) + "</actionReason>";
xml += "\r\n</credit>";
return xml;
}
public void testCredit() { credit credit = new credit(); credit.orderId = "12344"; credit.amount = 106; credit.orderSource = orderSourceType.ecommerce; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4100000000000001"; card.expDate = "1210"; credit.card = card; batchRequest.addCredit(credit); Assert.AreEqual(1, batchRequest.getNumCredit()); Assert.AreEqual(credit.amount, batchRequest.getSumOfCredit()); mockLitleFile.Verify(litleFile => litleFile.createRandomFile(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), mockLitleTime.Object)); mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, credit.Serialize())); }