@@ -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