Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > How to custom payment gateway using Paypal payment method? View modes: 
User avatar
Member
Member
thanhhieu291082-yahoo - 2/25/2009 2:16:58 AM
   
How to custom payment gateway using Paypal payment method?
Dear,
I custom payment gateway depend on KenticoCMS_EcommerceGuide_Purchase process and payment gateways_Developing custom payment gateways. I using PayPal payment method
I create custom payment gateway form and custom payment gateway class, in shopping cart process, at step 6 of shopping cart process when payment gateway form show, I click "Finish Payment" button
and it redirect to https://www.sandbox.paypal.com/us/cgi-bin/webscr with parametter of URL: https://www.sandbox.paypal.com/cgi-bin/webscr?cardnumber=4991319512885564&price=25.289&currency=USD&orderid=29
but paypay is not recognize my order, it isn't minus money in my account and don't have this order
This is my code:
Payment gateway form:

public partial class Doggy_PaymentProvider_CustomPaypalGatewayForm : CMSPaymentGatewayForm
{
protected void Page_Load(object sender, EventArgs e)
{
lblTitle.Text = "Your credit card details";
lblCardNumber.Text = "Credit card number:";
}
public override void LoadData()
{
base.LoadData();
txtCardNumber.Text = ValidationHelper.GetString(this.ShoppingCartInfoObj.PaymentGatewayCustomData["CustomGatewayCardNumber"], "");
}
public override string ValidateData()
{
return base.ValidateData();
if (txtCardNumber.Text.Trim() == "")
{
lblError.Visible = true;
lblError.Text = "Please enter your credit card number";
return lblError.Text;
}
return "";
}
public override string ProcessData()
{
this.ShoppingCartInfoObj.PaymentGatewayCustomData["CustomGatewayCardNumber"] = txtCardNumber.Text.Trim();
return "";
}
}

Custom payment gateway class:
namespace Doggy.PaymentProvider
{
public class PaypalPaymentGateway : CMSPaymentGatewayProvider
{
public PaymentResultInfo PaypalPaymentResult;

public override CMSPaymentGatewayForm GetPaymentDataForm()
{
try
{
return (CMSPaymentGatewayForm)this.ShoppingCartControl.LoadControl("~/Doggy/PaymentProvider/CustomPaypalGatewayForm.ascx");
}
catch
{
return null;
}
}
public override void ProcessPayment()
{
// Get payment gateway url
string url = this.GetPaymentGatewayUrl();
if (url != "")
{
// Initialize payment parameters
Hashtable parameters = InitializePaymentParameters();
// Add required payment data to the url
url = GetFullPaymentGatewayUrl(url, parameters);
// Redirect to payment gateway to finish payment
this.ShoppingCartControl.Page.Response.Redirect(url);
}
else
{
// Show error message - payment gateway url not found
this.ErrorMessage = "Unable to finish payment: Payment gateway url not found.";
// Update payment result
this.PaypalPaymentResult.PaymentDescription = this.ErrorMessage;
this.PaypalPaymentResult.PaymentIsCompleted = false;
// Update order payment result in database
this.UpdateOrderPaymentResult();
}
}

/// <summary>
/// Returns table with initialized payment parameters.
/// </summary>
/// <returns></returns>
private Hashtable InitializePaymentParameters()
{
Hashtable parameters = new Hashtable();
parameters["orderid"] = this.ShoppingCartInfoObj.OrderId;
parameters["price"] = this.ShoppingCartInfoObj.TotalPrice;
parameters["currency"] = this.ShoppingCartInfoObj.CurrencyInfoObj.CurrencyCode;
parameters["cardnumber"] = Convert.ToString(this.ShoppingCartInfoObj.PaymentGatewayCustomData["CustomGatewayCardNumber"]);

return parameters;
}

/// <summary>
/// Returns payment gateway url with payment data in query string.
/// </summary>
/// <param name="url">Payment gateway url.</param>
/// <param name="parameters">Initialized payment paremeters.</param>
/// <returns></returns>
private string GetFullPaymentGatewayUrl(string url, Hashtable parameters)
{
foreach (DictionaryEntry parameter in parameters)
{
// Add payment data to the url
url = UrlHelper.AddParameterToUrl(url, Convert.ToString(parameter.Key), HttpUtility.UrlEncode(Convert.ToString(parameter.Value)));
}
return url;
}

}
}

Please help me how to custom payment gateway correct and which param I need to get

User avatar
Member
Member
anil.thanga-gmail - 4/30/2009 5:57:55 AM
   
RE:How to custom payment gateway using Paypal payment method?
Hi i am developing the custom gateway. But why i am unable get the Method called
ShoppingCartControl.LoadControl() in my page. Why my page is not showing the loadcontrol method(). due to this i am unable to proceed. not only this method, the below line also showing as error.
this.ShoppingCartControl.Page.Response.Redirect(url);

Please help.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 5/19/2009 12:11:59 PM
   
RE:How to custom payment gateway using Paypal payment method?
Hi,

Just to inform anyone with problem with LoadControl method.
If the intellisense doesn't offer the LoadControl() method, ensure you have added references to all required dlls in the bin folder of your payment gateway project and eventually try to reference all dlls if the problem persist.

Regards,
Zdenek C.

User avatar
Member
Member
Peter - 6/1/2009 6:22:40 PM
   
RE:How to custom payment gateway using Paypal payment method?
Hi,
I came accross the same problem. You need to add to your references CMS.ExtendedControls and CMS.UIControls

Regards