Skip to content

Commit

Permalink
Initial public Release v1.1
Browse files Browse the repository at this point in the history
Release of v1.1 with features:
WooCommerce Payment Gateway
Pay Button
  • Loading branch information
straightvisions-matthias-bathke committed Jun 14, 2013
0 parents commit 332e601
Show file tree
Hide file tree
Showing 38 changed files with 3,253 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
215 changes: 215 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
#################
## Eclipse
#################

*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath


#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

#############
## Windows detritus
#############

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store


#############
## Python
#############

*.py[co]

# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg
149 changes: 149 additions & 0 deletions lib/api/Apiclient/Curl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?php

require_once 'Interface.php';

require_once realpath(dirname(__FILE__)) . '/../Exception.php';

if (!function_exists('json_decode')) {
throw new Exception("Please install the PHP JSON extension");
}

if (!function_exists('curl_init')) {
throw new Exception("Please install the PHP cURL extension");
}

/**
* Services_Paymill cURL HTTP client
*/
class Services_Paymill_Apiclient_Curl implements Services_Paymill_Apiclient_Interface
{

/**
* Paymill API merchant key
*
* @var string
*/
private $_apiKey = null;

/**
* Paymill API base url
*
* @var string
*/
private $_apiUrl = '/';

const USER_AGENT = 'Paymill-php/0.0.2';

public static $lastRawResponse;
public static $lastRawCurlOptions;

/**
* cURL HTTP client constructor
*
* @param string $apiKey
* @param string $apiEndpoint
*/
public function __construct($apiKey, $apiEndpoint)
{
$this->_apiKey = $apiKey;
$this->_apiUrl = $apiEndpoint;
}

/**
* Perform API and handle exceptions
*
* @param $action
* @param array $params
* @param string $method
* @return mixed
* @throws Services_Paymill_Exception
* @throws Exception
*/
public function request($action, $params = array(), $method = 'POST')
{
if (!is_array($params))
$params = array();

try {
$response = $this->_requestApi($action, $params, $method);
$httpStatusCode = $response['header']['status'];
if ($httpStatusCode != 200) {
$errorMessage = 'Client returned HTTP status code ' . $httpStatusCode;
if (isset($response['body']['error'])) {
$errorMessage = $response['body']['error'];
}
$responseCode = '';
if (isset($response['body']['response_code'])) {
$responseCode = $response['body']['response_code'];
}

return array("data" => array(
"error" => $errorMessage,
"response_code" => $responseCode
));
}

return $response['body'];
} catch (Exception $e) {
return array("data" => array("error" => $e->getMessage()));
}
}

/**
* Perform HTTP request to REST endpoint
*
* @param string $action
* @param array $params
* @param string $method
* @return array
*/
protected function _requestApi($action = '', $params = array(), $method = 'POST')
{
$curlOpts = array(
CURLOPT_URL => $this->_apiUrl . $action,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_USERAGENT => self::USER_AGENT,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSLVERSION => 3,
// CURLOPT_CAINFO => realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'paymill.crt',
);

if (Services_Paymill_Apiclient_Interface::HTTP_GET === $method) {
if (0 !== count($params)) {
$curlOpts[CURLOPT_URL] .= false === strpos($curlOpts[CURLOPT_URL], '?') ? '?' : '&';
$curlOpts[CURLOPT_URL] .= http_build_query($params, null, '&');
}
} else {
$curlOpts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
}

if ($this->_apiKey) {
$curlOpts[CURLOPT_USERPWD] = $this->_apiKey . ':';
}

$curl = curl_init();
curl_setopt_array($curl, $curlOpts);
$responseBody = curl_exec($curl);
self::$lastRawCurlOptions = $curlOpts;
self::$lastRawResponse = $responseBody;
$responseInfo = curl_getinfo($curl);
if ($responseBody === false) {
$responseBody = array('error' => curl_error($curl));
}
curl_close($curl);

if ('application/json' === $responseInfo['content_type']) {
$responseBody = json_decode($responseBody, true);
}

return array(
'header' => array(
'status' => $responseInfo['http_code'],
'reason' => null,
),
'body' => $responseBody
);
}

}
Loading

0 comments on commit 332e601

Please sign in to comment.