-
Notifications
You must be signed in to change notification settings - Fork 3
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
0 parents
commit e090579
Showing
444 changed files
with
30,980 additions
and
0 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,56 @@ | ||
<?php | ||
|
||
namespace Novalnet\Bundle\NovalnetBundle\Client; | ||
|
||
use GuzzleHttp\ClientInterface; | ||
|
||
/** | ||
* Handle Novalnet payport API request and response | ||
*/ | ||
class Gateway implements GatewayInterface | ||
{ | ||
/** @var ClientInterface */ | ||
protected $httpClient; | ||
|
||
/** | ||
* @param ClientInterface $httpClient | ||
*/ | ||
public function __construct(ClientInterface $httpClient) | ||
{ | ||
$this->httpClient = $httpClient; | ||
} | ||
|
||
/** {@inheritdoc} */ | ||
public function send($paymentAccessKey, $parameters, $hostAddress) | ||
{ | ||
$encodedData = base64_encode($paymentAccessKey); | ||
$headers = [ | ||
'Content-Type' => 'application/json', | ||
'charset' => 'utf-8', | ||
'Accept' => 'application/json', | ||
'X-NN-Access-Key' => $encodedData, | ||
]; | ||
|
||
$response = $this->httpClient->request( | ||
'POST', | ||
$hostAddress, | ||
$this->getRequestOptions($parameters, $headers) | ||
); | ||
$result = json_decode($response->getBody(true), true); | ||
return $result; | ||
} | ||
|
||
/** | ||
* @param object $config | ||
* @return array | ||
*/ | ||
protected function getRequestOptions($parameters, $headers) | ||
{ | ||
$requestOptions = [ | ||
'json' => $parameters, | ||
'headers' => $headers | ||
]; | ||
|
||
return $requestOptions; | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Novalnet\Bundle\NovalnetBundle\Client; | ||
|
||
/** | ||
* Interface for Handle Novalnet payport API request and response | ||
*/ | ||
interface GatewayInterface | ||
{ | ||
/** | ||
* @param string $paymentAccessKey | ||
* @param array $parameters | ||
* @param string $hostAddress | ||
*/ | ||
public function send($paymentAccessKey, $parameters, $hostAddress); | ||
} |
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,57 @@ | ||
<?php | ||
|
||
namespace Novalnet\Bundle\NovalnetBundle\Controller\Frontend; | ||
|
||
use Oro\Bundle\CheckoutBundle\Entity\Checkout; | ||
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor; | ||
use Oro\Bundle\SecurityBundle\Annotation\CsrfProtection; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Novalnet\Bundle\NovalnetBundle\Entity\NovalnetTransactionDetails; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; | ||
use Oro\Bundle\EntityBundle\ORM\DoctrineHelper; | ||
|
||
/** | ||
* Ajax Novalnet Controller | ||
*/ | ||
class AjaxNovalnetController extends AbstractController | ||
{ | ||
/** | ||
* @Route( | ||
* "/remove-payment-data/{id}", | ||
* name="novalnet_frontend_ajax_remove_payment_data", | ||
* requirements={"id"="\d+"}, | ||
* methods={"POST"} | ||
* ) | ||
* @ParamConverter("paymentTransaction", class="NovalnetBundle:NovalnetTransactionDetails", options={"id" = "id"}) | ||
* @param NovalnetTransactionDetails $novalnetTransactionDetails | ||
* @return JsonResponse | ||
*/ | ||
public function removePaymentDataAction(NovalnetTransactionDetails $novalnetTransactionDetails) | ||
{ | ||
$success = true; | ||
try { | ||
$doctrineHelper = $this->get(DoctrineHelper::class); | ||
$novalnetTransactionDetails->setToken(null); | ||
$novalnetTransactionDetails->setPaymentData(null); | ||
$entityManager = $doctrineHelper->getEntityManager('NovalnetBundle:NovalnetTransactionDetails'); | ||
$entityManager->persist($novalnetTransactionDetails); | ||
$entityManager->flush(); | ||
} catch (\Exception $exception) { | ||
$success = false; | ||
} | ||
|
||
return new JsonResponse(['successful' => $success]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getSubscribedServices() | ||
{ | ||
return array_merge(parent::getSubscribedServices(), [ | ||
DoctrineHelper::class | ||
]); | ||
} | ||
} |
Oops, something went wrong.