C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

need paypal payment gateway code


Posted Date: 01 Nov 2008      Posted By: anjali      Member Level: Silver     Points: 1   Responses: 1



hi,
need to implement the payments from our site.

the information will be entered by the customer in our site and has to goto paypal and check the card details and everything, and we have to get the output whether the transaction is success or failed.

please its very urgent.
give me the URL to send the customer information and what data needed to be send to the paypal site.

Thanks in Advance





Responses

Author: VijayaShankar    01 Nov 2008Member Level: GoldRating:     Points: -20

/*
* Copyright 2005, 2008 PayPal, Inc. All Rights Reserved.
*
* DoDirectPayment SOAP example; last modified 08MAY23.
*
* Process a credit card payment.
*/
using System;
using com.paypal.sdk.services;
using com.paypal.soap.api;
using com.paypal.sdk.profiles;
using System.Net;
/**
* PayPal .NET SDK sample code
*/
namespace GenerateCodeSOAP
{
public class DoDirectPayment
{
public DoDirectPayment()
{
System.Timers.Timer t = new System.Timers.Timer();

System.Threading.Thread.Sleep(1000);
}

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 = "vijaya_1224744555_biz_api1.jeevantechnologies.com";
profile.APIPassword = "1224744560";
profile.APISignature = "An5ns1Kso7MWUdW4ErQKJJJ4qi4-AkxQGWeNgFDSk.hp0-k6acfTBArj";
profile.Environment="sandbox";
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 = "192.168.1.140";
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.verified;
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);
return pp_response.Ack.ToString();
}
}
}



DotNetSOAPGenerate.zip
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : sending mail having bcc,and attachment
Previous : How to Get the Client System Name in Asp.net
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use