Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
commerce_payplug
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
commerce_payplug
Commits
7f750c4f
Commit
7f750c4f
authored
3 weeks ago
by
Nicolas Morand
Committed by
Dominique CLAUSE
3 weeks ago
Browse files
Options
Downloads
Patches
Plain Diff
Resolve
#3503519
"Commerce 3 compatibility"
parent
fd04b4e4
No related branches found
Branches containing commit
No related tags found
2 merge requests
!4
Draft: Quick fix 'Class contains 1 abstract method and must therefore be declared...
,
!2
Resolve #3503519 "Commerce 3 compatibility"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Plugin/Commerce/PaymentGateway/OffsitePayPlug.php
+18
-59
18 additions, 59 deletions
src/Plugin/Commerce/PaymentGateway/OffsitePayPlug.php
src/PluginForm/OffsitePayPlug/OffsitePayPlugForm.php
+10
-2
10 additions, 2 deletions
src/PluginForm/OffsitePayPlug/OffsitePayPlugForm.php
with
28 additions
and
61 deletions
src/Plugin/Commerce/PaymentGateway/OffsitePayPlug.php
+
18
−
59
View file @
7f750c4f
...
...
@@ -3,17 +3,14 @@
namespace
Drupal\commerce_payplug\Plugin\Commerce\PaymentGateway
;
use
Drupal\commerce_order
\Entity\OrderInterface
;
use
Drupal\commerce_payment
\Attribute\CommercePaymentGateway
;
use
Drupal\commerce_payment
\Entity\PaymentInterface
;
use
Drupal\commerce_payment
\Exception\PaymentGatewayException
;
use
Drupal\commerce_payment
\PaymentMethodTypeManager
;
use
Drupal\commerce_payment
\PaymentTypeManager
;
use
Drupal\commerce_payment
\Plugin\Commerce\PaymentGateway\OffsitePaymentGatewayBase
;
use
Drupal\commerce_payplug
\
Services\PayPlugServiceInterface
;
use
Drupal\commerce_payplug
\
PluginForm\OffsitePayPlug\OffsitePayPlugForm
;
use
Drupal\commerce_price
\Price
;
use
Drupal\Component\Datetime\TimeInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\
Messenger\MessengerInterface
;
use
Drupal\Core\
StringTranslation\TranslatableMarkup
;
use
Payplug\Exception\BadRequestException
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
...
...
@@ -21,20 +18,17 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Provides the off-site PayPlug payment gateway.
*
* @CommercePaymentGateway(
* id = "offsite_payplug",
* label = "PayPlug (Off-site redirect)",
* display_label = "Payment via PayPlug",
* forms = {
* "offsite-payment" = "Drupal\commerce_payplug\PluginForm\OffsitePayPlug\OffsitePayPlugForm",
* },
* payment_method_types = {"credit_card"},
* credit_card_types = {
* "visa", "mastercard"
* },
* )
*/
#
[
CommercePaymentGateway
(
id
:
'offsite_payplug'
,
label
:
new
TranslatableMarkup
(
'PayPlug (Off-site redirect)'
),
display_label
:
new
TranslatableMarkup
(
'Payment via PayPlug'
),
forms
:
[
'offsite-payment'
=>
OffsitePayPlugForm
::
class
,
],
payment_method_types
:
[
'credit_card'
],
credit_card_types
:
[
'visa'
,
'mastercard'
],
)]
class
OffsitePayPlug
extends
OffsitePaymentGatewayBase
implements
OffsitePayPlugInterface
{
/**
...
...
@@ -51,49 +45,14 @@ class OffsitePayPlug extends OffsitePaymentGatewayBase implements OffsitePayPlug
*/
protected
$messenger
;
/**
* Constructs a new OffsitePayPlug object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\commerce_payment\PaymentTypeManager $payment_type_manager
* The payment type manager.
* @param \Drupal\commerce_payment\PaymentMethodTypeManager $payment_method_type_manager
* The payment method type manager.
* @param \Drupal\commerce_payplug\Services\PayplugServiceInterface
* The PayPlug payment service interface.
* @param \Drupal\Component\Datetime\TimeInterface $time
* The time service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
EntityTypeManagerInterface
$entity_type_manager
,
PaymentTypeManager
$payment_type_manager
,
PaymentMethodTypeManager
$payment_method_type_manager
,
PayPlugServiceInterface
$payplug_service
,
TimeInterface
$time
,
MessengerInterface
$messenger
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$entity_type_manager
,
$payment_type_manager
,
$payment_method_type_manager
,
$time
);
$this
->
payPlugService
=
$payplug_service
;
$this
->
messenger
=
$messenger
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
return
new
static
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$container
->
get
(
'entity_type.manager'
),
$container
->
get
(
'plugin.manager.commerce_payment_type'
),
$container
->
get
(
'plugin.manager.commerce_payment_method_type'
),
$container
->
get
(
'commerce_payplug.payplug.service'
),
$container
->
get
(
'datetime.time'
),
$container
->
get
(
'messenger'
)
);
$instance
=
parent
::
create
(
$container
,
$configuration
,
$plugin_id
,
$plugin_definition
);
$instance
->
payPlugService
=
$container
->
get
(
'commerce_payplug.payplug.service'
);
$instance
->
messenger
=
$container
->
get
(
'messenger'
);
return
$instance
;
}
/**
...
...
@@ -188,7 +147,7 @@ class OffsitePayPlug extends OffsitePaymentGatewayBase implements OffsitePayPlug
$this
->
payPlugService
->
setApiKey
(
$api_key
);
$data
=
[
'amount'
=>
(
int
)
$
payment_gateway_plugin
->
toMinorUnits
(
$amount
)
'amount'
=>
(
int
)
$
this
->
minorUnitsConverter
->
toMinorUnits
(
$amount
)
];
try
{
if
(
$this
->
payPlugService
->
createPayPlugRefund
(
$payment
->
getRemoteId
(),
$data
))
{
...
...
This diff is collapsed.
Click to expand it.
src/PluginForm/OffsitePayPlug/OffsitePayPlugForm.php
+
10
−
2
View file @
7f750c4f
...
...
@@ -24,11 +24,19 @@ class OffsitePayPlugForm extends BasePaymentOffsiteForm {
*/
protected
$payPlugService
;
/**
* The minor units converter.
*
* @var \Drupal\commerce_price\MinorUnitsConverterInterface
*/
protected
$minorUnitsConverter
;
/**
* Constructs a new PaymentOffsiteForm object.
*/
function
__construct
()
{
public
function
__construct
()
{
$this
->
payPlugService
=
\Drupal
::
service
(
'commerce_payplug.payplug.service'
);
$this
->
minorUnitsConverter
=
\Drupal
::
service
(
'commerce_price.minor_units_converter'
);
}
/**
...
...
@@ -58,7 +66,7 @@ class OffsitePayPlugForm extends BasePaymentOffsiteForm {
$payplug_payment
=
NULL
;
try
{
$object
=
[
'amount'
=>
(
int
)
$
payment_gateway_plugin
->
toMinorUnits
(
$payment
->
getAmount
()),
'amount'
=>
(
int
)
$
this
->
minorUnitsConverter
->
toMinorUnits
(
$payment
->
getAmount
()),
'currency'
=>
$payment
->
getAmount
()
->
getCurrencyCode
(),
'billing'
=>
[
'first_name'
=>
$address
->
getGivenName
()
?
$address
->
getGivenName
()
:
'N/A'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment