forked from payrexx/shopware6-payrexx-gateway
-
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.
Check API Credentials and easy Access to Payrexx Support from our Plugin
- Loading branch information
Showing
24 changed files
with
557 additions
and
141 deletions.
There are no files selected for viewing
105 changes: 0 additions & 105 deletions
105
PayrexxPaymentGatewaySW6/Components/PayrexxGateway/PayrexxGatewayService.php
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
68 changes: 68 additions & 0 deletions
68
PayrexxPaymentGatewaySW6/src/Controller/SettingsController.php
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,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PayrexxPaymentGateway\Controller; | ||
|
||
use Shopware\Core\Framework\Routing\Annotation\RouteScope; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
use Shopware\Core\Framework\Context; | ||
use Psr\Log\LoggerInterface; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* @RouteScope(scopes={"api"}) | ||
*/ | ||
class SettingsController extends AbstractController | ||
{ | ||
/** | ||
* @var ContainerInterface | ||
*/ | ||
protected $container; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
protected $logger; | ||
|
||
/** | ||
* @param ContainerInterface $container | ||
* @param LoggerInterface $logger | ||
**/ | ||
public function __construct( | ||
ContainerInterface $container, | ||
LoggerInterface $logger | ||
) { | ||
$this->container = $container; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* @Route("/api/v{version}/_action/payrexx_payment/validate-api-credentials", name="api.action.payrexx_payment.validate.api.credentials", methods={"POST"}) | ||
* @throws \Payrexx\PayrexxException | ||
*/ | ||
public function validateApiCredentials(Request $request, Context $context): JsonResponse | ||
{ | ||
require_once dirname(dirname(__DIR__)). '/vendor/autoload.php'; | ||
$config = $request->get('credentials', []); | ||
|
||
$payrexx = new \Payrexx\Payrexx($config['instanceName'], $config['apiKey']); | ||
|
||
$signatureCheck = new \Payrexx\Models\Request\SignatureCheck(); | ||
|
||
$error = ''; | ||
try { | ||
$response = $payrexx->getOne($signatureCheck); | ||
} catch(\Payrexx\PayrexxException $e) { | ||
$error = $e; | ||
} | ||
return new JsonResponse(['credentialsValid' => !$error, 'error' => $error]); | ||
|
||
} | ||
|
||
} |
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
34 changes: 34 additions & 0 deletions
34
...ntGatewaySW6/src/Resources/app/administration/src/api/payrexx-payment-settings.service.js
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,34 @@ | ||
const { Application } = Shopware; | ||
const ApiService = Shopware.Classes.ApiService; | ||
|
||
class PayrexxPaymentSettingsService extends ApiService { | ||
constructor(httpClient, loginService, apiEndpoint = 'payrexx_payment') { | ||
super(httpClient, loginService, apiEndpoint); | ||
} | ||
|
||
validateApiCredentials(credentials) { | ||
const headers = this.getBasicHeaders(); | ||
|
||
return this.httpClient | ||
.post( | ||
`_action/${this.getApiBasePath()}/validate-api-credentials`, | ||
{ | ||
credentials: credentials, | ||
}, | ||
{ | ||
headers: headers | ||
} | ||
) | ||
.then((response) => { | ||
return ApiService.handleResponse(response); | ||
}); | ||
} | ||
|
||
} | ||
|
||
Application.addServiceProvider('PayrexxPaymentSettingsService', (container) => { | ||
const initContainer = Application.getContainer('init'); | ||
|
||
return new PayrexxPaymentSettingsService(initContainer.httpClient, container.loginService); | ||
}); | ||
|
2 changes: 2 additions & 0 deletions
2
PayrexxPaymentGatewaySW6/src/Resources/app/administration/src/main.js
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,2 @@ | ||
import './module/payrexx-payment'; | ||
import './api/payrexx-payment-settings.service'; |
8 changes: 8 additions & 0 deletions
8
...ources/app/administration/src/module/payrexx-payment/extension/sw-settings-index/index.js
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,8 @@ | ||
import template from './sw-settings-index.html.twig'; | ||
import './sw-settings.index.scss'; | ||
|
||
const { Component } = Shopware; | ||
|
||
Component.override('sw-settings-index', { | ||
template | ||
}); |
11 changes: 11 additions & 0 deletions
11
...ration/src/module/payrexx-payment/extension/sw-settings-index/sw-settings-index.html.twig
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,11 @@ | ||
{% block sw_settings_content_card_slot_plugins %} | ||
{% parent %} | ||
|
||
<sw-settings-item :label="$tc('payrexx-payment.module.title')" | ||
:to="{ name: 'payrexx.payment.index' }" | ||
:backgroundEnabled="false"> | ||
<template #icon> | ||
<img class="sw-settings-index__payrexx-icon" :src="'payrexxpaymentgatewaysw6/administration/plugin.png' | asset"> | ||
</template> | ||
</sw-settings-item> | ||
{% endblock %} |
8 changes: 8 additions & 0 deletions
8
...inistration/src/module/payrexx-payment/extension/sw-settings-index/sw-settings.index.scss
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,8 @@ | ||
.payrexx-context-button__button { | ||
height: 48px; | ||
line-height: 40px; | ||
} | ||
|
||
.sw-settings-index__payrexx-icon { | ||
height: 40px; | ||
} |
34 changes: 34 additions & 0 deletions
34
...exxPaymentGatewaySW6/src/Resources/app/administration/src/module/payrexx-payment/index.js
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,34 @@ | ||
import './extension/sw-settings-index'; | ||
|
||
import './page/payrexx-settings'; | ||
|
||
import deDE from './snippet/de_DE.json'; | ||
import enGB from './snippet/en_GB.json'; | ||
|
||
|
||
const { Module } = Shopware; | ||
|
||
Module.register('payrexx-payment', { | ||
type: 'plugin', | ||
name: 'PayrexxPayment', | ||
title: 'payrexx-payment.module.title', | ||
description: 'payrexx-payment.module.description', | ||
version: '1.0.0', | ||
targetVersion: '1.0.0', | ||
icon: 'default-action-settings', | ||
|
||
snippets: { | ||
'de-DE': deDE, | ||
'en-GB': enGB | ||
}, | ||
|
||
routes: { | ||
index: { | ||
component: 'payrexx-settings', | ||
path: 'index', | ||
meta: { | ||
parentPath: 'sw.settings.index' | ||
} | ||
} | ||
} | ||
}); |
Oops, something went wrong.