HomeGuidesAPI ReferenceChangelogDiscussions
GuidesiMIS ProfessionaliMIS EnterpriseClient SupportLog In
Guides

Make a donation with a cash payment

using System;
using Asi.Soa.ClientServices;
using Asi.Soa.Commerce.DataContracts;
using Asi.Soa.Core.DataContracts;
using Asi.Soa.Fundraising.DataContracts;
using Asi.Soa.Membership.DataContracts;

EntityManager entityManager = new EntityManager();

string partyId = "18043"; // Chris Baker

// Create remittance data within the associated data collection
RemittanceDataCollection remittanceDataCollection = new RemittanceDataCollection
{
  new RemittanceData
  {
    Amount = new MonetaryAmountData(25.00m, new CurrencyData("USD")),
    Message = "Cash",
    PaymentMethod = new PaymentMethodData
    {
      CSCRequired = false,
      IssueDateRequired = false,
      IssueNumberRequired = false,
      Message = "Cash",
      Name = "Main Checking Account",
      PaymentMethodId = "CASH",
      PaymentType = "Cash"
    },
    PayorParty = new CustomerPartyData
    {
      Party = new ComboPartyData
      {
        PartyId = partyId,
        Name = "Brian",
        Id = partyId
      },
      PartyId = partyId
    }
  }
};

// Create gift order line and associated line data collection
OrderLineDataCollection orderLineDataCollection = new OrderLineDataCollection
{
  new GiftOrderLineData
  {
    BaseUnitPrice = new MonetaryAmountData(25.00m, new CurrencyData("USD")),
    CanCombine = true,
    ExtendedAmount = new MonetaryAmountData(25.00m, new CurrencyData("USD")),
    Item = new ItemSummaryData
    {
      Description =
        "Large or small, your donation has an immediate impact on our efforts to protect freshwater sources and wetlands all over the world.",
      ItemClass = new ItemClassSummaryData
      {
        ItemClassId = "GIFT",
        Name = "Gift"
      },
      ItemCode = "WATER",
      ItemId = "WATER",
      Name = "Support the Water Preservation Fund"
    },
    QuantityOrdered = new QuantityData(1),
    UnitPrice = new MonetaryAmountData(25.00m, new CurrencyData("USD"))
  }
};

// Create combo order, utilizing remittance data payment and order line
ComboOrderData comboOrderData = new ComboOrderData
{
  Currency = new CurrencyData {CurrencyCode = "USD"},
  Order = new OrderData
  {
    Currency = new CurrencyData("USD"),
    LineTotal = new MonetaryAmountData(25.00m, new CurrencyData("USD")),
    Lines = orderLineDataCollection,
    OrderDate = DateTime.Now,
    OrderState = OrderStateData.Entered,
    OrderTotal = new MonetaryAmountData(25.00m, new CurrencyData("USD")),
    SoldToCustomerParty = new CustomerPartyData
    {
      PartyId = partyId
    },
    TotalBasePrice = new MonetaryAmountData(25.00m, new CurrencyData("USD"))
  },
  Payments = remittanceDataCollection
};

// Submit and validate via ComboOrderManager
ComboOrderManager comboOrderManager = new ComboOrderManager(entityManager, comboOrderData);

ValidateResultsData results = comboOrderManager.Validate();
if (results.IsValid)
{
  comboOrderManager.Submit();
  Console.WriteLine("Grand total: {0}", comboOrderManager.TransactionGrandTotal.Amount);
}
else
{
  Console.WriteLine(results.ValidationResults.Summary);
}
using System;
using Asi.Soa.ClientServices;
using Asi.Soa.Commerce.DataContracts;
using Asi.Soa.Core.DataContracts;
using Asi.Soa.Fundraising.DataContracts;
using Asi.Soa.Membership.DataContracts;

EntityManager entityManager = new EntityManager();

string partyId = "18043"; // Chris Baker

var membershipManager = new MembershipManager(entityManager);

// Find existing party record
PartyData personData = membershipManager.FindPartyByPartyId(partyId);

// Create remittance data within the associated data collection
RemittanceDataCollection remittanceDataCollection = new RemittanceDataCollection
{
  new RemittanceData
  {
    Amount = new MonetaryAmountData(25.00m, new CurrencyData("USD")),
    Message = "VISA ************1111",
    CreditCardInformation = new CreditCardInformationData
    {
      CardNumber = "4111111111111111",
      CardType = "VISA",
      Expiration = new YearMonthDateData {Month = 5, Year = DateTime.Now.Year + 1},
      HoldersName = personData.Name,
      SecurityCode = "123"
    },
    PaymentMethod = new PaymentMethodData
    {
      CSCRequired = false,
      IssueDateRequired = false,
      IssueNumberRequired = false,
      Message = "VISA",
      Name = "VISA",
      PaymentMethodId = "VISA",
      PaymentType = "CreditCard"
    },
    PayorParty = new CustomerPartyData
    {
      Party = new ComboPartyData
      {
        PartyId = partyId,
        Name = "Brian",
        Id = partyId
      },
      PartyId = partyId
    },
    ReferenceNumber = "100"
  }
};

// Create gift order line and associated line data collection
OrderLineDataCollection orderLineDataCollection = new OrderLineDataCollection
{
  new GiftOrderLineData
  {
    BaseUnitPrice = new MonetaryAmountData(25.00m, new CurrencyData("USD")),
    CanCombine = true,
    ExtendedAmount = new MonetaryAmountData(25.00m, new CurrencyData("USD")),
    Item = new ItemSummaryData
    {
      Description =
        "Large or small, your donation has an immediate impact on our efforts to protect freshwater sources and wetlands all over the world.",
      ItemClass = new ItemClassSummaryData
      {
        ItemClassId = "GIFT",
        Name = "Gift"
      },
      ItemCode = "WATER",
      ItemId = "WATER",
      Name = "Support the Water Preservation Fund"
    },
    QuantityOrdered = new QuantityData(1),
    UnitPrice = new MonetaryAmountData(25.00m, new CurrencyData("USD"))
  }
};

// Create combo order, utilizing remittance data payment and order line
ComboOrderData comboOrderData = new ComboOrderData
{
  Currency = new CurrencyData {CurrencyCode = "USD"},
  Order = new OrderData
  {
    Currency = new CurrencyData("USD"),
    LineTotal = new MonetaryAmountData(25.00m, new CurrencyData("USD")),
    Lines = orderLineDataCollection,
    OrderDate = DateTime.Now,
    OrderState = OrderStateData.Entered,
    OrderTotal = new MonetaryAmountData(25.00m, new CurrencyData("USD")),
    SoldToCustomerParty = new CustomerPartyData
    {
      PartyId = partyId
    },
    TotalBasePrice = new MonetaryAmountData(25.00m, new CurrencyData("USD"))
  },
  Payments = remittanceDataCollection
};

// Submit and validate via ComboOrderManager
ComboOrderManager comboOrderManager = new ComboOrderManager(entityManager, comboOrderData);

ValidateResultsData results = comboOrderManager.Validate();
if (results.IsValid)
{
  comboOrderManager.Submit();
  Console.WriteLine("Grand total: {0}", comboOrderManager.TransactionGrandTotal.Amount);
}
else
{
  Console.WriteLine(results.ValidationResults.Summary);
}