public void FromDto(OrderTransactionDTO dto) { if (dto == null) return; this.Action = (ActionType)((int)dto.Action); this.Amount = dto.Amount; this.CheckNumber = dto.CheckNumber ?? string.Empty; this.CompanyAccountNumber = dto.CompanyAccountNumber ?? string.Empty; if (dto.CreditCard != null) { if (dto.CreditCard.CardIsEncrypted == false) { this.CreditCard.CardNumber = dto.CreditCard.CardNumber ?? string.Empty; } this.CreditCard.CardHolderName = dto.CreditCard.CardHolderName ?? string.Empty; this.CreditCard.ExpirationMonth = dto.CreditCard.ExpirationMonth; this.CreditCard.ExpirationYear = dto.CreditCard.ExpirationYear; this.CreditCard.SecurityCode = dto.CreditCard.SecurityCode ?? string.Empty; } this.GiftCardNumber = dto.GiftCardNumber ?? string.Empty; this.Id = dto.Id; this.LinkedToTransaction = dto.LinkedToTransaction ?? string.Empty; this.Messages = dto.Messages ?? string.Empty; this.OrderId = dto.OrderId ?? string.Empty; this.OrderNumber = dto.OrderNumber ?? string.Empty; this.PurchaseOrderNumber = dto.PurchaseOrderNumber ?? string.Empty; this.RefNum1 = dto.RefNum1 ?? string.Empty; this.RefNum2 = dto.RefNum2 ?? string.Empty; this.StoreId = dto.StoreId; this.Success = dto.Success; this.TimeStampUtc = dto.TimeStampUtc; this.Voided = dto.Voided; }
//DTO public OrderTransactionDTO ToDto() { OrderTransactionDTO dto = new OrderTransactionDTO(); dto.Action = (OrderTransactionActionDTO)((int)this.Action); dto.Amount = this.Amount; dto.CheckNumber = this.CheckNumber; dto.CompanyAccountNumber = this.CompanyAccountNumber; dto.CreditCard = new OrderTransactionCardDataDTO(); dto.CreditCard.CardHolderName = this.CreditCard.CardHolderName; dto.CreditCard.CardIsEncrypted = false; dto.CreditCard.CardNumber = this.CreditCard.CardNumber; dto.CreditCard.ExpirationMonth = this.CreditCard.ExpirationMonth; dto.CreditCard.ExpirationYear = this.CreditCard.ExpirationYear; dto.CreditCard.SecurityCode = this.CreditCard.SecurityCode; dto.GiftCardNumber = this.GiftCardNumber; dto.Id = this.Id; dto.LinkedToTransaction = this.LinkedToTransaction; dto.Messages = this.Messages; dto.OrderId = this.OrderId; dto.OrderNumber = this.OrderNumber; dto.PurchaseOrderNumber = this.PurchaseOrderNumber; dto.RefNum1 = this.RefNum1; dto.RefNum2 = this.RefNum2; dto.StoreId = this.StoreId; dto.Success = this.Success; dto.TimeStampUtc = this.TimeStampUtc; dto.Voided = this.Voided; return dto; }
private void ImportOrderTransactions(string orderBvin, string orderNumber) { wl(" - Transactions for Order " + orderNumber); data.BV53Entities db = new data.BV53Entities(EFConnString(settings.SourceConnectionString())); Api proxy = GetBV6Proxy(); var old = db.bvc_OrderPayment.Where(y => y.orderID == orderBvin); if (old == null) return; foreach (data.bvc_OrderPayment item in old) { wl("Transaction: " + item.bvin); bool hasAuth = item.AmountAuthorized != 0; bool hasCharge = item.AmountCharged != 0; bool hasRefund = item.AmountRefunded != 0; Guid AuthTransactionID = new Guid(); Guid ChargeTransactionId = new Guid(); Guid RefundTransactionId = new Guid(); // Get Guids for transactions Guid.TryParse(item.bvin, out ChargeTransactionId); if (hasAuth && (hasCharge == false && hasRefund == false)) { // Auth only, no refund or charge Guid.TryParse(item.bvin, out AuthTransactionID); } if (hasRefund && (hasCharge == false && hasAuth == false)) { // Refund only, no auth or charge Guid.TryParse(item.bvin, out RefundTransactionId); } if (hasAuth) { OrderTransactionDTO opAuth = new OrderTransactionDTO(); opAuth.Id = AuthTransactionID; switch (item.paymentMethodId) { case "4A807645-4B9D-43f1-BC07-9F233B4E713C": // Credit Card opAuth.Action = OrderTransactionActionDTO.CreditCardHold; break; case "9FD35C50-CDCB-42ac-9549-14119BECBD0C": // Telephone opAuth.Action = OrderTransactionActionDTO.OfflinePaymentRequest; break; case "494A61C8-D7E7-457f-B293-4838EF010C32": // Check opAuth.Action = OrderTransactionActionDTO.OfflinePaymentRequest; break; case "7FCC4B3F-6E67-4f58-86B0-25BCCC035A0E": // Cash case "EE171EFD-9E4A-4eda-AD70-4CB99F28E06C": // COD opAuth.Action = OrderTransactionActionDTO.OfflinePaymentRequest; break; case "A0300DBD-39EE-472C-9179-D4B96F27913B": // CredEx opAuth.Action = OrderTransactionActionDTO.CreditCardHold; break; case "26C948F3-22EF-4bcb-9AE9-DEB9839BF4A7": // PO opAuth.Action = OrderTransactionActionDTO.PurchaseOrderInfo; break; case "91a205f1-8c1c-4267-bed0-c8e410e7e680": // Gift Card opAuth.Action = OrderTransactionActionDTO.GiftCardHold; break; case "49de5510-dfe4-4b18-91a6-3dc9925566a1": // Google Checkout opAuth.Action = OrderTransactionActionDTO.CreditCardHold; break; case "33eeba60-e5b7-4864-9b57-3f8d614f8301": // PayPal Express opAuth.Action = OrderTransactionActionDTO.PayPalHold; break; default: opAuth.Action = OrderTransactionActionDTO.CreditCardHold; break; } opAuth.Amount = item.AmountAuthorized; opAuth.CheckNumber = item.checkNumber ?? string.Empty; opAuth.CreditCard = new OrderTransactionCardDataDTO(); opAuth.CreditCard.CardHolderName = item.creditCardHolder ?? string.Empty; opAuth.CreditCard.CardIsEncrypted = true; opAuth.CreditCard.CardNumber = string.Empty; opAuth.CreditCard.ExpirationMonth = item.creditCardExpMonth; opAuth.CreditCard.ExpirationYear = item.creditCardExpYear; opAuth.CreditCard.SecurityCode = string.Empty; opAuth.GiftCardNumber = item.giftCertificateNumber ?? string.Empty; opAuth.LinkedToTransaction = string.Empty; opAuth.Messages = item.note ?? string.Empty; opAuth.OrderId = orderBvin ?? string.Empty; opAuth.OrderNumber = orderNumber ?? string.Empty; opAuth.PurchaseOrderNumber = item.purchaseOrderNumber ?? string.Empty; opAuth.RefNum1 = item.transactionReferenceNumber ?? string.Empty; opAuth.RefNum2 = item.transactionResponseCode ?? string.Empty; opAuth.Success = true; opAuth.TimeStampUtc = item.auditDate; opAuth.Voided = false; var res = proxy.OrderTransactionsCreate(opAuth); if (res != null) { if (res.Errors.Count > 0) { DumpErrors(res.Errors); wl("FAILED TRANSACTION: " + item.bvin); } } else { wl("FAILED! EXCEPTION! TRANSACTION: " + item.bvin); } } if (hasCharge) { OrderTransactionDTO opCharge = new OrderTransactionDTO(); opCharge.Id = ChargeTransactionId; switch (item.paymentMethodId) { case "4A807645-4B9D-43f1-BC07-9F233B4E713C": // Credit Card opCharge.Action = OrderTransactionActionDTO.CreditCardCharge; break; case "9FD35C50-CDCB-42ac-9549-14119BECBD0C": // Telephone opCharge.Action = OrderTransactionActionDTO.OfflinePaymentRequest; break; case "494A61C8-D7E7-457f-B293-4838EF010C32": // Check opCharge.Action = OrderTransactionActionDTO.CheckReceived; break; case "7FCC4B3F-6E67-4f58-86B0-25BCCC035A0E": // Cash case "EE171EFD-9E4A-4eda-AD70-4CB99F28E06C": // COD opCharge.Action = OrderTransactionActionDTO.CashReceived; break; case "A0300DBD-39EE-472C-9179-D4B96F27913B": // CredEx opCharge.Action = OrderTransactionActionDTO.CashReceived; break; case "26C948F3-22EF-4bcb-9AE9-DEB9839BF4A7": // PO opCharge.Action = OrderTransactionActionDTO.PurchaseOrderAccepted; break; case "91a205f1-8c1c-4267-bed0-c8e410e7e680": // Gift Card opCharge.Action = OrderTransactionActionDTO.GiftCardCapture; break; case "49de5510-dfe4-4b18-91a6-3dc9925566a1": // Google Checkout opCharge.Action = OrderTransactionActionDTO.CreditCardCharge; break; case "33eeba60-e5b7-4864-9b57-3f8d614f8301": // PayPal Express opCharge.Action = OrderTransactionActionDTO.PayPalCharge; break; default: opCharge.Action = OrderTransactionActionDTO.CreditCardCharge; break; } opCharge.Amount = item.AmountCharged; opCharge.CheckNumber = item.checkNumber ?? string.Empty; opCharge.CreditCard = new OrderTransactionCardDataDTO(); opCharge.CreditCard.CardHolderName = item.creditCardHolder ?? string.Empty; opCharge.CreditCard.CardIsEncrypted = true; opCharge.CreditCard.CardNumber = string.Empty; opCharge.CreditCard.ExpirationMonth = item.creditCardExpMonth; opCharge.CreditCard.ExpirationYear = item.creditCardExpYear; opCharge.CreditCard.SecurityCode = string.Empty; opCharge.GiftCardNumber = item.giftCertificateNumber ?? string.Empty; opCharge.LinkedToTransaction = string.Empty; opCharge.Messages = item.note ?? string.Empty; opCharge.OrderId = orderBvin ?? string.Empty; opCharge.OrderNumber = orderNumber ?? string.Empty; opCharge.PurchaseOrderNumber = item.purchaseOrderNumber ?? string.Empty; opCharge.RefNum1 = item.transactionReferenceNumber ?? string.Empty; opCharge.RefNum2 = item.transactionResponseCode ?? string.Empty; opCharge.Success = true; opCharge.TimeStampUtc = item.auditDate; opCharge.Voided = false; var res = proxy.OrderTransactionsCreate(opCharge); if (res != null) { if (res.Errors.Count > 0) { DumpErrors(res.Errors); wl("FAILED TRANSACTION: " + item.bvin); } } else { wl("FAILED! EXCEPTION! TRANSACTION: " + item.bvin); } } if (hasRefund) { OrderTransactionDTO opRefund = new OrderTransactionDTO(); opRefund.Id = RefundTransactionId; switch (item.paymentMethodId) { case "4A807645-4B9D-43f1-BC07-9F233B4E713C": // Credit Card opRefund.Action = OrderTransactionActionDTO.CreditCardRefund; break; case "9FD35C50-CDCB-42ac-9549-14119BECBD0C": // Telephone opRefund.Action = OrderTransactionActionDTO.OfflinePaymentRequest; break; case "494A61C8-D7E7-457f-B293-4838EF010C32": // Check opRefund.Action = OrderTransactionActionDTO.CheckReturned; break; case "7FCC4B3F-6E67-4f58-86B0-25BCCC035A0E": // Cash case "EE171EFD-9E4A-4eda-AD70-4CB99F28E06C": // COD opRefund.Action = OrderTransactionActionDTO.CashReturned; break; case "A0300DBD-39EE-472C-9179-D4B96F27913B": // CredEx opRefund.Action = OrderTransactionActionDTO.CashReturned; break; case "26C948F3-22EF-4bcb-9AE9-DEB9839BF4A7": // PO opRefund.Action = OrderTransactionActionDTO.CashReturned; break; case "91a205f1-8c1c-4267-bed0-c8e410e7e680": // Gift Card opRefund.Action = OrderTransactionActionDTO.GiftCardIncrease; break; case "49de5510-dfe4-4b18-91a6-3dc9925566a1": // Google Checkout opRefund.Action = OrderTransactionActionDTO.CreditCardRefund; break; case "33eeba60-e5b7-4864-9b57-3f8d614f8301": // PayPal Express opRefund.Action = OrderTransactionActionDTO.PayPalRefund; break; default: opRefund.Action = OrderTransactionActionDTO.CreditCardRefund; break; } opRefund.Amount = -1 * item.AmountCharged; opRefund.CheckNumber = item.checkNumber ?? string.Empty; opRefund.CreditCard = new OrderTransactionCardDataDTO(); opRefund.CreditCard.CardHolderName = item.creditCardHolder ?? string.Empty; opRefund.CreditCard.CardIsEncrypted = true; opRefund.CreditCard.CardNumber = string.Empty; opRefund.CreditCard.ExpirationMonth = item.creditCardExpMonth; opRefund.CreditCard.ExpirationYear = item.creditCardExpYear; opRefund.CreditCard.SecurityCode = string.Empty; opRefund.GiftCardNumber = item.giftCertificateNumber ?? string.Empty; opRefund.LinkedToTransaction = string.Empty; opRefund.Messages = item.note ?? string.Empty; opRefund.OrderId = orderBvin ?? string.Empty; opRefund.OrderNumber = orderNumber ?? string.Empty; opRefund.PurchaseOrderNumber = item.purchaseOrderNumber ?? string.Empty; opRefund.RefNum1 = item.transactionReferenceNumber ?? string.Empty; opRefund.RefNum2 = item.transactionResponseCode ?? string.Empty; opRefund.Success = true; opRefund.TimeStampUtc = item.auditDate; opRefund.Voided = false; var res = proxy.OrderTransactionsCreate(opRefund); if (res != null) { if (res.Errors.Count > 0) { DumpErrors(res.Errors); wl("FAILED TRANSACTION: " + item.bvin); } } else { wl("FAILED! EXCEPTION! TRANSACTION: " + item.bvin); } } } }
private void ImportOrderTransactions(string orderBvin, string orderNumber, data.bvc_Order old) { wl(" - Transactions for Order " + orderNumber); Api proxy = GetBV6Proxy(); foreach (data.bvc_OrderPayment item in old.bvc_OrderPayment) { wl("Transaction: " + item.ID); bool hasAuth = (item.AuthorizationOnly == 1) && (item.Amount != 0); bool hasCharge = (item.PaymentType == 2) && (item.Amount != 0); bool hasRefund = (item.PaymentType == 3) && (item.Amount != 0); if (hasAuth) { OrderTransactionDTO opAuth = new OrderTransactionDTO(); opAuth.Id = new Guid(); switch (item.PaymentMethod) { case 1: // Credit Card opAuth.Action = OrderTransactionActionDTO.CreditCardHold; break; case 7: // Telephone case 9: // Fax case 3: // Check case 4: // Cash case 6: // Other case 8: // Email opAuth.Action = OrderTransactionActionDTO.OfflinePaymentRequest; break; case 10: // PO opAuth.Action = OrderTransactionActionDTO.PurchaseOrderInfo; break; case 5: // Gift Card opAuth.Action = OrderTransactionActionDTO.GiftCardHold; break; case 2: // PayPal Express opAuth.Action = OrderTransactionActionDTO.PayPalHold; break; default: opAuth.Action = OrderTransactionActionDTO.OfflinePaymentRequest; break; } opAuth.Amount = (decimal)item.Amount; if (hasRefund) { item.Amount = item.Amount * -1; } opAuth.CheckNumber = item.CheckNumber ?? string.Empty; opAuth.CreditCard = new OrderTransactionCardDataDTO(); opAuth.CreditCard.CardHolderName = item.CreditCardHolder ?? string.Empty; opAuth.CreditCard.CardIsEncrypted = true; opAuth.CreditCard.CardNumber = string.Empty; opAuth.CreditCard.ExpirationMonth = item.CreditCardExpMonth; opAuth.CreditCard.ExpirationYear = item.CreditCardExpYear; opAuth.CreditCard.SecurityCode = string.Empty; opAuth.GiftCardNumber = item.GiftCertificateNumber ?? string.Empty; opAuth.LinkedToTransaction = string.Empty; opAuth.Messages = item.Note ?? string.Empty; opAuth.OrderId = orderBvin ?? string.Empty; opAuth.OrderNumber = orderNumber ?? string.Empty; opAuth.PurchaseOrderNumber = item.PurchaseOrderNumber ?? string.Empty; opAuth.RefNum1 = item.TransactionReferenceNumber ?? string.Empty; opAuth.RefNum2 = item.TransactionResponseCode ?? string.Empty; opAuth.Success = true; opAuth.TimeStampUtc = item.AuditDate; opAuth.Voided = false; wl("- Creating Auth | " + opAuth.Amount + " | " + item.ID.ToString() + " | " + opAuth.Action.ToString()); var res = proxy.OrderTransactionsCreate(opAuth); if (res != null) { if (res.Errors.Count > 0) { DumpErrors(res.Errors); wl("FAILED TRANSACTION: " + item.ID.ToString()); } } else { wl("FAILED! EXCEPTION! TRANSACTION: " + item.ID.ToString()); } } if (hasCharge) { OrderTransactionDTO opCharge = new OrderTransactionDTO(); opCharge.Id = new Guid(); switch (item.PaymentMethod) { case 1: // Credit Card opCharge.Action = OrderTransactionActionDTO.CreditCardCharge; break; case 7: // Telephone case 9: // Fax case 3: // Check case 4: // Cash case 6: // Other case 8: // Email opCharge.Action = OrderTransactionActionDTO.CashReceived; break; case 10: // PO opCharge.Action = OrderTransactionActionDTO.PurchaseOrderAccepted; break; case 5: // Gift Card opCharge.Action = OrderTransactionActionDTO.GiftCardCapture; break; case 2: // PayPal Express opCharge.Action = OrderTransactionActionDTO.PayPalCharge; break; default: opCharge.Action = OrderTransactionActionDTO.CashReceived; break; } opCharge.Amount = (decimal)item.Amount; opCharge.CheckNumber = item.CheckNumber ?? string.Empty; opCharge.CreditCard = new OrderTransactionCardDataDTO(); opCharge.CreditCard.CardHolderName = item.CreditCardHolder ?? string.Empty; opCharge.CreditCard.CardIsEncrypted = true; opCharge.CreditCard.CardNumber = string.Empty; opCharge.CreditCard.ExpirationMonth = item.CreditCardExpMonth; opCharge.CreditCard.ExpirationYear = item.CreditCardExpYear; opCharge.CreditCard.SecurityCode = string.Empty; opCharge.GiftCardNumber = item.GiftCertificateNumber ?? string.Empty; opCharge.LinkedToTransaction = string.Empty; opCharge.Messages = item.Note ?? string.Empty; opCharge.OrderId = orderBvin ?? string.Empty; opCharge.OrderNumber = orderNumber ?? string.Empty; opCharge.PurchaseOrderNumber = item.PurchaseOrderNumber ?? string.Empty; opCharge.RefNum1 = item.TransactionReferenceNumber ?? string.Empty; opCharge.RefNum2 = item.TransactionResponseCode ?? string.Empty; opCharge.Success = true; opCharge.TimeStampUtc = item.AuditDate; opCharge.Voided = false; wl("- Creating Charge | " + opCharge.Amount + " | " + item.ID.ToString() + " | " + opCharge.Action.ToString()); var res = proxy.OrderTransactionsCreate(opCharge); if (res != null) { if (res.Errors.Count > 0) { DumpErrors(res.Errors); wl("FAILED TRANSACTION: " + item.ID.ToString()); } } else { wl("FAILED! EXCEPTION! TRANSACTION: " + item.ID.ToString()); } } if (hasRefund) { OrderTransactionDTO opRefund = new OrderTransactionDTO(); opRefund.Id = new Guid(); switch (item.PaymentMethod) { case 1: // Credit Card opRefund.Action = OrderTransactionActionDTO.CreditCardRefund; break; case 7: // Telephone case 9: // Fax case 3: // Check case 4: // Cash case 6: // Other case 8: // Email opRefund.Action = OrderTransactionActionDTO.CashReturned; break; case 10: // PO opRefund.Action = OrderTransactionActionDTO.CashReturned; break; case 5: // Gift Card opRefund.Action = OrderTransactionActionDTO.GiftCardIncrease; break; case 2: // PayPal Express opRefund.Action = OrderTransactionActionDTO.PayPalRefund; break; default: opRefund.Action = OrderTransactionActionDTO.CashReturned; break; } opRefund.Amount = -1 * (decimal)item.Amount; opRefund.CheckNumber = item.CheckNumber ?? string.Empty; opRefund.CreditCard = new OrderTransactionCardDataDTO(); opRefund.CreditCard.CardHolderName = item.CreditCardHolder ?? string.Empty; opRefund.CreditCard.CardIsEncrypted = true; opRefund.CreditCard.CardNumber = string.Empty; opRefund.CreditCard.ExpirationMonth = item.CreditCardExpMonth; opRefund.CreditCard.ExpirationYear = item.CreditCardExpYear; opRefund.CreditCard.SecurityCode = string.Empty; opRefund.GiftCardNumber = item.GiftCertificateNumber ?? string.Empty; opRefund.LinkedToTransaction = string.Empty; opRefund.Messages = item.Note ?? string.Empty; opRefund.OrderId = orderBvin ?? string.Empty; opRefund.OrderNumber = orderNumber ?? string.Empty; opRefund.PurchaseOrderNumber = item.PurchaseOrderNumber ?? string.Empty; opRefund.RefNum1 = item.TransactionReferenceNumber ?? string.Empty; opRefund.RefNum2 = item.TransactionResponseCode ?? string.Empty; opRefund.Success = true; opRefund.TimeStampUtc = item.AuditDate; opRefund.Voided = false; wl("- Creating Refund | " + opRefund.Amount + " | " + item.ID.ToString() + " | " + opRefund.Action.ToString()); var res = proxy.OrderTransactionsCreate(opRefund); if (res != null) { if (res.Errors.Count > 0) { DumpErrors(res.Errors); wl("FAILED TRANSACTION: " + item.ID.ToString()); } } else { wl("FAILED! EXCEPTION! TRANSACTION: " + item.ID.ToString()); } } } }
public ApiResponse<OrderTransactionDTO> OrderTransactionsUpdate(OrderTransactionDTO item) { ApiResponse<OrderTransactionDTO> result = new ApiResponse<OrderTransactionDTO>(); result = RestHelper.PostRequest<ApiResponse<OrderTransactionDTO>>(this.fullApiUri + "ordertransactions/" + Enc(item.Id.ToString()) + "?key=" + Enc(key), MerchantTribe.Web.Json.ObjectToJson(item)); return result; }