Skip to content

Commit b5d9e73

Browse files
authored
Merge pull request #23 from payplug/qa-4-1
Release 4.1.1
2 parents 4b105c3 + 576baad commit b5d9e73

2 files changed

Lines changed: 37 additions & 16 deletions

File tree

src/Resources/public/js/app/components/payplug-transition-button-component.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,24 @@ define(function(require) {
4242
* @inheritDoc
4343
*/
4444
beforeTransit: function(eventData) {
45-
if (this.options.maxAmount <= (this.options.totalValue * 100)) {
46-
eventData.stopped = true;
45+
if (~eventData.data.paymentMethod.indexOf("payplug")) {
46+
if (this.options.maxAmount <= (this.options.totalValue * 100)) {
47+
eventData.stopped = true;
4748

48-
messenger.notificationFlashMessage(
49-
'warning',
50-
__('synolia.frontend.payment_method.checkout.payplug.maximum_amount.label')
51-
);
52-
}
49+
messenger.notificationFlashMessage(
50+
'warning',
51+
__('synolia.frontend.payment_method.checkout.payplug.maximum_amount.label')
52+
);
53+
}
5354

54-
if (this.options.minAmount >= (this.options.totalValue * 100)) {
55-
eventData.stopped = true;
55+
if (this.options.minAmount >= (this.options.totalValue * 100)) {
56+
eventData.stopped = true;
5657

57-
messenger.notificationFlashMessage(
58-
'warning',
59-
__('synolia.frontend.payment_method.checkout.payplug.minimum_amount.label')
60-
);
58+
messenger.notificationFlashMessage(
59+
'warning',
60+
__('synolia.frontend.payment_method.checkout.payplug.minimum_amount.label')
61+
);
62+
}
6163
}
6264
},
6365
});

src/Service/Gateway.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class Gateway
3030
{
3131
const FIRST_NAME_LAST_NAME_MAX_LENGTH = 100;
3232
const USER_AGENT_PRODUCT_NAME = 'PayPlug-OroCommerce';
33+
const USER_AGENT_OROCOMMERCE_VERSION_PREFIX = 'OroCommerce/';
34+
const PAYPLUG_MODULE_COMPOSER_NAME = 'payplug/payplug-orocommerce';
3335

3436
/**
3537
* @var DoctrineHelper
@@ -140,6 +142,7 @@ public function treatNotify(PayplugConfigInterface $config): IVerifiableAPIResou
140142
public function createPayment(PaymentTransaction $paymentTransaction, PayplugConfigInterface $config)
141143
{
142144
$payplugClient = $this->initPayplugClientAndSetDebugModeForLogger($config);
145+
$routerContext = $this->router->getContext();
143146

144147
$this->logger->debug(__METHOD__ . ' BEGIN');
145148

@@ -149,7 +152,12 @@ public function createPayment(PaymentTransaction $paymentTransaction, PayplugCon
149152
'shipping' => $this->getAddressValues(AddressType::TYPE_SHIPPING, $paymentTransaction),
150153
'billing' => $this->getAddressValues(AddressType::TYPE_BILLING, $paymentTransaction),
151154
'hosted_payment' => $this->getCallbackUrls($paymentTransaction),
152-
'notification_url' => $this->getNotificationUrl($paymentTransaction)
155+
'notification_url' => $this->getNotificationUrl($paymentTransaction),
156+
'metadata' => [
157+
'order_id' => $paymentTransaction->getEntityIdentifier(),
158+
'customer_id' => $paymentTransaction->getFrontendOwner()->getId(),
159+
'website' => sprintf('%s://%s', $routerContext->getScheme(), $routerContext->getHost()),
160+
]
153161
];
154162

155163
$this->logger->debug('Payment::create from data ' . $this->logger->anonymizeAndJsonEncodeArray($data));
@@ -179,11 +187,21 @@ public function refundPayment(
179187

180188
$this->logger->debug(__METHOD__ . ' BEGIN');
181189
$amountToRefund = (int) round($amount * 100);
190+
$routerContext = $this->router->getContext();
182191

183192
$refund = null;
184193

194+
$data = [
195+
'amount' => $amountToRefund,
196+
'metadata' => [
197+
'order_id' => $paymentTransaction->getEntityIdentifier(),
198+
'customer_id' => $paymentTransaction->getFrontendOwner()->getId(),
199+
'website' => sprintf('%s://%s', $routerContext->getScheme(), $routerContext->getHost()),
200+
]
201+
];
202+
185203
try {
186-
$refund = Refund::create($paymentTransaction->getReference(), ['amount' => $amountToRefund], $payplugClient);
204+
$refund = Refund::create($paymentTransaction->getReference(), $data, $payplugClient);
187205
} catch (PayplugException $exception) {
188206
$this->logger->debug($exception->getHttpResponse());
189207
throw new \Exception('Refund action cannot be performed');
@@ -214,7 +232,8 @@ protected function initPayplugClientAndSetDebugModeForLogger(PayplugConfigInterf
214232

215233
HttpClient::addDefaultUserAgentProduct(
216234
self::USER_AGENT_PRODUCT_NAME,
217-
$this->versionHelper->getVersion()
235+
$this->versionHelper->getVersion(self::PAYPLUG_MODULE_COMPOSER_NAME),
236+
self::USER_AGENT_OROCOMMERCE_VERSION_PREFIX . $this->versionHelper->getVersion()
218237
);
219238

220239
return $client;

0 commit comments

Comments
 (0)