-
Notifications
You must be signed in to change notification settings - Fork 2
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 #5 from wallee-payment/ss-plenty
Ss plenty
- Loading branch information
Showing
8 changed files
with
319 additions
and
181 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,31 @@ | ||
<?php | ||
use Wallee\Sdk\Service\TransactionService; | ||
use Wallee\Sdk\Model\EntityQuery; | ||
use Wallee\Sdk\Model\EntityQueryFilter; | ||
use Wallee\Sdk\Model\EntityQueryOrderBy; | ||
use Wallee\Sdk\Model\EntityQueryOrderByType; | ||
use Wallee\Sdk\Model\EntityQueryFilterType; | ||
use Wallee\Sdk\Model\CriteriaOperator; | ||
|
||
require_once __DIR__ . '/WalleeSdkHelper.php'; | ||
|
||
$client = WalleeSdkHelper::getApiClient(SdkRestApi::getParam('gatewayBasePath'), SdkRestApi::getParam('apiUserId'), SdkRestApi::getParam('apiUserKey')); | ||
|
||
$spaceId = SdkRestApi::getParam('spaceId'); | ||
|
||
$service = new TransactionService($client); | ||
$query = new EntityQuery(); | ||
$filter = new EntityQueryFilter(); | ||
$filter->setType(EntityQueryFilterType::LEAF); | ||
$filter->setOperator(CriteriaOperator::EQUALS); | ||
$filter->setFieldName('merchantReference'); | ||
$filter->setValue(SdkRestApi::getParam('merchantReference')); | ||
$query->setFilter($filter); | ||
$orderBy = new EntityQueryOrderBy(); | ||
$orderBy->setFieldName('createdOn'); | ||
$orderBy->setSorting(EntityQueryOrderByType::DESC); | ||
$query->setOrderBys($orderBy); | ||
$query->setNumberOfEntities(1); | ||
$transactions = $service->search($spaceId, $query); | ||
|
||
return WalleeSdkHelper::convertData(current($transactions)); |
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,71 @@ | ||
<?php | ||
namespace Wallee\Controllers; | ||
|
||
use IO\Services\NotificationService; | ||
use Plenty\Plugin\Controller; | ||
use Plenty\Plugin\Http\Request; | ||
use Plenty\Plugin\Http\Response; | ||
use Plenty\Plugin\Log\Loggable; | ||
use Wallee\Services\WalleeSdkService; | ||
|
||
class PaymentProcessController extends Controller | ||
{ | ||
|
||
use Loggable; | ||
|
||
/** | ||
* | ||
* @var Request | ||
*/ | ||
private $request; | ||
|
||
/** | ||
* | ||
* @var Response | ||
*/ | ||
private $response; | ||
|
||
/** | ||
* | ||
* @var WalleeSdkService | ||
*/ | ||
private $sdkService; | ||
|
||
/** | ||
* | ||
* @var NotificationService | ||
*/ | ||
private $notificationService; | ||
|
||
/** | ||
* PaymentController constructor. | ||
* | ||
* @param Request $request | ||
* @param Response $response | ||
* @param WalleeSdkService $sdkService | ||
* @param NotificationService $notificationService | ||
*/ | ||
public function __construct(Request $request, Response $response, WalleeSdkService $sdkService, NotificationService $notificationService) | ||
{ | ||
parent::__construct(); | ||
$this->request = $request; | ||
$this->response = $response; | ||
$this->sdkService = $sdkService; | ||
$this->notificationService = $notificationService; | ||
} | ||
|
||
/** | ||
* | ||
* @param int $id | ||
*/ | ||
public function failTransaction(int $id) | ||
{ | ||
$transaction = $this->sdkService->call('getTransactionByMerchantReference', [ | ||
'merchantReference' => $id | ||
]); | ||
if (is_array($transaction) && ! isset($transaction['error']) && isset($transaction['userFailureMessage']) && ! empty($transaction['userFailureMessage'])) { | ||
$this->notificationService->error($transaction['userFailureMessage']); | ||
} | ||
return $this->response->redirectTo('checkout'); | ||
} | ||
} |
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,18 +1,19 @@ | ||
<?php | ||
|
||
namespace Wallee\Providers; | ||
|
||
use Plenty\Plugin\RouteServiceProvider; | ||
use Plenty\Plugin\Routing\Router; | ||
|
||
class WalleeRouteServiceProvider extends RouteServiceProvider { | ||
|
||
/** | ||
* | ||
* @param Router $router | ||
*/ | ||
public function map(Router $router) { | ||
$router->post('wallee/update-transaction', 'Wallee\Controllers\PaymentNotificationController@updateTransaction'); | ||
} | ||
class WalleeRouteServiceProvider extends RouteServiceProvider | ||
{ | ||
|
||
/** | ||
* | ||
* @param Router $router | ||
*/ | ||
public function map(Router $router) | ||
{ | ||
$router->post('wallee/update-transaction', 'Wallee\Controllers\PaymentNotificationController@updateTransaction'); | ||
$router->get('wallee/fail-transaction/{id}', 'Wallee\Controllers\PaymentProcessController@failTransaction')->where('id', '\d+'); | ||
} | ||
} |
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