-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added OrderType to templates, moved templates to separate folder, add…
…ed shorthand methods, added initial testing
- Loading branch information
Showing
21 changed files
with
240 additions
and
35 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
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,5 +1,5 @@ | ||
{ | ||
"require": { | ||
"num8er/tranzware-payment-gateway": "^1.1.5" | ||
"num8er/tranzware-payment-gateway": "^1.1.7" | ||
} | ||
} |
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
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,12 +1,11 @@ | ||
<?php | ||
require_once('vendor/autoload.php'); | ||
|
||
use num8er\TranzWarePaymentGateway\TranzWarePaymentGatewayHandlerFactory; | ||
use \num8er\TranzWarePaymentGateway\TranzWarePaymentGatewayHandlerFactory; | ||
|
||
$handlerFactory = new TranzWarePaymentGatewayHandlerFactory(); | ||
$orderCallbackHandler = $handlerFactory->createOrderCallbackHandler(); | ||
|
||
$orderStatusData = $orderCallbackHandler->handle(); | ||
|
||
var_dump($orderStatusData); | ||
|
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,12 +1,11 @@ | ||
<?php | ||
require_once('vendor/autoload.php'); | ||
|
||
use num8er\TranzWarePaymentGateway\TranzWarePaymentGatewayHandlerFactory; | ||
use \num8er\TranzWarePaymentGateway\TranzWarePaymentGatewayHandlerFactory; | ||
|
||
$handlerFactory = new TranzWarePaymentGatewayHandlerFactory(); | ||
$orderCallbackHandler = $handlerFactory->createOrderCallbackHandler(); | ||
|
||
$orderStatusData = $orderCallbackHandler->handle(); | ||
|
||
var_dump($orderStatusData); | ||
|
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,12 +1,11 @@ | ||
<?php | ||
require_once('vendor/autoload.php'); | ||
|
||
use num8er\TranzWarePaymentGateway\TranzWarePaymentGatewayHandlerFactory; | ||
use \num8er\TranzWarePaymentGateway\TranzWarePaymentGatewayHandlerFactory; | ||
|
||
$handlerFactory = new TranzWarePaymentGatewayHandlerFactory(); | ||
$orderCallbackHandler = $handlerFactory->createOrderCallbackHandler(); | ||
|
||
$orderStatusData = $orderCallbackHandler->handle(); | ||
|
||
var_dump($orderStatusData); | ||
|
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,43 @@ | ||
<?php | ||
|
||
namespace num8er\TranzWarePaymentGateway; | ||
|
||
class OrderTypes | ||
{ | ||
const PURCHASE = 'Purchase'; | ||
const PRE_AUTH = 'PreAuth'; | ||
|
||
public static function sanitizeValue($value) | ||
{ | ||
$value = preg_replace("/[^A-Za-z_]/", '', $value); | ||
$value = trim($value, '_'); | ||
if (!$value) return ''; | ||
|
||
$isSnakeCase = strpos($value, '_') > 0; | ||
if ($isSnakeCase) { | ||
return | ||
implode('', | ||
array_map('ucwords', | ||
array_map('strtolower', | ||
explode('_', $value) | ||
) | ||
) | ||
); | ||
} | ||
|
||
$words = implode('_', preg_split('/(?=[A-Z])/', $value)); | ||
return self::sanitizeValue($words); | ||
} | ||
|
||
public static function isValid($orderType) | ||
{ | ||
$allowedTypes = [self::PURCHASE, self::PRE_AUTH]; | ||
return in_array($orderType, $allowedTypes); | ||
} | ||
|
||
public static function fromString($orderType) | ||
{ | ||
$orderType = self::sanitizeValue($orderType); | ||
return self::isValid($orderType) ? $orderType : self::PURCHASE; | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.