string amount = Convert.ToString(Session["TotalPayment"]);
string redirect = "https://www.paypal.com/xclick/business=julie@reframecollective.com";
redirect += "&item_name=videos_Payment";
// redirect += "&item_number=1";
redirect += "&amount=" + String.Format("{0:0.00}", amount);
redirect += "¤cy_code=USD";
//redirect += "&no_shipping=1";
// redirect += "&no_note=1";
redirect += "&return=http://reframeawards.com/SuccessPaypalPayment.aspx";//?status=success&orderid=" + orderId;
redirect += "&cancel_return=http://reframeawards.com/Categories.aspx/fail";//?status=failed&orderid=" + orderId;
Response.Redirect(redirect);
====================================================================
/*Paypal Integration using API(DoDirectPayment)*/
====================================================================
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using com.paypal.sdk.services;
using com.paypal.soap.api;
using com.paypal.sdk.profiles;
using com.paypal.sdk.exceptions;
///
/// Summary description for DoDirectPayment
///
namespace GenerateCodeSOAP
{
public class DoDirectPayment
{
public DoDirectPayment()
{
//
// TODO: Add constructor logic here
//
}
public string DoDirectPaymentCode(string paymentAmount, string buyerLastName, string buyerFirstName, string buyerAddress1, string buyerAddress2, string buyerCity, string buyerState, string buyerZipCode, string creditCardType, string creditCardNumber, string CVV2, int expMonth, int expYear, PaymentActionCodeType paymentAction)
{
CallerServices caller = new CallerServices();
IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
/*
WARNING: Do not embed plaintext credentials in your application code.
Doing so is insecure and against best practices.
Your API credentials must be handled securely. Please consider
encrypting them for use in any production environment, and ensure
that only authorized individuals may view or modify them.
*/
// Set up your API credentials, PayPal end point, and API version.
profile.APIUsername = "julie_api1.reframecollective.com";//"julie@reframecollective.com";//
profile.APIPassword = "V3GB2HR76FEU92XB";//"togglereframe";//
profile.APISignature = "ADlg1IZhxkPA1k9zzvwCX-FsoRV9AfW9ubc4HF7B.C1.Dl5PkYq1FIvg";
profile.Environment = "Live";
caller.APIProfile = profile;
// Create the request object.
DoDirectPaymentRequestType pp_Request = new DoDirectPaymentRequestType();
pp_Request.Version = "51.0";
// Add request-specific fields to the request.
// Create the request details object.
pp_Request.DoDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType();
pp_Request.DoDirectPaymentRequestDetails.IPAddress = "10.244.43.106";
pp_Request.DoDirectPaymentRequestDetails.MerchantSessionId = "1X911810264059026";
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.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 = buyerAddress1;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street2 = buyerAddress2;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CityName = buyerCity;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.StateOrProvince = buyerState;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.PostalCode = buyerZipCode;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountryName = "USA";
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Country = CountryCodeType.US;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountrySpecified = true;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName = new PersonNameType();
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.FirstName = buyerFirstName;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.LastName = buyerLastName;
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails = new PaymentDetailsType();
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal = new BasicAmountType();
// 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;
// Execute the API operation and obtain the response.
DoDirectPaymentResponseType pp_response = new DoDirectPaymentResponseType();
pp_response = (DoDirectPaymentResponseType)caller.Call("DoDirectPayment", pp_Request);
if (pp_response.Ack.ToString().Equals("Success"))
{
HttpContext.Current.Session["STransactionID"] = pp_response.TransactionID.ToString();
}
return pp_response.Ack.ToString();
}
}
}
How to Call This Function on page
1)Create a object of this class file like
DoDirectPayment objMakePay = new DoDirectPayment();
2)And Finally call this method like this
string msg = objMakePay.DoDirectPaymentCode(paymentAmount, buyerLastName, buyerFirstName, buyerAddress1, buyerAddress2, buyerCity, buyerState, buyerZipCode, creditCardType, creditCardNumber, CVV2, expMonth, expYear, PaymentActionCodeType.Sale);
nice one
ReplyDeleteThe above code doesn't work with ASP.NET 2008 IDE, framework 3.5.
ReplyDeleteCallerServices caller = new CallerServices();
The major caller class is not compatible.
Your comments might solve my problem.Thanks
check you Dll Rference and version of ddl
ReplyDeleteThanks
Praveen