// private readonly ICountryCodes _countryCodes = new CountryCodesModels(); public CountryType(CountryCodeType country) { var cText = CountryCodes.GetFromCode(country.ToString()); countryCodeField = country.ToString(); valueField = cText?.Country; }
public void ConvertEnumTest() { CountryCodeType ct = CountryCodeType.AT; ebIModels.Schema.ebInterface4p1.CountryCodeType ctErg; ctErg = ct.ConvertEnum <ebIModels.Schema.ebInterface4p1.CountryCodeType>(); //var ctx = ct.ConvertEnum<CountryCodeType, ebIModels. // Assert.Fail(); }
/// <summary> /// Returns shipping cost estimates for an item for every calculated shipping service /// that the seller has offered with the listing. This is analogous to the Shipping /// Calculator seen in both the buyer and seller web pages. /// </summary> /// /// <param name="ItemID"> /// The item ID that uniquely identifies the item listing for which /// to retrieve the data. Required input. /// </param> /// /// <param name="QuantitySold"> /// Number of items sold to a single buyer and to be shipped together. /// </param> /// /// <param name="DestinationPostalCode"> /// Destination country postal code (or zipcode, for US). Ignored if no /// country code is provided. Optional tag for some countries. More likely to /// be required for large countries. /// </param> /// /// <param name="DestinationCountryCode"> /// Destination country code. If DestinationCountryCode is US, /// a postal code is required and it represents the US zip code. /// </param> /// public ShippingDetailsType GetItemShipping(string ItemID, int QuantitySold, string DestinationPostalCode, CountryCodeType DestinationCountryCode) { this.ItemID = ItemID; this.QuantitySold = QuantitySold; this.DestinationPostalCode = DestinationPostalCode; this.DestinationCountryCode = DestinationCountryCode; Execute(); return ApiResponse.ShippingDetails; }
private CountryCodeType GetCountryCodeType(Country country) { CountryCodeType payerCountry = CountryCodeType.US; try { payerCountry = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), country.TwoLetterIsoCode); } catch { } return(payerCountry); }
/// <summary> /// Get Paypal country code /// </summary> /// <param name="country">Country</param> /// <returns>Paypal country code</returns> protected CountryCodeType GetPaypalCountryCodeType(Country country) { CountryCodeType payerCountry = CountryCodeType.US; try { payerCountry = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), country.TwoLetterISOCode); } catch { } return(payerCountry); }
/// <summary> /// Get Paypal country code /// </summary> /// <param name="country">Country</param> /// <returns>Paypal country code</returns> public static CountryCodeType GetPaypalCountryCodeType(Country country) { CountryCodeType payerCountry = CountryCodeType.US; try { payerCountry = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), country.TwoLetterIsoCode); } catch { } return(payerCountry); }
// http://developer.ebay.com/devzone/xml/docs/reference/ebay/types/AddressType.html public void AddSellerContactDetails(string city, string companyname, CountryCodeType country, string streetaddress, string phone, string postcode, string state) { item.SellerContactDetails = new AddressType() { CityName = city, CompanyName = companyname, Country = country, Phone = phone, PostalCode = postcode, StateOrProvince = state, Street = streetaddress }; }
/// <summary> /// Inspects the string and determines on the length which country code type to use in the PTV request /// </summary> /// <param name="country">The country string</param> /// <returns>A list of options to instruct PTV to override the default country code types</returns> private IEnumerable <PtvRequestOption> GetCountryCode(string country) { int countryCodeLength = (country ?? string.Empty).Length; if (countryCodeLength <= 0) { yield break; } // Pick ISO2 or ISO3 if they match the length - else use the country name at own risk CountryCodeType codeType = countryCodeLength == 2 ? CountryCodeType.Iso2 : countryCodeLength == 3 ? CountryCodeType.Iso3 : CountryCodeType.CountryName; yield return(new PtvRequestOption("COUNTRY_CODETYPE", ((int)codeType).ToString())); }
public void GetItemShipping() { Assert.IsNotNull(TestData.NewItem, "Failed because no item available -- requires successful AddItem test"); // GetItemShippingCall api = new GetItemShippingCall(this.apiContext); string itemID = TestData.NewItem.ItemID; string postalCode = "95125"; int quantitySold = 1; CountryCodeType countryCode = CountryCodeType.US; // Make API call. ShippingDetailsType shippingDetails = api.GetItemShipping(itemID, quantitySold, postalCode, countryCode); //check whether the call is success. Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning, "do not success!"); Assert.IsNotNull(shippingDetails); }
/// <summary> /// This is the base request type of the <b>GetItemShipping</b> call. This call takes an <b>ItemID</b> value for an item that has yet to be shipped, and then returns estimated shipping costs for every shipping service that the seller has offered with the listing. This call will also return <b>PickUpInStoreDetails.EligibleForPickupDropOff</b> and <b>PickUpInStoreDetails.EligibleForPickupInStore</b> flags if the item is available for buyer pick-up through the In-Store Pickup or Click and Collect features. /// </summary> /// /// <param name="ItemID"> /// The unique identifier of the eBay listing for which to retrieve estimated shipping costs for all offered shipping service options. The <b>ItemID</b> value passed into this field should be for an listing that offers at least one calculated shipping service option, and for an item that has yet to be shipped. /// </param> /// /// <param name="QuantitySold"> /// This field is used to specify the quantity of the item. The <b>QuantitySold</b> value defaults to <code>1</code> if not specified. If a value greater than <code>1</code> is specified in this field, the shipping service costs returned in the response will reflect the expense to ship multiple quantity of an item. /// </param> /// /// <param name="DestinationPostalCode"> /// The destination postal code (or zip code for US) is supplied in this field. <b>GetItemShipping</b> requires the destination of the shipment. Some countries will require both the <b>DestinationPostalCode</b> and the lt;b>DestinationCountryCode</b>, and some countries will accept either one or the other. /// </param> /// /// <param name="DestinationCountryCode"> /// The destination country code is supplied in this field. <b>GetItemShipping</b> requires the destination of the shipment. Some countries will require both the <b>DestinationPostalCode</b> and the lt;b>DestinationCountryCode</b>, and some countries will accept either one or the other. /// /// Two-digit country codes can be found in <a href="types/CountryCodeType.html">CountryCodeType</a>. /// </param> /// public ShippingDetailsType GetItemShipping(string ItemID, int QuantitySold, string DestinationPostalCode, CountryCodeType DestinationCountryCode) { this.ItemID = ItemID; this.QuantitySold = QuantitySold; this.DestinationPostalCode = DestinationPostalCode; this.DestinationCountryCode = DestinationCountryCode; Execute(); return(ApiResponse.ShippingDetails); }
public DoDirectPaymentResponseType DoDirectPayment(string paymentAmount, string buyerBillingLastName, string buyerBillingFirstName, string buyerShippingLastName, string buyerShippingFirstName, string buyerBillingAddress1, string buyerBillingAddress2, string buyerBillingCity, string buyerBillingState, string buyerBillingPostalCode, CountryCodeType buyerBillingCountryCode, string creditCardType, string creditCardNumber, string CVV2, int expMonth, int expYear, PaymentActionCodeType paymentAction, string ipAddress, string buyerShippingAddress1, string buyerShippingAddress2, string buyerShippingCity, string buyerShippingState, string buyerShippingPostalCode, CountryCodeType buyerShippingCountryCode, string invoiceId) { // Create the request object DoDirectPaymentRequestType pp_Request = new DoDirectPaymentRequestType(); // Create the request details object pp_Request.DoDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType(); pp_Request.DoDirectPaymentRequestDetails.IPAddress = ipAddress; pp_Request.DoDirectPaymentRequestDetails.MerchantSessionId = ""; pp_Request.DoDirectPaymentRequestDetails.PaymentAction = paymentAction; pp_Request.DoDirectPaymentRequestDetails.CreditCard = new CreditCardDetailsType(); pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardNumber = creditCardNumber; switch (creditCardType) { case "Visa": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Visa; break; case "MasterCard": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.MasterCard; break; case "Discover": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Discover; break; case "Amex": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Amex; break; } pp_Request.DoDirectPaymentRequestDetails.CreditCard.CVV2 = CVV2; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonth = expMonth; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYear = expYear; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonthSpecified = true; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYearSpecified = true; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner = new PayerInfoType(); pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Payer = ""; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerID = ""; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerStatus = PayPalUserStatusCodeType.unverified; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerCountry = CountryCodeType.US; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address = new AddressType(); pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street1 = buyerBillingAddress1; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street2 = buyerBillingAddress2; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CityName = buyerBillingCity; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.StateOrProvince = buyerBillingState; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.PostalCode = buyerBillingPostalCode; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Country = buyerBillingCountryCode; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountrySpecified = true; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails = new PaymentDetailsType(); pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress = new AddressType(); pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.Name = buyerShippingFirstName + " " + buyerShippingLastName; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.Street1 = buyerShippingAddress1; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.Street2 = buyerShippingAddress2; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.CityName = buyerShippingCity; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.StateOrProvince = buyerShippingState; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.PostalCode = buyerShippingPostalCode; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.Country = buyerShippingCountryCode; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.CountrySpecified = true; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName = new PersonNameType(); pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.FirstName = buyerBillingFirstName; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.LastName = buyerBillingLastName; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal = new BasicAmountType(); pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.InvoiceID = invoiceId; // NOTE: The only currency supported by the Direct Payment API at this time is US dollars (USD). pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.currencyID = CurrencyCodeType.USD; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.Value = paymentAmount; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ButtonSource = "BVCommerce_Cart_DP_US"; return (DoDirectPaymentResponseType)caller.Call("DoDirectPayment", pp_Request); }
/// <summary> /// /// </summary> public CountryDetailsType getCountryDetailsByCountryCode(CountryCodeType countryCode) { return (CountryDetailsType)_CountryDetailsByCountry[countryCode]; }
public void GetAlpha2CountryCodeTest(string iso3code, CountryCodeType expected) { var result = CountriesAndStates.GetAlpha2CountryCode(iso3code); Assert.Equal(expected, result); }
public DoDirectPaymentResponseType DoDirectPayment(string paymentAmount, string buyerBillingLastName, string buyerBillingFirstName, string buyerShippingLastName, string buyerShippingFirstName, string buyerBillingAddress1, string buyerBillingAddress2, string buyerBillingCity, string buyerBillingState, string buyerBillingPostalCode, CountryCodeType buyerBillingCountryCode, string creditCardType, string creditCardNumber, string CVV2, int expMonth, int expYear, PaymentActionCodeType paymentAction, string ipAddress, string buyerShippingAddress1, string buyerShippingAddress2, string buyerShippingCity, string buyerShippingState, string buyerShippingPostalCode, CountryCodeType buyerShippingCountryCode, string invoiceId) { // Create the request object DoDirectPaymentRequestType pp_Request = new DoDirectPaymentRequestType(); // Create the request details object pp_Request.DoDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType(); pp_Request.DoDirectPaymentRequestDetails.IPAddress = ipAddress; pp_Request.DoDirectPaymentRequestDetails.MerchantSessionId = ""; pp_Request.DoDirectPaymentRequestDetails.PaymentAction = paymentAction; pp_Request.DoDirectPaymentRequestDetails.CreditCard = new CreditCardDetailsType(); pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardNumber = creditCardNumber; switch (creditCardType) { case "Visa": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Visa; break; case "MasterCard": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.MasterCard; break; case "Discover": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Discover; break; case "Amex": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Amex; break; } pp_Request.DoDirectPaymentRequestDetails.CreditCard.CVV2 = CVV2; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonth = expMonth; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYear = expYear; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonthSpecified = true; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYearSpecified = true; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner = new PayerInfoType(); pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Payer = ""; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerID = ""; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerStatus = PayPalUserStatusCodeType.unverified; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerCountry = CountryCodeType.US; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address = new AddressType(); pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street1 = buyerBillingAddress1; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street2 = buyerBillingAddress2; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CityName = buyerBillingCity; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.StateOrProvince = buyerBillingState; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.PostalCode = buyerBillingPostalCode; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Country = buyerBillingCountryCode; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountrySpecified = true; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails = new PaymentDetailsType(); pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress = new AddressType(); pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.Name = buyerShippingFirstName + " " + buyerShippingLastName; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.Street1 = buyerShippingAddress1; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.Street2 = buyerShippingAddress2; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.CityName = buyerShippingCity; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.StateOrProvince = buyerShippingState; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.PostalCode = buyerShippingPostalCode; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.Country = buyerShippingCountryCode; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShipToAddress.CountrySpecified = true; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName = new PersonNameType(); pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.FirstName = buyerBillingFirstName; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.LastName = buyerBillingLastName; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal = new BasicAmountType(); pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.InvoiceID = invoiceId; // NOTE: The only currency supported by the Direct Payment API at this time is US dollars (USD). pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.currencyID = CurrencyCodeType.USD; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.Value = paymentAmount; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ButtonSource = "BVCommerce_Cart_DP_US"; return((DoDirectPaymentResponseType)caller.Call("DoDirectPayment", pp_Request)); }
/// <summary> /// For backward compatibility with old wrappers. /// </summary> public ShippingDetailsType GetItemShipping(string ItemID, string DestinationPostalCode, CountryCodeType DestinationCountryCode) { this.DestinationCountryCode = DestinationCountryCode; this.ItemID = ItemID; this.DestinationPostalCode = DestinationPostalCode; Execute(); return ShippingDetails; }
/// <summary> /// For backward compatibility with old wrappers. /// </summary> public ShippingDetailsType GetItemShipping(string ItemID, string DestinationPostalCode, CountryCodeType DestinationCountryCode) { this.DestinationCountryCode = DestinationCountryCode; this.ItemID = ItemID; this.DestinationPostalCode = DestinationPostalCode; Execute(); return(ShippingDetails); }
// startprice = starting price for auctions, selling price for fixeditems public ItemType BuildItem(SiteCodeType site, ListingTypeCodeType listingType, string title, string description, CurrencyCodeType currency, double?buynowPrice, double startPrice, double?reservePrice, string location, CountryCodeType country, int categoryid, int quantity, int?conditionID, ReturnsAccepted returns, string listingDuration, string refund_policy, string return_within, int dispatch_time, string paypal_email) { item = new ItemType(); item.Site = site; // item title item.Title = title; // item description // append powered by tradelr if (description.IndexOf("http://wwww.tradelr.com/Content/img/tradelr.png") == -1) { item.Description = string.Format("{0}<p> </p><p><center><img src='http://wwww.tradelr.com/Content/img/tradelr.png' /><div>powered by <a target='_blank' href='http://www.tradelr.com'>tradelr</a></div></center></p>", description); } else { item.Description = description; } // http://developer.ebay.com/DevZone/xml/docs/Reference/ebay/types/ListingTypeCodeType.html item.ListingType = listingType; // prices item.Currency = currency; item.StartPrice = new AmountType { Value = startPrice, currencyID = currency }; if (buynowPrice.HasValue) { item.BuyItNowPrice = new AmountType { Value = buynowPrice.Value, currencyID = currency }; } if (reservePrice.HasValue) { item.ReservePrice = new AmountType() { Value = reservePrice.Value, currencyID = currency }; } // listing duration item.ListingDuration = listingDuration; // item location and country item.Location = location; item.Country = country; // listing category, Photography Software var category = new CategoryType(); category.CategoryID = categoryid.ToString(); item.PrimaryCategory = category; // item quality item.Quantity = quantity; // payment methods item.PaymentMethods = paymentOptions; // email is required if paypal is used as payment method item.PayPalEmailAddress = paypal_email; // http://developer.ebay.com/devzone/finding/callref/Enums/conditionIdList.html if (conditionID.HasValue) { item.ConditionID = conditionID.Value; } item.DispatchTimeMax = dispatch_time; // return policy var policy = new ReturnPolicyType { ReturnsAcceptedOption = returns.ToString(), ShippingCostPaidByOption = "Buyer" }; if (returns == ReturnsAccepted.ReturnsAccepted) { policy.Refund = refund_policy; policy.ReturnsWithinOption = return_within; } item.ReturnPolicy = policy; return(item); }
public Commerce.Common.Transaction DoDirectCheckout(Commerce.Common.Order order, bool AuthOnly) { PayPalSvc.DoDirectPaymentReq req = new DoDirectPaymentReq(); req.DoDirectPaymentRequest = new DoDirectPaymentRequestType(); req.DoDirectPaymentRequest.Version = PayPalServiceUtility.PayPalAPIVersionNumber; DoDirectPaymentRequestDetailsType details = new DoDirectPaymentRequestDetailsType(); details.CreditCard = new CreditCardDetailsType(); details.CreditCard.CardOwner = new PayerInfoType(); details.CreditCard.CardOwner.Address = new AddressType(); details.CreditCard.CardOwner.PayerName = new PersonNameType(); details.PaymentDetails = new PaymentDetailsType(); CountryCodeType payerCountry = CountryCodeType.US; if (order.BillingAddress.Country != "US") { try { payerCountry = (CountryCodeType)StringToEnum(typeof(CountryCodeType), order.BillingAddress.Country); } catch { } } details.CreditCard.CardOwner.Address.Country = payerCountry; details.CreditCard.CardOwner.PayerCountry = payerCountry; details.CreditCard.CardOwner.Address.CountrySpecified = true; details.CreditCard.CardOwner.Address.Street1 = order.BillingAddress.Address1; details.CreditCard.CardOwner.Address.Street2 = order.BillingAddress.Address2; details.CreditCard.CardOwner.Address.CityName = order.BillingAddress.City; details.CreditCard.CardOwner.Address.StateOrProvince = order.BillingAddress.StateOrRegion; details.CreditCard.CardOwner.Address.PostalCode = order.BillingAddress.Zip; details.CreditCard.CardOwner.PayerName.FirstName = order.BillingAddress.FirstName; details.CreditCard.CardOwner.PayerName.LastName = order.BillingAddress.LastName; //the basics int roundTo = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits; decimal dTotal = Math.Round(order.CalculateSubTotal(), roundTo) + Math.Round(order.TaxAmount, roundTo) + Math.Round(order.ShippingAmount, roundTo); details.PaymentDetails.OrderTotal = GetBasicAmount(dTotal); details.PaymentDetails.ShippingTotal = this.GetBasicAmount(Math.Round(order.ShippingAmount, roundTo)); details.PaymentDetails.TaxTotal = this.GetBasicAmount(Math.Round(order.TaxAmount, roundTo)); details.PaymentDetails.Custom = order.OrderNumber; details.PaymentDetails.ItemTotal = GetBasicAmount(Math.Round(order.CalculateSubTotal(), roundTo)); details.PaymentDetails.ButtonSource = DP_BN_ID; //credit card details.CreditCard.CreditCardNumber = order.CreditCardNumber; CreditCardTypeType ccType = CreditCardTypeType.Visa; switch (order.CreditCardType) { case Commerce.Common.CreditCardType.MasterCard: ccType = CreditCardTypeType.MasterCard; break; case Commerce.Common.CreditCardType.Amex: ccType = CreditCardTypeType.Amex; break; } details.CreditCard.CreditCardType = ccType; details.CreditCard.ExpMonth = Convert.ToInt16(order.CreditCardExpireMonth); details.CreditCard.ExpYear = Convert.ToInt16(order.CreditCardExpireYear); details.CreditCard.CVV2 = order.CreditCardSecurityNumber; //set the IP - required details.IPAddress = order.UserIP; //set the req var to details req.DoDirectPaymentRequest.DoDirectPaymentRequestDetails = details; //sale type if (AuthOnly) { details.PaymentAction = PaymentActionCodeType.Authorization; } else { details.PaymentAction = PaymentActionCodeType.Sale; } //send the request DoDirectPaymentResponseType response = service2.DoDirectPayment(req); string errors = this.CheckErrors(response); Commerce.Common.Transaction trans = new Commerce.Common.Transaction(); trans.OrderID = order.OrderID; string sOut = ""; if (errors == string.Empty) { trans.GatewayResponse = response.Ack.ToString(); trans.AuthorizationCode = response.TransactionID; trans.CVV2Code = response.CVV2Code; } else { trans.GatewayResponse = errors; throw new Exception(errors); } return(trans); }
/// <summary> /// /// </summary> public CountryDetailsType getCountryDetailsByCountryCode(CountryCodeType countryCode) { return((CountryDetailsType)_CountryDetailsByCountry[countryCode]); }
static public OrderInfo Charge(string firstName, string lastName, string address1, string address2, string city, string state, string zip, string country, string ccType, string ccNumber, string ccAuthCode, int ccExpireYear, int ccExpireMonth, decimal priceFinal, decimal priceTax, decimal priceShipping) { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; CreditCardTypeType cardType = CreditCardTypeType.Visa; switch (ccType) { case "Visa": case "MasterCard": case "Discover": cardType = (CreditCardTypeType)Enum.Parse(typeof(CreditCardTypeType), ccType.ToString()); break; case "AMEX": cardType = CreditCardTypeType.Amex; break; default: cardType = CreditCardTypeType.Visa; break; } CountryCodeType countryCode = CountryCodeType.US; try { countryCode = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), country); } catch { countryCode = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), Robo.Country.NameToCode(country)); } finally { countryCode = CountryCodeType.US; } using (var client = new PayPalAPIAAInterfaceClient(new BasicHttpsBinding(), new EndpointAddress(EndpointUrl))) { var credentials = new CustomSecurityHeaderType() { Credentials = new UserIdPasswordType() { Username = APIUserName, Password = APIPassword, Signature = APISignature } }; DoDirectPaymentReq req = new DoDirectPaymentReq() { DoDirectPaymentRequest = new DoDirectPaymentRequestType() { Version = "121.0", DoDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType() { CreditCard = new CreditCardDetailsType() { CardOwner = new PayerInfoType() { PayerName = new PersonNameType() { FirstName = firstName, LastName = lastName }, Address = new AddressType() { CityName = city, StateOrProvince = state, PostalCode = zip, Country = countryCode, Street1 = address1, Street2 = address2 } }, CreditCardNumber = ccNumber, CreditCardType = cardType, CreditCardTypeSpecified = true, CVV2 = ccAuthCode, ExpMonth = ccExpireMonth, ExpMonthSpecified = true, ExpYear = ccExpireYear, ExpYearSpecified = true }, PaymentAction = PaymentActionCodeType.Sale, PaymentDetails = new PaymentDetailsType() { OrderTotal = new BasicAmountType() { currencyID = CurrencyCodeType.USD, Value = priceFinal.ToString("F2") }, ShippingTotal = new BasicAmountType() { currencyID = CurrencyCodeType.USD, Value = priceShipping.ToString("F2") }, TaxTotal = new BasicAmountType() { currencyID = CurrencyCodeType.USD, Value = priceTax.ToString("F2") } } } } }; var response = client.DoDirectPayment(ref credentials, req); // check errors string errors = CheckErrors(response); OrderInfo info = new OrderInfo(); if (errors == String.Empty) { info.Ack = response.Ack.ToString(); info.TransactionID = response.TransactionID; info.CVV2Code = response.CVV2Code; } else { info.Ack = errors; } return(info); } }
public DoDirectPaymentResponseType DoDirectPayment(string paymentAmount, string buyerBillingLastName, string buyerBillingFirstName, string buyerShippingLastName, string buyerShippingFirstName, string buyerBillingAddress1, string buyerBillingAddress2, string buyerBillingCity, string buyerBillingState, string buyerBillingPostalCode, CountryCodeType buyerBillingCountryCode, string creditCardType, string creditCardNumber, string CVV2, int expMonth, int expYear, PaymentActionCodeType paymentAction, string ipAddress, string buyerShippingAddress1, string buyerShippingAddress2, string buyerShippingCity, string buyerShippingState, string buyerShippingPostalCode, CountryCodeType buyerShippingCountryCode, string invoiceId, CurrencyCodeType storeCurrency) { // Create the request object var pp_Request = new DoDirectPaymentRequestType { DoDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType { IPAddress = ipAddress, MerchantSessionId = string.Empty, PaymentAction = paymentAction, CreditCard = new CreditCardDetailsType { CreditCardNumber = creditCardNumber } } }; // Create the request details object switch (creditCardType) { case "Visa": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Visa; break; case "MasterCard": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.MasterCard; break; case "Discover": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Discover; break; case "Amex": pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Amex; break; } pp_Request.DoDirectPaymentRequestDetails.CreditCard.CVV2 = CVV2; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonth = expMonth; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYear = expYear; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonthSpecified = true; pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYearSpecified = true; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner = new PayerInfoType { Payer = string.Empty, PayerID = string.Empty, PayerStatus = PayPalUserStatusCodeType.unverified, PayerCountry = CountryCodeType.US, Address = new AddressType { Street1 = buyerBillingAddress1, Street2 = buyerBillingAddress2, CityName = buyerBillingCity, StateOrProvince = buyerBillingState, PostalCode = buyerBillingPostalCode, Country = buyerBillingCountryCode, CountrySpecified = true } }; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails = new PaymentDetailsType { ShipToAddress = new AddressType { Name = buyerShippingFirstName + " " + buyerShippingLastName, Street1 = buyerShippingAddress1, Street2 = buyerShippingAddress2, CityName = buyerShippingCity, StateOrProvince = buyerShippingState, PostalCode = buyerShippingPostalCode, Country = buyerShippingCountryCode, CountrySpecified = true } }; pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName = new PersonNameType { FirstName = buyerBillingFirstName, LastName = buyerBillingLastName }; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal = new BasicAmountType(); pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.InvoiceID = invoiceId; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.currencyID = storeCurrency; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.Value = paymentAmount; pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ButtonSource = "HotcakesCommerce_Cart_DP_US"; return((DoDirectPaymentResponseType)caller.Call("DoDirectPayment", pp_Request)); }
public com.paypal.soap.api.DoDirectPaymentResponseType TakeCardPayment( com.paypal.soap.api.CreditCardTypeType cardType, string cardNumber, int startMonth, int startYear, int expMonth, int expYear, int CVV2, string firstName, string lastName, string payerName, string street1, string street2, string city, string state, string postCode, CountryCodeType country, decimal amount, com.paypal.soap.api.CurrencyCodeType currency, string ipAddress, com.paypal.soap.api.PaymentActionCodeType paymentType) { CallerServices caller = new CallerServices(); IAPIProfile profile = ProfileFactory.createSignatureAPIProfile(); profile.APIUsername = APIUsername; profile.APIPassword = APIPassword; profile.Environment = StartPage.UseTestEnvironment ? "sandbox" : "live"; profile.Subject = ""; profile.APISignature = APISignature; caller.APIProfile = profile; com.paypal.soap.api.DoDirectPaymentRequestDetailsType directPaymentDetails = new com.paypal.soap.api.DoDirectPaymentRequestDetailsType(); //Set Credit Card com.paypal.soap.api.CreditCardDetailsType cc = new com.paypal.soap.api.CreditCardDetailsType(); cc.CreditCardType = cardType; cc.CreditCardNumber = cardNumber; cc.StartMonth = startMonth; cc.StartMonthSpecified = true; cc.StartYear = startYear; cc.StartYearSpecified = true; cc.ExpMonth = expMonth; cc.ExpMonthSpecified = true; cc.ExpYear = expYear; cc.ExpYearSpecified = true; cc.CVV2 = CVV2.ToString(); //Set Credit Card.CardOwner com.paypal.soap.api.PayerInfoType theCardOwner = new com.paypal.soap.api.PayerInfoType(); com.paypal.soap.api.PersonNameType thePayerName = new com.paypal.soap.api.PersonNameType(); thePayerName.FirstName = firstName; thePayerName.LastName = lastName; theCardOwner.PayerName = thePayerName; com.paypal.soap.api.AddressType theAddress = new com.paypal.soap.api.AddressType(); theAddress.Street1 = street1; theAddress.Street2 = street2; theAddress.CityName = city; theAddress.StateOrProvince = state; theAddress.PostalCode = postCode; theAddress.Country = country; theCardOwner.Address = theAddress; cc.CardOwner = theCardOwner; directPaymentDetails.CreditCard = cc; //Set Order Total com.paypal.soap.api.BasicAmountType temp = new com.paypal.soap.api.BasicAmountType(); com.paypal.soap.api.PaymentDetailsType payDetailType = new com.paypal.soap.api.PaymentDetailsType(); temp.Value = string.Format("{0:0.00}", amount); temp.currencyID = currency; payDetailType.OrderTotal = temp; directPaymentDetails.PaymentDetails = payDetailType; //Set IP directPaymentDetails.IPAddress = ipAddress; //Set Transaction Type directPaymentDetails.PaymentAction = paymentType; //Set Request com.paypal.soap.api.DoDirectPaymentRequestType request = new com.paypal.soap.api.DoDirectPaymentRequestType(); //Set Payment Detail request.DoDirectPaymentRequestDetails = directPaymentDetails; request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountrySpecified = true; return (com.paypal.soap.api.DoDirectPaymentResponseType)caller.Call("DoDirectPayment", request); }