thanks, Do you know when the next version will be out?
Mike Wazee
details.CreditCard.CardOwner.Address.PostalCode = paymentInfo.BillingAddress.ZipPostalCode;
details.CreditCard.CardOwner.Payer = customer.Email;
details.PaymentDetails.ButtonSource = "nopCommerceCart";
AddressType shipToAddress = new AddressType();
Address shippingAddress = paymentInfo.ShippingAddress;
shipToAddress.Name = string.Format("{0} {1}", shippingAddress.FirstName, shippingAddress.LastName);
shipToAddress.Street1 = shippingAddress.Address1;
shipToAddress.Street2 = shippingAddress.Address2;
shipToAddress.CityName = shippingAddress.City;
if (shippingAddress.StateProvince != null)
shipToAddress.StateOrProvince = shippingAddress.StateProvince.Abbreviation;
shipToAddress.PostalCode = shippingAddress.ZipPostalCode;
shipToAddress.Country = GetPaypalCountryCodeType(shippingAddress.Country);
shipToAddress.CountryName = shippingAddress.Country.Name;
shipToAddress.CountrySpecified = true;
shipToAddress.Phone = shippingAddress.PhoneNumber;
details.PaymentDetails.ShipToAddress = shipToAddress;
DoDirectPaymentResponseType response = service2.DoDirectPayment(req);
protected void AuthorizeOrSale(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ProcessPaymentResult processPaymentResult, bool authorizeOnly)
{
InitSettings();
DoDirectPaymentReq req = new DoDirectPaymentReq();
req.DoDirectPaymentRequest = new DoDirectPaymentRequestType();
req.DoDirectPaymentRequest.Version = this.APIVersion;
DoDirectPaymentRequestDetailsType details = new DoDirectPaymentRequestDetailsType();
req.DoDirectPaymentRequest.DoDirectPaymentRequestDetails = details;
details.IPAddress = HttpContext.Current.Request.UserHostAddress;
details.PaymentAction = (authorizeOnly ? PaymentActionCodeType.Authorization : PaymentActionCodeType.Sale);
details.CreditCard = new CreditCardDetailsType()
{
CreditCardNumber = paymentInfo.CreditCardNumber,
CreditCardType = GetPaypalCreditCardType(paymentInfo.CreditCardType),
ExpMonthSpecified = true,
ExpMonth = paymentInfo.CreditCardExpireMonth,
ExpYearSpecified = true,
ExpYear = paymentInfo.CreditCardExpireYear,
CVV2 = paymentInfo.CreditCardCVV2,
CardOwner = new PayerInfoType()
{
PayerCountry = GetPaypalCountryCodeType(paymentInfo.BillingAddress.Country),
Address = new AddressType()
{
CountrySpecified = true,
Street1 = paymentInfo.BillingAddress.Address1,
Street2 = paymentInfo.BillingAddress.Address2,
CityName = paymentInfo.BillingAddress.City,
StateOrProvince = paymentInfo.BillingAddress.StateProvince.Abbreviation,
Country = GetPaypalCountryCodeType(paymentInfo.BillingAddress.Country),
PostalCode = paymentInfo.BillingAddress.ZipPostalCode,
},
Payer = customer.Email,
PayerName = new PersonNameType()
{
FirstName = paymentInfo.BillingAddress.FirstName,
LastName = paymentInfo.BillingAddress.LastName
}
}
};
Address ship = paymentInfo.ShippingAddress;
details.PaymentDetails = new PaymentDetailsType()
{
OrderTotal = new BasicAmountType()
{
Value = paymentInfo.OrderTotal.ToString("N", new CultureInfo("en-us")),
currencyID = PaypalHelper.GetPaypalCurrency(CurrencyManager.PrimaryStoreCurrency)
},
Custom = OrderGuid.ToString(),
ButtonSource = "nopCommerceCart",
ShipToAddress = new AddressType()
{
Name = string.Format("{0} {1}", ship.FirstName, ship.LastName),
Street1 = paymentInfo.ShippingAddress.Address1,
Street2 = paymentInfo.ShippingAddress.Address2,
CityName = ship.City,
StateOrProvince = ship.StateProvince.Abbreviation,
PostalCode = ship.ZipPostalCode,
Country = GetPaypalCountryCodeType(ship.Country),
CountryName = ship.Country.Name,
CountrySpecified = true,
Phone = ship.PhoneNumber,
}
};
// Add Shopping Cart Items
ShoppingCart cart = ShoppingCartManager.GetShoppingCartByCustomerSessionGUID(
ShoppingCartTypeEnum.ShoppingCart, NopContext.Current.Session.CustomerSessionGUID);
PaymentDetailsItemType[] cartItems = new PaymentDetailsItemType[cart.Count];
for(int i = 0; i < cart.Count; i++)
{
ShoppingCartItem item = cart[i];
cartItems[i] = new PaymentDetailsItemType()
{
Name = item.ProductVariant.Product.Name,
Number = item.ProductVariant.eBayProductID,
Quantity = item.Quantity.ToString(),
Amount = new BasicAmountType()
{
currencyID = PaypalHelper.GetPaypalCurrency(CurrencyManager.PrimaryStoreCurrency),
Value = (item.Quantity * item.ProductVariant.Price).ToString("N", new CultureInfo("en-us"))
}
};
};
details.PaymentDetails.PaymentDetailsItem = cartItems;
DoDirectPaymentResponseType response = service2.DoDirectPayment(req);
string error = string.Empty;
bool Success = PaypalHelper.CheckSuccess(response, out error);
if (Success)
{
processPaymentResult.AuthorizationTransactionID = response.TransactionID;
processPaymentResult.AuthorizationTransactionResult = response.Ack.ToString();
processPaymentResult.AVSResult = response.AVSCode;
processPaymentResult.AuthorizationTransactionCode = response.CVV2Code;
if (authorizeOnly)
processPaymentResult.PaymentStatus = PaymentStatusEnum.Authorized;
else
processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
}
else
{
processPaymentResult.Error = error;
processPaymentResult.FullError = error;
}
}