Initial project's source code check-in.
This commit is contained in:
commit
b03b0b373f
4573 changed files with 981205 additions and 0 deletions
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WebsitePanel.Ecommerce.EnterpriseServer
|
||||
{
|
||||
/// <summary>
|
||||
/// PayPal Payment Provider keys set
|
||||
/// </summary>
|
||||
public class PayPalProKeys
|
||||
{
|
||||
/// <summary>2.20</summary>
|
||||
public const string Version = "Version";
|
||||
public const string Username = "Username";
|
||||
public const string Password = "Password";
|
||||
public const string Signature = "Signature";
|
||||
|
||||
public const string ErrorPrefix = "PayPalPro.";
|
||||
|
||||
private PayPalProKeys()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace WebsitePanel.Ecommerce.EnterpriseServer
|
||||
{
|
||||
/// <summary>
|
||||
/// Payment provider for the PayPal Gateway
|
||||
/// </summary>
|
||||
public class PayPalProProvider : SystemPluginBase, IPaymentGatewayProvider
|
||||
{
|
||||
public const string DEMO_SERVICE_URL = "https://api-aa.sandbox.paypal.com/2.0/";
|
||||
public const string LIVE_SERVICE_URL = "https://api-aa-3t.paypal.com/2.0/";
|
||||
public const string PROCESSOR_VERSION = "2.0";
|
||||
|
||||
public override string[] SecureSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return new string[] { PayPalProSettings.SIGNATURE, PayPalProSettings.PASSWORD };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether plug-in running in live mode
|
||||
/// </summary>
|
||||
public bool LiveMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToBoolean(PluginSettings[PayPalProSettings.LIVE_MODE]);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets service username
|
||||
/// </summary>
|
||||
public string Username
|
||||
{
|
||||
get { return PluginSettings[PayPalProSettings.USERNAME]; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets service password
|
||||
/// </summary>
|
||||
public string Password
|
||||
{
|
||||
get { return PluginSettings[PayPalProSettings.PASSWORD]; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets service signature
|
||||
/// </summary>
|
||||
public string Signature
|
||||
{
|
||||
get { return PluginSettings[PayPalProSettings.SIGNATURE]; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets service url
|
||||
/// </summary>
|
||||
public string ServiceUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (LiveMode)
|
||||
return LIVE_SERVICE_URL;
|
||||
|
||||
return DEMO_SERVICE_URL;
|
||||
}
|
||||
}
|
||||
|
||||
#region IPaymentGatewayProvider Members
|
||||
|
||||
public TransactionResult SubmitPaymentTransaction(CheckoutDetails details)
|
||||
{
|
||||
//init result structure
|
||||
TransactionResult ret = new TransactionResult();
|
||||
|
||||
//set up Request
|
||||
//instantiate DoDirectPaymentRequestType and RequestDetails objects
|
||||
DoDirectPaymentRequestType request = new DoDirectPaymentRequestType();
|
||||
request.Version = PROCESSOR_VERSION;
|
||||
DoDirectPaymentRequestDetailsType requestDetails = new DoDirectPaymentRequestDetailsType();
|
||||
request.DoDirectPaymentRequestDetails = requestDetails;
|
||||
|
||||
//set payment action
|
||||
requestDetails.PaymentAction = PaymentActionCodeType.Sale;
|
||||
|
||||
//set IP
|
||||
//requestDetails.IPAddress = Request.UserHostAddress;
|
||||
requestDetails.IPAddress = details[CheckoutKeys.IPAddress];
|
||||
|
||||
//set CreditCard info
|
||||
CreditCardDetailsType creditCardDetails = new CreditCardDetailsType();
|
||||
requestDetails.CreditCard = creditCardDetails;
|
||||
creditCardDetails.CreditCardNumber = details[CheckoutKeys.CardNumber];
|
||||
creditCardDetails.CreditCardType = (CreditCardTypeType)Enum.Parse(typeof(CreditCardTypeType), details[CheckoutKeys.CardType], true);
|
||||
creditCardDetails.CVV2 = details[CheckoutKeys.VerificationCode];
|
||||
creditCardDetails.ExpMonth = Int32.Parse(details[CheckoutKeys.ExpireMonth]);
|
||||
creditCardDetails.ExpYear = Int32.Parse(details[CheckoutKeys.ExpireYear]);
|
||||
// Switch/Solo
|
||||
if (creditCardDetails.CreditCardType == CreditCardTypeType.Solo ||
|
||||
creditCardDetails.CreditCardType == CreditCardTypeType.Switch)
|
||||
{
|
||||
creditCardDetails.StartMonth = Int32.Parse(details[CheckoutKeys.StartMonth]);
|
||||
creditCardDetails.StartYear = Int32.Parse(details[CheckoutKeys.StartYear]);
|
||||
creditCardDetails.IssueNumber = details[CheckoutKeys.IssueNumber];
|
||||
}
|
||||
|
||||
//set billing address
|
||||
PayerInfoType cardOwner = new PayerInfoType();
|
||||
creditCardDetails.CardOwner = cardOwner;
|
||||
cardOwner.PayerName = new PersonNameType();
|
||||
cardOwner.PayerName.FirstName = details[CheckoutKeys.FirstName];
|
||||
cardOwner.PayerName.LastName = details[CheckoutKeys.LastName];
|
||||
|
||||
cardOwner.Address = new AddressType();
|
||||
cardOwner.Address.Street1 = details[CheckoutKeys.Address];
|
||||
//??? cardOwner.Address.Street2 = "";
|
||||
cardOwner.Address.CityName = details[CheckoutKeys.City];
|
||||
cardOwner.Address.StateOrProvince = details[CheckoutKeys.State];
|
||||
cardOwner.Address.PostalCode = details[CheckoutKeys.Zip];
|
||||
cardOwner.Address.CountrySpecified = true;
|
||||
cardOwner.Address.Country = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), details[CheckoutKeys.Country], true);
|
||||
|
||||
//set payment Details
|
||||
PaymentDetailsType paymentDetails = new PaymentDetailsType();
|
||||
requestDetails.PaymentDetails = paymentDetails;
|
||||
paymentDetails.OrderTotal = new BasicAmountType();
|
||||
//TODO: Add currency support
|
||||
paymentDetails.OrderTotal.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), details[CheckoutKeys.Currency]);
|
||||
//paymentDetails.OrderTotal.currencyID = CurrencyCodeType.USD;
|
||||
//No currency symbol. Decimal separator must be a period (.), and the thousands separator must be a comma (,)
|
||||
paymentDetails.OrderTotal.Value = details[CheckoutKeys.Amount];
|
||||
|
||||
DoDirectPaymentReq paymentRequest = new DoDirectPaymentReq();
|
||||
paymentRequest.DoDirectPaymentRequest = request;
|
||||
|
||||
//FINISH set up req
|
||||
//setup request Header, API credentials
|
||||
PayPalAPIAASoapBinding paypalInterface = new PayPalAPIAASoapBinding();
|
||||
UserIdPasswordType user = new UserIdPasswordType();
|
||||
|
||||
//set api credentials - username, password, signature
|
||||
user.Username = Username;
|
||||
user.Password = Password;
|
||||
user.Signature = Signature;
|
||||
// setup service url
|
||||
paypalInterface.Url = ServiceUrl;
|
||||
paypalInterface.RequesterCredentials = new CustomSecurityHeaderType();
|
||||
paypalInterface.RequesterCredentials.Credentials = user;
|
||||
|
||||
//make call return response
|
||||
DoDirectPaymentResponseType paymentResponse = new DoDirectPaymentResponseType();
|
||||
paymentResponse = paypalInterface.DoDirectPayment(paymentRequest);
|
||||
//write response xml to the ret object
|
||||
ret.RawResponse = SerializeObject(paymentResponse);
|
||||
|
||||
switch (paymentResponse.Ack)
|
||||
{
|
||||
case AckCodeType.Success:
|
||||
case AckCodeType.SuccessWithWarning:
|
||||
ret.Succeed = true;
|
||||
ret.TransactionId = paymentResponse.TransactionID;
|
||||
ret.TransactionStatus = TransactionStatus.Approved;
|
||||
break;
|
||||
default: // show errors if Ack is NOT Success
|
||||
ret.Succeed = false;
|
||||
ret.TransactionStatus = TransactionStatus.Declined;
|
||||
if (paymentResponse.Errors != null &&
|
||||
paymentResponse.Errors.Length > 0)
|
||||
{
|
||||
ret.StatusCode = PayPalProKeys.ErrorPrefix + paymentResponse.Errors[0].ErrorCode;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private string UTF8ByteArrayToString(byte[] characters)
|
||||
{
|
||||
UTF8Encoding encoding = new UTF8Encoding();
|
||||
string ret = encoding.GetString(characters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private string SerializeObject(object obj)
|
||||
{
|
||||
string ret = null;
|
||||
if (obj == null)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
XmlTextWriter xmlTextWriter = null;
|
||||
try
|
||||
{
|
||||
XmlSerializer xmlSerializer = new XmlSerializer(obj.GetType());
|
||||
xmlTextWriter = new XmlTextWriter(new MemoryStream(), Encoding.UTF8);
|
||||
xmlSerializer.Serialize(xmlTextWriter, obj);
|
||||
MemoryStream memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
|
||||
ret = UTF8ByteArrayToString(memoryStream.ToArray());
|
||||
return ret;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//write to log
|
||||
return ret;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (xmlTextWriter != null)
|
||||
{
|
||||
xmlTextWriter.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("WebsitePanel.Plugins.PayPalPro")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyProduct("WebsitePanel.Plugins.PayPalPro")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("781d6d6e-71fb-4d7e-af43-72f8ec98dbd0")]
|
10913
WebsitePanel/Sources/WebsitePanel.Gateways.PayPal/Reference.cs
Normal file
10913
WebsitePanel/Sources/WebsitePanel.Gateways.PayPal/Reference.cs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D695D58C-99F7-409E-B3D8-C1B97A8E748A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WebsitePanel.Ecommerce.EnterpriseServer</RootNamespace>
|
||||
<AssemblyName>WebsitePanel.Plugins.PayPalPro</AssemblyName>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\WebsitePanel.EnterpriseServer\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<WarningsAsErrors>618</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\WebsitePanel.EnterpriseServer\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<WarningsAsErrors>618</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\VersionInfo.cs">
|
||||
<Link>VersionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="PayPalKeys.cs" />
|
||||
<Compile Include="PayPalProProvider.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Reference.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WebsitePanel.EnterpriseServer.Base\WebsitePanel.EnterpriseServer.Base.csproj">
|
||||
<Project>{C09CE910-F16B-48A1-B2CC-C99B8C1CF775}</Project>
|
||||
<Name>WebsitePanel.EnterpriseServer.Base</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue