public static void createCustomerProfileTransactionRequest(createCustomerProfileTransactionRequest request) { if (null != request) { profileTransactionType(request.transaction); } }
/// <summary> /// Captures the specified transaction. /// </summary> /// <param name="profileID">The profile ID.</param> /// <param name="paymentProfileId">The payment profile id.</param> /// <param name="shippingProfileId">The id of the shipping information to use for the transaction.</param> /// <param name="transId">The transaction id to mark to capture (settle).</param> /// <param name="amount">The decimal amount to capture.</param> /// <returns></returns> public IGatewayResponse PriorAuthCapture(string profileID, string paymentProfileId, string shippingProfileId, string transId, Decimal amount) { var req = new createCustomerProfileTransactionRequest(); var trans = new profileTransPriorAuthCaptureType(); if (!String.IsNullOrEmpty(profileID)) { trans.customerProfileId = profileID; } if (!String.IsNullOrEmpty(paymentProfileId)) { trans.customerPaymentProfileId = paymentProfileId; } trans.transId = transId; //required trans.amount = amount; // required. if (!String.IsNullOrEmpty(shippingProfileId)) { trans.customerShippingAddressId = shippingProfileId; } req.transaction = new profileTransactionType(); req.transaction.Item = trans; var response = (createCustomerProfileTransactionResponse)_gateway.Send(req); return(new GatewayResponse(response.directResponse.Split(','))); }
/// <summary> /// Voids a previously authorized transaction /// </summary> /// <param name="profileID">The profile ID.</param> /// <param name="paymentProfileId">The payment profile id.</param> /// <param name="transactionId">The transaction id.</param> /// <returns></returns> public IGatewayResponse Void(string profileID, string paymentProfileId, string transactionId) { var req = new createCustomerProfileTransactionRequest(); var trans = new profileTransVoidType(); trans.customerProfileId = profileID; trans.customerPaymentProfileId = paymentProfileId; trans.transId = transactionId; req.transaction = new profileTransactionType(); req.transaction.Item = trans; var response = (createCustomerProfileTransactionResponse)_gateway.Send(req); return(new GatewayResponse(response.directResponse.Split(','))); }
/// <summary> /// Refunds a transaction for the specified amount /// </summary> /// <param name="profileID">The profile ID.</param> /// <param name="paymentProfileId">The payment profile id.</param> /// <param name="transactionId">The transaction id.</param> /// <param name="approvalCode">The approval code.</param> /// <param name="amount">The amount.</param> /// <returns></returns> public IGatewayResponse Refund(string profileID, string paymentProfileId, string transactionId, string approvalCode, decimal amount) { var req = new createCustomerProfileTransactionRequest(); var trans = new profileTransRefundType(); trans.amount = amount; trans.customerProfileId = profileID; trans.customerPaymentProfileId = paymentProfileId; trans.transId = transactionId; req.transaction = new profileTransactionType(); req.transaction.Item = trans; var response = (createCustomerProfileTransactionResponse)_gateway.Send(req); return(new GatewayResponse(response.directResponse.Split(','))); }
public void MockcreateCustomerProfileTransactionTest() { //define all mocked objects as final var mockController = GetMockController <createCustomerProfileTransactionRequest, createCustomerProfileTransactionResponse>(); var mockRequest = new createCustomerProfileTransactionRequest { merchantAuthentication = new merchantAuthenticationType { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, transaction = new profileTransactionType { Item = new profileTransAuthCaptureType(), }, }; var transactionResponse = new transactionResponse() { accountNumber = "1234", }; var mockResponse = new createCustomerProfileTransactionResponse { refId = "1234", sessionToken = "sessiontoken", transactionResponse = transactionResponse, }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <createCustomerProfileTransactionRequest, createCustomerProfileTransactionResponse, createCustomerProfileTransactionController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.transactionResponse); LogHelper.info(Logger, "createCustomerProfileTransaction: Details:{0}", controllerResponse.transactionResponse); }
/// <summary> /// Captures the specified transaction. /// </summary> /// <param name="profileID">The profile ID.</param> /// <param name="paymentProfileId">The payment profile id.</param> /// <param name="cardCode">The 3 or 4 digit card code in the signature space.</param> /// <param name="amount">The amount.</param> /// <param name="approvalCode">The approval code.</param> /// <returns></returns> public IGatewayResponse Capture(string profileID, string paymentProfileId, string cardCode, decimal amount, string approvalCode) { var req = new createCustomerProfileTransactionRequest(); var trans = new profileTransCaptureOnlyType(); trans.approvalCode = approvalCode; trans.customerProfileId = profileID; trans.amount = amount; if (!String.IsNullOrEmpty(cardCode)) { trans.cardCode = cardCode; } trans.customerPaymentProfileId = paymentProfileId; req.transaction = new profileTransactionType(); req.transaction.Item = trans; var response = (createCustomerProfileTransactionResponse)_gateway.Send(req); return(new GatewayResponse(response.directResponse.Split(','))); }
/// <summary> /// Authorizes a transaction using the supplied profile information, abstracted through an Order object. Using the Order /// you can add line items, specify shipping and tax, etc. /// </summary> /// <param name="order">The order.</param> /// <returns>A string representing the approval code</returns> public IGatewayResponse Authorize(Order order) { var req = new createCustomerProfileTransactionRequest(); var trans = new profileTransAuthOnlyType(); trans.customerProfileId = order.CustomerProfileID; trans.customerPaymentProfileId = order.PaymentProfileID; trans.amount = order.Total; //order information trans.order = new orderExType(); trans.order.description = order.Description; trans.order.invoiceNumber = order.InvoiceNumber; trans.order.purchaseOrderNumber = order.PONumber; if (!String.IsNullOrEmpty(order.ShippingAddressProfileID)) { trans.customerShippingAddressId = order.ShippingAddressProfileID; } if (order.SalesTaxAmount > 0) { trans.tax = new extendedAmountType { amount = order.SalesTaxAmount, description = order.SalesTaxName, name = order.SalesTaxName } } ; if (order.ShippingAmount > 0) { trans.shipping = new extendedAmountType { amount = order.ShippingAmount, description = order.ShippingName, name = order.ShippingName } } ; //line items if (order._lineItems.Count > 0) { trans.lineItems = order._lineItems.ToArray(); } if (order.TaxExempt.HasValue) { trans.taxExempt = order.TaxExempt.Value; trans.taxExemptSpecified = true; } if (order.RecurringBilling.HasValue) { trans.recurringBilling = order.RecurringBilling.Value; trans.recurringBillingSpecified = true; } if (!String.IsNullOrEmpty(order.CardCode)) { trans.cardCode = order.CardCode; } req.transaction = new profileTransactionType(); req.transaction.Item = trans; req.extraOptions = order.ExtraOptions; var response = (createCustomerProfileTransactionResponse)_gateway.Send(req); return(new GatewayResponse(response.directResponse.Split(','))); }
/// <summary> /// Authorizes and Captures a transaction using the supplied profile information, abstracted through an Order object. Using the Order /// you can add line items, specify shipping and tax, etc. /// </summary> /// <param name="order">The order.</param> /// <returns></returns> public IGatewayResponse AuthorizeAndCapture(Order order) { var req = new createCustomerProfileTransactionRequest(); var trans = new profileTransAuthCaptureType(); trans.customerProfileId = order.CustomerProfileID; trans.customerPaymentProfileId = order.PaymentProfileID; trans.amount = order.Total; if (!String.IsNullOrEmpty(order.ShippingAddressProfileID)) { trans.customerShippingAddressId = order.ShippingAddressProfileID; } if (order.SalesTaxAmount > 0) { trans.tax = new extendedAmountType { amount = order.SalesTaxAmount, description = order.SalesTaxName, name = order.SalesTaxName } } ; if (order.ShippingAmount > 0) { trans.shipping = new extendedAmountType { amount = order.ShippingAmount, description = order.ShippingName, name = order.ShippingName } } ; //line items if (order._lineItems.Count > 0) { trans.lineItems = order._lineItems.ToArray(); } if (order.TaxExempt.HasValue) { trans.taxExempt = order.TaxExempt.Value; trans.taxExemptSpecified = true; } if (order.RecurringBilling.HasValue) { trans.recurringBilling = order.RecurringBilling.Value; trans.recurringBillingSpecified = true; } if (!String.IsNullOrEmpty(order.CardCode)) { trans.cardCode = order.CardCode; } req.transaction = new profileTransactionType(); req.transaction.Item = trans; var response = (createCustomerProfileTransactionResponse)_gateway.Send(req); if (response.directResponse != null && response.messages.resultCode == messageTypeEnum.Ok) { return(new GatewayResponse(response.directResponse.Split(','))); } else { //response.messages.message.ToString(), response.messages.resultCode.ToString() string respMessages = string.Empty; response.messages.message.ToList().ForEach(a => respMessages += a.code + "-" + a.text); return(new GatewayResponse { RawResponse = new string[] { response.messages.resultCode.ToString(), string.Empty, string.Empty, respMessages } }); } }