Loading src/Plugin/Commerce/PaymentGateway/Mollie.php +10 −3 Original line number Diff line number Diff line Loading @@ -227,6 +227,8 @@ class Mollie extends OffsitePaymentGatewayBase implements HasPaymentInstructions // Capture payment. $payment_transition = $payment->getState()->getWorkflow()->getTransition('authorize_capture'); $payment->getState()->applyTransition($payment_transition); $payment->setRemoteState($mollie_payment_remote_object->status); $payment->save(); break; case MolliePaymentStatus::STATUS_CANCELED: Loading @@ -235,12 +237,16 @@ class Mollie extends OffsitePaymentGatewayBase implements HasPaymentInstructions $payment->getState()->applyTransition($payment_transition); $payment_transition = $payment->getState()->getWorkflow()->getTransition('void'); $payment->getState()->applyTransition($payment_transition); $payment->setRemoteState($mollie_payment_remote_object->status); $payment->save(); break; case MolliePaymentStatus::STATUS_OPEN: // Authorize payment. $payment_transition = $payment->getState()->getWorkflow()->getTransition('authorize'); $payment->getState()->applyTransition($payment_transition); $payment->setRemoteState($mollie_payment_remote_object->status); $payment->save(); break; case MolliePaymentStatus::STATUS_FAILED: Loading @@ -249,6 +255,8 @@ class Mollie extends OffsitePaymentGatewayBase implements HasPaymentInstructions $payment->getState()->applyTransition($payment_transition); $payment_transition = $payment->getState()->getWorkflow()->getTransition('void'); $payment->getState()->applyTransition($payment_transition); $payment->setRemoteState($mollie_payment_remote_object->status); $payment->save(); break; case MolliePaymentStatus::STATUS_EXPIRED: Loading @@ -257,11 +265,10 @@ class Mollie extends OffsitePaymentGatewayBase implements HasPaymentInstructions $payment->getState()->applyTransition($payment_transition); $payment_transition = $payment->getState()->getWorkflow()->getTransition('expire'); $payment->getState()->applyTransition($payment_transition); break; } $payment->setRemoteState($mollie_payment_remote_object->status); $payment->save(); break; } // Return empty response with 200 status code. return new JsonResponse(); Loading tests/src/Functional/MolliePaymentOffsiteFormTest.php +30 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { // First call onNotify(). $this->helperCallOnNotifyWebhook(); // Second call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); // Then do onReturn() (go back to website). $this->drupalGet('mollie_return/1'); $this->assertSession()->addressEquals('checkout/1/complete'); Loading @@ -214,6 +217,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { 'commerce_payment_status' => 'completed', 'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_PAID, ]); // Third call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); } /** Loading Loading @@ -247,6 +253,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { // First call onNotify(). $this->helperCallOnNotifyWebhook(); // Second call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); // Then do onReturn() (go back to website). $this->drupalGet('mollie_return/1'); $this->assertSession()->addressEquals('checkout/1/review'); Loading @@ -260,6 +269,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { 'commerce_payment_status' => 'authorization_voided', 'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_CANCELED, ]); // Third call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); } /** Loading Loading @@ -295,6 +307,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { // First call onNotify(). $this->helperCallOnNotifyWebhook(); // Second call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); // Then do onReturn() (go back to website). $this->drupalGet('mollie_return/1'); $this->assertSession()->addressEquals('mollie_return/1'); Loading @@ -308,6 +323,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { 'commerce_payment_status' => 'authorization', 'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_OPEN, ]); // Third call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); } /** Loading Loading @@ -345,6 +363,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { // First call onNotify(). $this->helperCallOnNotifyWebhook(); // Second call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); // Then do onReturn() (go back to website). $this->drupalGet('mollie_return/1'); $this->assertSession()->addressEquals('checkout/1/review'); Loading @@ -359,6 +380,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { 'commerce_payment_status' => 'authorization_voided', 'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_FAILED, ]); // Third call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); } /** Loading Loading @@ -398,6 +422,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { // First call onNotify(). $this->helperCallOnNotifyWebhook(); // Second call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); // Then do onReturn() (go back to website). $this->drupalGet('mollie_return/1'); $this->assertSession()->addressEquals('checkout/1/review'); Loading @@ -412,6 +439,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { 'commerce_payment_status' => 'authorization_expired', 'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_EXPIRED, ]); // Third call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); } /** Loading Loading
src/Plugin/Commerce/PaymentGateway/Mollie.php +10 −3 Original line number Diff line number Diff line Loading @@ -227,6 +227,8 @@ class Mollie extends OffsitePaymentGatewayBase implements HasPaymentInstructions // Capture payment. $payment_transition = $payment->getState()->getWorkflow()->getTransition('authorize_capture'); $payment->getState()->applyTransition($payment_transition); $payment->setRemoteState($mollie_payment_remote_object->status); $payment->save(); break; case MolliePaymentStatus::STATUS_CANCELED: Loading @@ -235,12 +237,16 @@ class Mollie extends OffsitePaymentGatewayBase implements HasPaymentInstructions $payment->getState()->applyTransition($payment_transition); $payment_transition = $payment->getState()->getWorkflow()->getTransition('void'); $payment->getState()->applyTransition($payment_transition); $payment->setRemoteState($mollie_payment_remote_object->status); $payment->save(); break; case MolliePaymentStatus::STATUS_OPEN: // Authorize payment. $payment_transition = $payment->getState()->getWorkflow()->getTransition('authorize'); $payment->getState()->applyTransition($payment_transition); $payment->setRemoteState($mollie_payment_remote_object->status); $payment->save(); break; case MolliePaymentStatus::STATUS_FAILED: Loading @@ -249,6 +255,8 @@ class Mollie extends OffsitePaymentGatewayBase implements HasPaymentInstructions $payment->getState()->applyTransition($payment_transition); $payment_transition = $payment->getState()->getWorkflow()->getTransition('void'); $payment->getState()->applyTransition($payment_transition); $payment->setRemoteState($mollie_payment_remote_object->status); $payment->save(); break; case MolliePaymentStatus::STATUS_EXPIRED: Loading @@ -257,11 +265,10 @@ class Mollie extends OffsitePaymentGatewayBase implements HasPaymentInstructions $payment->getState()->applyTransition($payment_transition); $payment_transition = $payment->getState()->getWorkflow()->getTransition('expire'); $payment->getState()->applyTransition($payment_transition); break; } $payment->setRemoteState($mollie_payment_remote_object->status); $payment->save(); break; } // Return empty response with 200 status code. return new JsonResponse(); Loading
tests/src/Functional/MolliePaymentOffsiteFormTest.php +30 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { // First call onNotify(). $this->helperCallOnNotifyWebhook(); // Second call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); // Then do onReturn() (go back to website). $this->drupalGet('mollie_return/1'); $this->assertSession()->addressEquals('checkout/1/complete'); Loading @@ -214,6 +217,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { 'commerce_payment_status' => 'completed', 'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_PAID, ]); // Third call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); } /** Loading Loading @@ -247,6 +253,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { // First call onNotify(). $this->helperCallOnNotifyWebhook(); // Second call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); // Then do onReturn() (go back to website). $this->drupalGet('mollie_return/1'); $this->assertSession()->addressEquals('checkout/1/review'); Loading @@ -260,6 +269,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { 'commerce_payment_status' => 'authorization_voided', 'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_CANCELED, ]); // Third call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); } /** Loading Loading @@ -295,6 +307,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { // First call onNotify(). $this->helperCallOnNotifyWebhook(); // Second call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); // Then do onReturn() (go back to website). $this->drupalGet('mollie_return/1'); $this->assertSession()->addressEquals('mollie_return/1'); Loading @@ -308,6 +323,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { 'commerce_payment_status' => 'authorization', 'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_OPEN, ]); // Third call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); } /** Loading Loading @@ -345,6 +363,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { // First call onNotify(). $this->helperCallOnNotifyWebhook(); // Second call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); // Then do onReturn() (go back to website). $this->drupalGet('mollie_return/1'); $this->assertSession()->addressEquals('checkout/1/review'); Loading @@ -359,6 +380,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { 'commerce_payment_status' => 'authorization_voided', 'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_FAILED, ]); // Third call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); } /** Loading Loading @@ -398,6 +422,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { // First call onNotify(). $this->helperCallOnNotifyWebhook(); // Second call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); // Then do onReturn() (go back to website). $this->drupalGet('mollie_return/1'); $this->assertSession()->addressEquals('checkout/1/review'); Loading @@ -412,6 +439,9 @@ class MolliePaymentOffsiteFormTest extends CommerceBrowserTestBase { 'commerce_payment_status' => 'authorization_expired', 'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_EXPIRED, ]); // Third call onNotify(). Nothing should happen. $this->helperCallOnNotifyWebhook(); } /** Loading