-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from wayforpay/service-url
Service URL handler Return URL handler
- Loading branch information
Showing
16 changed files
with
510 additions
and
23 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
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,36 @@ | ||
<?php | ||
/* | ||
* This file is part of the WayForPay project. | ||
* | ||
* @link https://github.com/wayforpay/php-sdk | ||
* | ||
* @author Vladislav Lyshenko <vladdnepr1989@gmail.com> | ||
* @copyright Copyright 2019 WayForPay | ||
* @license https://opensource.org/licenses/MIT | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use WayForPay\SDK\Credential\AccountSecretTestCredential; | ||
use WayForPay\SDK\Exception\WayForPaySDKException; | ||
use WayForPay\SDK\Handler\ServiceUrlHandler; | ||
|
||
// Use test credential or yours | ||
$credential = new AccountSecretTestCredential(); | ||
//$credential = new AccountSecretCredential('account', 'secret'); | ||
|
||
try { | ||
$handler = new ServiceUrlHandler($credential); | ||
$response = $handler->parseRequestFromGlobals(); | ||
|
||
if ($response->getReason()->isOK()) { | ||
echo "Success"; | ||
} else { | ||
echo "Error: " . $response->getReason()->getMessage(); | ||
} | ||
} catch (WayForPaySDKException $e) { | ||
echo "WayForPay SDK exception: " . $e->getMessage(); | ||
} |
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,32 @@ | ||
<?php | ||
/* | ||
* This file is part of the WayForPay project. | ||
* | ||
* @link https://github.com/wayforpay/php-sdk | ||
* | ||
* @author Vladislav Lyshenko <vladdnepr1989@gmail.com> | ||
* @copyright Copyright 2019 WayForPay | ||
* @license https://opensource.org/licenses/MIT | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use WayForPay\SDK\Credential\AccountSecretTestCredential; | ||
use WayForPay\SDK\Exception\WayForPaySDKException; | ||
use WayForPay\SDK\Handler\ServiceUrlHandler; | ||
|
||
// Use test credential or yours | ||
$credential = new AccountSecretTestCredential(); | ||
//$credential = new AccountSecretCredential('account', 'secret'); | ||
|
||
try { | ||
$handler = new ServiceUrlHandler($credential); | ||
$response = $handler->parseRequestFromPostRaw(); | ||
|
||
echo $handler->getSuccessResponse($response->getTransaction()); | ||
} catch (WayForPaySDKException $e) { | ||
echo "WayForPay SDK exception: " . $e->getMessage(); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<?php | ||
/* | ||
* This file is part of the WayForPay project. | ||
* | ||
* @link https://github.com/wayforpay/php-sdk | ||
* | ||
* @author Vladislav Lyshenko <vladdnepr1989@gmail.com> | ||
* @copyright Copyright 2019 WayForPay | ||
* @license https://opensource.org/licenses/MIT | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace WayForPay\SDK\Domain; | ||
|
||
use DateTime; | ||
|
||
class TransactionService extends TransactionBase | ||
{ | ||
/** | ||
* @var CardToken | ||
*/ | ||
private $recToken; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $authCode; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $repayUrl; | ||
|
||
/** | ||
* @param array $data | ||
* @return TransactionService | ||
* @throws \Exception | ||
*/ | ||
public static function fromArray(array $data) | ||
{ | ||
$default = array( | ||
'merchantAccount' => '', | ||
'orderReference' => '', | ||
'merchantSignature' => '', | ||
'amount' => 0, | ||
'currency' => '', | ||
'authCode' => 0, | ||
'email' => '', | ||
'phone' => '', | ||
'createdDate' => 0, | ||
'processingDate' => 0, | ||
'cardPan' => '', | ||
'cardType' => '', | ||
'issuerBankCountry' => '', | ||
'issuerBankName' => '', | ||
'recToken' => '', | ||
'transactionStatus' => '', | ||
'reason' => '', | ||
'reasonCode' => 0, | ||
'fee' => 0, | ||
'paymentSystem' => '', | ||
'repayUrl' => '', | ||
); | ||
|
||
$data = array_merge($default, $data); | ||
|
||
return new self( | ||
$data['merchantTransactionType'], | ||
$data['orderReference'], | ||
new DateTime('@' . $data['createdDate']), | ||
$data['amount'], | ||
$data['currency'], | ||
$data['transactionStatus'], | ||
new DateTime('@' . $data['processingDate']), | ||
$data['reasonCode'], | ||
$data['reason'], | ||
isset($data['email']) ? $data['email'] : null, | ||
isset($data['phone']) ? $data['phone'] : null, | ||
isset($data['paymentSystem']) ? $data['paymentSystem'] : null, | ||
isset($data['cardPan']) ? $data['cardPan'] : null, | ||
isset($data['cardType']) ? $data['cardType'] : null, | ||
isset($data['issuerBankCountry']) ? $data['issuerBankCountry'] : null, | ||
isset($data['issuerBankName']) ? $data['issuerBankName'] : null, | ||
isset($data['fee']) ? $data['fee'] : null, | ||
isset($data['baseAmount']) ? $data['baseAmount'] : null, | ||
isset($data['baseCurrency']) ? $data['baseCurrency'] : null, | ||
isset($data['authCode']) ? $data['authCode'] : null, | ||
isset($data['recToken']) ? $data['recToken'] : null, | ||
isset($data['repayUrl']) ? $data['repayUrl'] : null | ||
); | ||
} | ||
|
||
public function __construct( | ||
$merchantTransactionType, | ||
$orderReference, | ||
DateTime $createdDate, | ||
$amount, $currency, | ||
$status, DateTime | ||
$processingDate, | ||
$reasonCode, | ||
$reason, | ||
$email = null, | ||
$phone = null, | ||
$paymentSystem = null, | ||
$cardPan = null, | ||
$cardType = null, | ||
$issuerBankCountry = null, | ||
$issuerBankName = null, | ||
$fee = null, | ||
$baseAmount = null, | ||
$baseCurrency = null, | ||
$authCode = null, | ||
$recToken = null, | ||
$repayUrl = null | ||
) { | ||
parent::__construct( | ||
$orderReference, | ||
$createdDate, | ||
$amount, | ||
$currency, | ||
$status, | ||
$processingDate, | ||
$reasonCode, | ||
$reason, | ||
$email, | ||
$phone, | ||
$paymentSystem, | ||
$cardPan, | ||
$cardType, | ||
$issuerBankCountry, | ||
$issuerBankName, | ||
$fee, | ||
$baseAmount, | ||
$baseCurrency | ||
); | ||
|
||
$this->repayUrl = strval($repayUrl); | ||
$this->authCode = strval($authCode); | ||
$this->recToken = $recToken ? new CardToken($recToken) : null; | ||
} | ||
|
||
/** | ||
* @return CardToken | ||
*/ | ||
public function getRecToken() | ||
{ | ||
return $this->recToken; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getAuthCode() | ||
{ | ||
return $this->authCode; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getRepayUrl() | ||
{ | ||
return $this->repayUrl; | ||
} | ||
} |
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.