I am trying to implement a credit card payment solution on my website using SagePay, where I can take payment on my website. I am using ASP.NET Web forms and C#. Here is my code:
var objSagePay = new SagePayIntegration();
var request = objSagePay.DirectPaymentRequest();
if ((request != null)) {
request.Vendor = "testVendor";
request.CardHolder = "Customer Name";
request.CardNumber = "4900000000000";
request.CardType = CardType.VISA;
request.ExpiryDate = "0119";
request.Cv2 = "123";
request.Currency = "GBP";
request.Amount = 10.0;
request.BillingAddress1 = "Test Address 1";
request.BillingAddress2 = "";
request.BillingPostCode = "412";
request.BillingCountry = "";
}
var result = objSagePay.ProcessDirectPaymentRequest(request, "https://test.sagepay.com/gateway/service/vspdirect-register.vsp");
When the result object call is executed, I get Object reference is Null.
Any idea where i am doing things wrong?
Stack Trace
[NullReferenceException: Object reference not set to an instance of an object.] SagePay.IntegrationKit.SagePayIntegration.GetPropertyTextValue(Object request, String propertyName) in C:\dev\dotnet\VspDotNetKitAPI\SagePayIntegration.cs:93 SagePay.IntegrationKit.SagePayIntegration.ProcessDirectPaymentRequest(IDirectPayment paymentRequest, String directPaymentUrl) in C:\dev\dotnet\VspDotNetKitAPI\SagePayIntegration.cs:449 orders_payment_Default.btnProceedCreditCard_Click(Object sender, EventArgs e) in Default.aspx.cs:93 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9692746 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3562
VendorTxCode
? This is your order number for example. – DavidG