Skip to content

Commit

Permalink
Merge pull request #1 from coreshop/karser_implementation
Browse files Browse the repository at this point in the history
move to karser/payum-saferpay
  • Loading branch information
solverat authored Jun 10, 2020
2 parents 0547e2e + 469a189 commit f8f0edb
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# CoreShop Saferpay Payum Connector
This Bundle activates the Saferpay PaymentGateway in CoreShop.
It requires the [dachcom-digital/payum-saferpay](https:/dachcom-digital/payum-saferpay) repository which will be installed automatically.
It requires the [karser/PayumSaferpay](https:/karser/PayumSaferpay) repository which will be installed automatically.

## Installation

#### 1. Composer

```json
"coreshop/payum-saferpay-bundle": "~1.0.0"
"coreshop/payum-saferpay-bundle": "~2.0.0"
```

#### 2. Activate
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
}
],
"require": {
"php": "^7.1",
"dachcom-digital/payum-saferpay": "~1.2.0",
"coreshop/core-shop": "^2.0"
"php": "^7.2",
"karser/payum-saferpay": "^0.3",
"coreshop/core-shop": "^2.2"
},
"config": {
"bin-dir": "bin"
Expand Down
14 changes: 8 additions & 6 deletions src/CoreShop/Payum/Saferpay/Event/RefundEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*/


namespace CoreShop\Payum\SaferpayBundle\Event;

use CoreShop\Bundle\PayumBundle\Model\GatewayConfig;
use CoreShop\Component\Payment\Model\PaymentInterface;
use Payum\Core\Reply\ReplyInterface;
use Payum\Core\Request\Refund;
use Payum\Core\Payum;

Expand All @@ -25,8 +26,6 @@ class RefundEvent
protected $payum;

/**
* RefundEvent constructor.
*
* @param Payum $payum
*/
public function __construct(Payum $payum)
Expand All @@ -36,11 +35,14 @@ public function __construct(Payum $payum)

/**
* @param PaymentInterface $payment
* @throws \Payum\Core\Reply\ReplyInterface
* @throws ReplyInterface
*/
public function refund(PaymentInterface $payment)
{
$saferpay = $this->payum->getGateway($payment->getPaymentProvider()->getGatewayConfig()->getGatewayName());
$saferpay->execute(new Refund($payment));
/** @var GatewayConfig $gatewayConfig */
$gatewayConfig = $payment->getPaymentProvider()->getGatewayConfig();

$saferPay = $this->payum->getGateway($gatewayConfig->getGatewayName());
$saferPay->execute(new Refund($payment));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,23 @@ public function onPostExecute(Context $context)

$result = ArrayObject::ensureArrayObject($request->getResult());

$result['optional_payer_language_code'] = $gatewayLanguage;
$payerData = [];
if (isset($result['Payer']) && is_array($result['Payer'])) {
$payerData = $result['Payer'];
}

$payerData['LanguageCode'] = $gatewayLanguage;

$request->setResult((array)$result);
$result['Payer'] = $payerData;

$request->setResult((array) $result);
}

/**
* {@inheritdoc}
*/
public function onPreExecute(Context $context)
{

}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/CoreShop/Payum/Saferpay/Form/Payment/SaferpayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'groups' => 'coreshop',
]),
],
])
->add('interface', TextType::class, [
'constraints' => [
new NotBlank([
'groups' => 'coreshop',
]),
],
])
->add('optionalParameters', CollectionType::class, [
'allow_add' => true,
Expand Down
3 changes: 2 additions & 1 deletion src/CoreShop/Payum/Saferpay/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ services:
- { name: form.type }

CoreShop\Payum\SaferpayBundle\Event\RefundEvent:
public: true
arguments:
- '@payum'

payum.saferpay_gateway_factory:
class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder
arguments: [DachcomDigital\Payum\Saferpay\SaferpayGatewayFactory]
arguments: [Karser\PayumSaferpay\SaferpayGatewayFactory]
tags:
- {name: payum.gateway_factory_builder, factory: saferpay }
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ coreshop.provider.gateways.saferpay = Class.create(coreshop.provider.gateways.ab
{name: 'styling_content_security_enabled', defaultValue: '', description: ''},
{name: 'styling_theme', defaultValue: '', description: ''},
{name: 'config_set', defaultValue: '', description: ''},
{name: 'payer_note', defaultValue: '', description: ''},
],

getLayout: function (config) {
Expand All @@ -32,13 +33,17 @@ coreshop.provider.gateways.saferpay = Class.create(coreshop.provider.gateways.ab
['test', 'Test'],
['production', 'Production']
]
});

var optionalFields = [{
}), storeInterface = new Ext.data.ArrayStore({
fields: ['interface', 'interfaceName'],
data: [
['PAYMENT_PAGE', 'Payment Page'],
['TRANSACTION', 'Transaction']
]
}), optionalFields = [{
xtype: 'label',
anchor: '100%',
style: 'display:block; padding:5px; background:#f5f5f5; border:1px solid #eee; font-weight: 300;',
html: '<a href="https://saferpay.github.io/jsonapi/index.html#Payment_v1_PaymentPage_Initialize">Payment_v1_PaymentPage_Initialize (v 1.8)</a>'
html: '<a href="https://saferpay.github.io/jsonapi/index.html#Payment_v1_PaymentPage_Initialize">Payment (PaymentPage, v1.10)</a>'
}];

Ext.Array.each(this.optionalFields, function (field) {
Expand All @@ -58,7 +63,7 @@ coreshop.provider.gateways.saferpay = Class.create(coreshop.provider.gateways.ab
value: value
});

if(description != '') {
if (description !== '') {
optionalFields.push({
xtype: 'label',
text: description,
Expand Down Expand Up @@ -110,6 +115,19 @@ coreshop.provider.gateways.saferpay = Class.create(coreshop.provider.gateways.ab
length: 255,
value: config.terminalId ? config.terminalId : ''
},
{
xtype: 'combobox',
fieldLabel: t('saferpay.config.interface'),
name: 'gatewayConfig.config.interface',
value: config.interface ? config.interface : 'PAYMENT_PAGE',
store: storeInterface,
triggerAction: 'all',
valueField: 'interface',
displayField: 'interfaceName',
mode: 'local',
forceSelection: true,
selectOnFocus: true
},
{
xtype: 'fieldset',
title: t('saferpay.config.optional_parameter'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
saferpay.config.environment: 'Umgebung'
saferpay.config.username: 'Benutzername'
saferpay.config.password: 'Password'
saferpay.config.customer_id: 'Customer ID'
saferpay.config.password: 'Passwort'
saferpay.config.customer_id: 'Kunden ID'
saferpay.config.terminal_id: 'Terminal ID'
saferpay.config.interface: 'Interface Strategie'
saferpay.config.optional_parameter: 'Optionale Parameter'
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ saferpay.config.username: 'Username'
saferpay.config.password: 'Password'
saferpay.config.customer_id: 'Customer ID'
saferpay.config.terminal_id: 'Terminal ID'
saferpay.config.interface: 'Interface Strategy'
saferpay.config.optional_parameter: 'Optional Parameters'

0 comments on commit f8f0edb

Please sign in to comment.