|
|
|
|
Get cart contents in custom payment gateway
Last post Wed, Oct 15 2008, 12:08 AM by truthbrother. 7 replies.
-
Wed, Oct 01 2008, 2:00 AM |
-
victorgunta
-
-
-
Joined on 04-21-2008
-
-
Posts 72
-
-
|
Get cart contents in custom payment gateway
Hello,
Starting from the GenericGateway i made my own gateway, but i can't seem to get the current cart contents. This is the code i have in the Charge() procedure :
Cart cart = ClientCart.GetCart();
if (cart != null && cart.CartItems != null) { int cartItems = 0; foreach (CartItem item in cart.CartItems.CartItem) { //Gateway.AddProduct(item.ProductTitle, item.CartItemId.ToString(), "", item.Price.ToString(), item.Quantity.ToString(), "19", ""); Gateway.AddProduct(item.ProductTitle, "", "", "", "", "19", ""); cartItems++; } }
All the item properties are null.
|
|
-
Wed, Oct 01 2008, 4:01 AM |
-
victorgunta
-
-
-
Joined on 04-21-2008
-
-
Posts 72
-
-
|
Re: Get cart contents in custom payment gateway
Nevermind, i've fixed it. The AddProduct procedure was faulty.
However, i have a different problem now. When the user clicks "Confirm order" i have to redirect it to the payment gateway page. But in the event log, i get
WebServices.OrderCreate:Complete ---> System.Threading.ThreadAbortException: Thread was being aborted.
|
|
-
Fri, Oct 03 2008, 10:04 AM |
-
truthbrother
-
-
-
Joined on 12-21-2006
-
Los Angeles, CA
-
Posts 201
-
-
|
Re: Get cart contents in custom payment gateway
It might be hard for us to help you since you created your own custom gateway. Can you provide any more details with the steps you took, a screenshot, etc.?
Mediachase Software
|
|
-
Fri, Oct 03 2008, 2:21 PM |
-
victorgunta
-
-
-
Joined on 04-21-2008
-
-
Posts 72
-
-
|
Re: Get cart contents in custom payment gateway
I started from the GenericGateway class. It has only the Charge() method :
public class ePaymentGateway : IPaymentGateway { public bool Charge(IPaymentInfo info, ref string message) { ePayGateway Gateway = new ePayGateway(); Cart cart = ClientCart.GetCart();
if (cart != null && cart.CartItems != null) { Gateway.MerchantID = ClientConfig.GetParamValue("ePayment","MerchantID"); Gateway.Key = ClientConfig.GetParamValue("ePayment","MerchantKey"); Gateway.Url = ClientConfig.GetParamValue("ePayment","ProcessURL"); Gateway.OrderID = info.TransactionId;
Gateway.Shipping = "45"; Gateway.Discount = cart.CartItems.DiscountPrice.Amount.ToString(); Gateway.TotalProducts = cart.CartItems.CartItem.Length; String itemPrice = String.Empty; foreach (CartItem item in cart.CartItems.CartItem) { itemPrice = item.Price.Amount.ToString(); Gateway.AddProduct(item.ProductTitle, item.CartItemId.ToString(), "", itemPrice.Remove(itemPrice.IndexOf(',')), item.Quantity.ToString(), "19", ""); }
CustomerInfo UserInfo = ClientCustomer.GetCustomerInfo(); Address address = info.BillingAddress;
Gateway.AddBillingInfo( new string[] { "BILL_FNAME", "BILL_LNAME", "BILL_EMAIL", "BILL_PHONE", "BILL_FAX", "BILL_ADDRESS", "BILL_ADDRESS2", "BILL_ZIPCODE", "BILL_CITY", "BILL_STATE", "BILL_COUNTRYCODE" }, new string[] { address.FirstName, address.LastName, UserInfo.Email, address.PhoneNumber, address.FaxNumber, address.Address1, address.Address2, address.ZipPostalCode, address.City, address.StateProvince, address.Country.Code } );
Gateway.AddShippingInfo( new string[] { "DELIVERY_FNAME", "DELIVERY_LNAME", "DELIVERY_PHONE", "DELIVERY_COMPANY", "DELIVERY_ADDRESS", "DELIVERY_ADDRESS2", "DELIVERY_ZIPCODE", "DELIVERY_CITY", "DELIVERY_STATE", "DELIVERY_COUNTRYCODE" }, new string[] { address.FirstName, address.LastName, address.PhoneNumber, address.Company, address.Address1, address.Address2, address.ZipPostalCode, address.City, address.StateProvince, address.Country.Code } );
Gateway.PostData(); return true; } else { return false; } } }
The ePayGateway is the class that helps building the request for the gateway. And the final method, PostData() builds a form with all the parameters and submits to the gateway URL with redirect. This is where the thread gets interrupted.
Maybe if i add info.Complete() before PostData() this will not happen ?
|
|
-
Wed, Oct 08 2008, 3:04 PM |
-
Thu, Oct 09 2008, 10:25 AM |
-
truthbrother
-
-
-
Joined on 12-21-2006
-
Los Angeles, CA
-
Posts 201
-
-
|
Re: Get cart contents in custom payment gateway
Were you successful? Since I have not coded a gateway in the way that you are trying to implement it, the best I can ask you to do is to try it and give us error messages and screenshots when things fail. Sorry I couldn't be more helpful.
Mediachase Software
|
|
-
Tue, Oct 14 2008, 4:04 AM |
-
victorgunta
-
-
-
Joined on 04-21-2008
-
-
Posts 72
-
-
|
Re: Get cart contents in custom payment gateway
Well, no. I still have the exception in the log : Thread aborted.
Maybe you can explain how the payment process works (in steps and methods) and maybe i can figure out where i can fit in.
|
|
-
Wed, Oct 15 2008, 12:08 AM |
-
truthbrother
-
-
-
Joined on 12-21-2006
-
Los Angeles, CA
-
Posts 201
-
-
|
Re: Get cart contents in custom payment gateway
Here are a couple of articles that should help you with your custom gateway --
http://docs.mediachase.com/doku.php?id=ecf:41:tutorials:payment
(example - working with PayPal)
http://docs.mediachase.com/doku.php?id=ecf:41:tutorials:paypal
|
|
|
|
|
|