forked from anvargear/LaravelPayuLatam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6dc3eeb
commit f171529
Showing
12 changed files
with
398 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/vendor | ||
composer.phar | ||
composer.lock | ||
/nbproject | ||
/site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,42 @@ | ||
{ | ||
"name": "anvarco/payulatam", | ||
"description": "Payulatam form laravel provides an expressive, fluent interface to PayuLatam subscription billing services.", | ||
"version": "0.0.3-dev", | ||
"type": "project", | ||
"require": { | ||
"php": ">=5.5.9", | ||
"anvarco/sdkpayu": "1.0.*", | ||
"laravel/framework": "5.*" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "AnvarStudios.CO Labs", | ||
"email": "[email protected]", | ||
"homepage": "http://www.anvarstudios.co", | ||
"role": "Developer" | ||
} | ||
], | ||
"support": { | ||
"name": "anvarco/payulatam", | ||
"description": "Payulatam form laravel provides an expressive, fluent interface to PayuLatam subscription billing services.", | ||
"version": "0.0.3-dev", | ||
"type": "project", | ||
"require": { | ||
"php": ">=5.5.9" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "4.8.*", | ||
"orchestra/testbench": "~3.1" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "AnvarStudios.CO Labs", | ||
"email": "[email protected]", | ||
"wiki": "https://github.com/anvarstudios/LaravelPayuLatam/wiki" | ||
"homepage": "http://www.anvarstudios.co", | ||
"role": "Developer" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"AnvarCO\\PayuLatam\\": "src/" | ||
} | ||
{ | ||
"name": "Jose Luis Fonseca", | ||
"email": "[email protected]", | ||
"homepage": "https://www.josefonseca.me", | ||
"role": "Developer" | ||
} | ||
], | ||
"support": { | ||
"email": "[email protected]", | ||
"wiki": "https://github.com/anvarstudios/LaravelPayuLatam/wiki" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"AnvarCO\\PayuLatam\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"AnvarCO\\PayuLatam\\Tests\\": "tests/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Package Test Suite"> | ||
<directory suffix=".php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace AnvarCO\PayuLatam\Form; | ||
|
||
|
||
use AnvarCO\PayuLatam\WebCheckoutData; | ||
|
||
/** | ||
* Class Builder | ||
* @package AnvarCO\PayuLatam\Form | ||
* @author Jose Luis Fonseca <[email protected]> | ||
*/ | ||
class Builder { | ||
|
||
/** | ||
* @var WebCheckoutData | ||
*/ | ||
private $payu; | ||
|
||
/** | ||
* @param WebCheckoutData $payu | ||
*/ | ||
public function __construct(WebCheckoutData $payu) | ||
{ | ||
$this->payu = $payu; | ||
} | ||
|
||
/** | ||
* ger the form based on the theme in config | ||
* @return string | ||
*/ | ||
public function getForm() | ||
{ | ||
return view('payulatam::templates.'.config('payulatam.theme','bootstrap'))->with($this->payu->toArray())->render(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
<?php | ||
|
||
namespace AnvarCO\PayuLatam; | ||
|
||
|
||
/** | ||
* Class WebCheckoutData | ||
* @package AnvarCO\PayuLatam | ||
* @author Jose Luis Fonseca <[email protected]> | ||
*/ | ||
class WebCheckoutData | ||
{ | ||
|
||
/** | ||
* @var | ||
*/ | ||
private $merchantId; | ||
/** | ||
* @var | ||
*/ | ||
private $apiKey; | ||
/** | ||
* @var | ||
*/ | ||
private $apiLogin; | ||
/** | ||
* @var | ||
*/ | ||
private $lang; | ||
/** | ||
* @var | ||
*/ | ||
private $currency; | ||
/** | ||
* @var bool | ||
*/ | ||
private $test = true; | ||
/** | ||
* @var | ||
*/ | ||
private $responseUrl; | ||
/** | ||
* @var | ||
*/ | ||
private $confirmationUrl; | ||
/** | ||
* @var | ||
*/ | ||
private $buyerEmail; | ||
/** | ||
* @var | ||
*/ | ||
private $description; | ||
/** | ||
* @var | ||
*/ | ||
private $referenceCode; | ||
/** | ||
* @var | ||
*/ | ||
private $amount; | ||
/** | ||
* @var | ||
*/ | ||
private $tax; | ||
/** | ||
* @var | ||
*/ | ||
private $taxReturnBase; | ||
/** | ||
* @var null | ||
*/ | ||
private $signature = null; | ||
/** | ||
* @var string | ||
*/ | ||
private $url = "https://stg.gateway.payulatam.com/ppp-web-gateway/"; | ||
|
||
/** | ||
* | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->setVariables(); | ||
} | ||
|
||
/** | ||
* Set the variables to generate the form | ||
* @param $buyerEmail | ||
* @param $description | ||
* @param $referenceCode | ||
* @param $amount | ||
* @param int $tax | ||
* @param int $taxReturnBase | ||
* @return $this | ||
*/ | ||
public function init($buyerEmail, $description, $referenceCode, $amount, $tax = 0, $taxReturnBase = 0) | ||
{ | ||
$this->buyerEmail = $buyerEmail; | ||
$this->description = $description; | ||
$this->referenceCode = $referenceCode; | ||
$this->amount = $amount; | ||
$this->tax = $tax; | ||
$this->taxReturnBase = $taxReturnBase; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Generate the signature and return the object for a builder | ||
* @return $this | ||
*/ | ||
public function process() | ||
{ | ||
$this->setSignature(); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get the data required for PayU Web checkout as array | ||
* @return array | ||
*/ | ||
public function toArray() | ||
{ | ||
return [ | ||
'merchantId' => $this->merchantId, | ||
'accountId' => $this->merchantId, | ||
'description' => $this->description, | ||
'referenceCode' => $this->referenceCode, | ||
'currency' => $this->currency, | ||
'amount' => $this->amount, | ||
'tax' => $this->tax, | ||
'taxReturnBase' => $this->taxReturnBase, | ||
'signature' => $this->signature, | ||
'isTest' => (int)$this->test, | ||
'buyerEmail' => $this->buyerEmail, | ||
'responseUrl' => $this->responseUrl, | ||
'confirmationUrl' => $this->confirmationUrl, | ||
'url' => $this->url | ||
]; | ||
} | ||
|
||
/** | ||
* Generate the signature based in the given data | ||
* @return $this | ||
*/ | ||
protected function setSignature() | ||
{ | ||
$this->signature = md5($this->apiKey . '~' . $this->merchantId . '~' . $this->referenceCode . '~' . $this->amount . '~' . $this->currency); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set the initial variables from config | ||
*/ | ||
private function setVariables() | ||
{ | ||
$this->merchantId = config('payulatam.merchantId', '123'); | ||
$this->apiKey = config('payulatam.apiKey', '123'); | ||
$this->apiLogin = config('payulatam.apiLogin', '123'); | ||
$this->lang = config('payulatam.language', 'es'); | ||
$this->currency = config('payulatam.currency', 'COP'); | ||
$this->test = config('payulatam.test', true); | ||
$this->responseUrl = config('payulatam.responseUrl', ''); | ||
$this->confirmationUrl = config('payulatam.confirmationUrl', ''); | ||
if (empty($this->test)) { | ||
$this->url = "https://gateway.payulatam.com/ppp-web-gateway/"; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.