Skip to content

Commit 5d36c1e

Browse files
STRIPE-37: Stripe Split Order Payment (#33943)
- Implemented CI fixes
1 parent 932fdf9 commit 5d36c1e

9 files changed

Lines changed: 39 additions & 17 deletions

File tree

src/Oro/Bundle/StripeBundle/Command/ReAuthorizeCronCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ protected function configure()
4646
$this->setDescription('Cancels expiring Stripe authorization holds and places new ones instead.')
4747
->setHelp(
4848
<<<'HELP'
49-
The <info>%command.name%</info> command cancels expiring Stripe authorization holds and places new ones instead (payment card authorizations expire in Stripe after 7 days by default).
49+
The <info>%command.name%</info> command cancels expiring Stripe authorization holds and places new ones instead
50+
(payment card authorizations expire in Stripe after 7 days by default).
5051
5152
<info>php %command.full_name%</info>
5253

src/Oro/Bundle/StripeBundle/EventListener/StripePaymentCallBackListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public function setLogger(LoggerInterface $logger): void
4141
$this->logger = $logger;
4242
}
4343

44+
/**
45+
* @param AbstractCallbackEvent $event
46+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
47+
*/
4448
public function onReturn(AbstractCallbackEvent $event)
4549
{
4650
$paymentTransaction = $event->getPaymentTransaction();

src/Oro/Bundle/StripeBundle/Handler/ReAuthorizationHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function reAuthorize(): void
5252
/** @var StripePaymentConfig[] $configs */
5353
$configs = array_filter(
5454
(array)$this->paymentConfigsProvider->getConfigs(),
55-
static fn(StripePaymentConfig $paymentConfig) => $paymentConfig->isReAuthorizationAllowed()
55+
static fn (StripePaymentConfig $paymentConfig) => $paymentConfig->isReAuthorizationAllowed()
5656
);
5757

5858
if (empty($configs)) {

src/Oro/Bundle/StripeBundle/Resources/public/js/app/components/stripe-payment-component.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ define(function(require) {
4848
// Handle additional user actions (3D secure validation, etc.. )
4949
const self = this;
5050

51-
const intentErrorHandler = function () {
51+
const intentErrorHandler = function(result) {
5252
mediator.execute(
5353
'showFlashMessage',
5454
'error',
@@ -61,7 +61,7 @@ define(function(require) {
6161
);
6262
};
6363

64-
const exceptionHandler = function (error) {
64+
const exceptionHandler = function(error) {
6565
console.log(error);
6666
mediator.execute(
6767
'showFlashMessage',
@@ -73,27 +73,27 @@ define(function(require) {
7373
const stripe = stripeClient.getStripeInstance(this.options);
7474
if (_.has(response, 'payment_intent_client_secret')) {
7575
stripe.handleCardAction(response.payment_intent_client_secret)
76-
.then(function (result) {
76+
.then(function(result) {
7777
if (result.error) {
78-
intentErrorHandler();
78+
intentErrorHandler(result);
7979
} else if (result.hasOwnProperty('paymentIntent')) {
80-
const paymentIntentId = result.paymentIntent.id;
80+
const intentId = result.paymentIntent.id;
8181
mediator.execute(
8282
'redirectTo',
83-
{url: eventData.responseData.returnUrl + '?paymentIntentId=' + paymentIntentId},
83+
{url: eventData.responseData.returnUrl + '?paymentIntentId=' + intentId},
8484
{redirect: true}
8585
);
8686
}
8787
})
8888
.catch(exceptionHandler)
89-
.always(function () {
89+
.always(function() {
9090
mediator.execute('hideLoading');
9191
});
9292
} else if (_.has(response, 'setup_intent_client_secret')) {
9393
stripe.confirmCardSetup(response.setup_intent_client_secret)
94-
.then(function (result) {
94+
.then(function(result) {
9595
if (result.error) {
96-
intentErrorHandler();
96+
intentErrorHandler(result);
9797
} else if (result.hasOwnProperty('setupIntent')) {
9898
const setupIntentId = result.setupIntent.id;
9999
mediator.execute(
@@ -104,12 +104,16 @@ define(function(require) {
104104
}
105105
})
106106
.catch(exceptionHandler)
107-
.always(function () {
107+
.always(function() {
108108
mediator.execute('hideLoading');
109109
});
110110
}
111111
} else if (_.has(eventData.responseData, 'partiallyPaidUrl')) {
112-
mediator.execute('redirectTo', {url: eventData.responseData.partiallyPaidUrl}, {redirect: true});
112+
mediator.execute(
113+
'redirectTo',
114+
{url: eventData.responseData.partiallyPaidUrl},
115+
{redirect: true}
116+
);
113117
} else {
114118
mediator.execute('redirectTo', {url: eventData.responseData.errorUrl}, {redirect: true});
115119
}

src/Oro/Bundle/StripeBundle/Tests/Behat/Mock/Client/StripeGatewayMock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private function createSetupIntentObject()
110110
private function getStatus(string $card): string
111111
{
112112
return match ($card) {
113-
self::NO_AUTH_CARD => 'succeeded',
113+
self::NO_AUTH_CARD => 'succeeded',
114114
self::AUTH_CARD => 'requires_action',
115115
self::ERROR_CARD => 'error',
116116
};

src/Oro/Bundle/StripeBundle/Tests/Functional/DataFixtures/LoadPaymentTransactions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ class LoadPaymentTransactions extends AbstractFixture implements ContainerAwareI
8888

8989
public function load(ObjectManager $manager): void
9090
{
91-
$transactionExpireHours = $this->container->getParameter('oro_stripe.authorization_transaction_expiration_hours');
91+
$transactionExpireHours = $this->container
92+
->getParameter('oro_stripe.authorization_transaction_expiration_hours');
93+
9294
$expireDate = (new \DateTime('now', new \DateTimeZone('UTC')))
9395
->modify(sprintf('-%d hour', $transactionExpireHours + 1));
9496

src/Oro/Bundle/StripeBundle/Tests/Unit/Client/StripeGatewayTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
use Stripe\SetupIntent;
3939
use Stripe\StripeClient;
4040

41+
/**
42+
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
43+
*/
4144
class StripeGatewayTest extends TestCase
4245
{
4346
use SetReflectionPropertyTrait;

src/Oro/Bundle/StripeBundle/Tests/Unit/Model/SetupIntentResponseTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public function testResponseObject(
3131
$this->assertEquals($expected, $responseData['data']);
3232
}
3333

34+
/**
35+
* @return \Generator
36+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
37+
*/
3438
public function responseDataProvider(): \Generator
3539
{
3640
yield [

src/Oro/Bundle/StripeBundle/Tests/Unit/Notification/ReAuthorizeMessageNotificationsTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ public function testSendAuthorizationFailed()
113113
$this->doctrineHelper->expects($this->never())
114114
->method('getSingleEntityIdentifier');
115115

116-
$this->messageNotifications->sendAuthorizationFailed($paymentTransaction, ['test@test.com']);
116+
$this->messageNotifications->sendAuthorizationFailed(
117+
$paymentTransaction,
118+
['test@test.com'],
119+
'Payment card declined'
120+
);
117121
}
118122

119123
public function testSendAuthorizationFailedWhenEntityIsNotOrder()
@@ -188,4 +192,4 @@ public function testSendAuthorizationFailedWhenEntityIsNotOrder()
188192
'Payment card declined'
189193
);
190194
}
191-
}
195+
}

0 commit comments

Comments
 (0)