From c5a4e4b24b8f29f0dc39bdb5a87d8168d3fefd97 Mon Sep 17 00:00:00 2001 From: mglaman Date: Mon, 16 Jan 2017 11:50:20 -0600 Subject: [PATCH] Issue #2843995 by mglaman: Implement Payments Standard --- .../PaymentGateway/PaymentsStandard.php | 76 +++++++++++++++++++ .../PaymentsStandardInterface.php | 9 +++ 2 files changed, 85 insertions(+) create mode 100644 src/Plugin/Commerce/PaymentGateway/PaymentsStandard.php create mode 100644 src/Plugin/Commerce/PaymentGateway/PaymentsStandardInterface.php diff --git a/src/Plugin/Commerce/PaymentGateway/PaymentsStandard.php b/src/Plugin/Commerce/PaymentGateway/PaymentsStandard.php new file mode 100644 index 0000000..7a063d8 --- /dev/null +++ b/src/Plugin/Commerce/PaymentGateway/PaymentsStandard.php @@ -0,0 +1,76 @@ +get('request_stack')->getCurrentRequest(); + + // mc_gross = 89.50 + // invoice = 3-TIMESTAMP + // protection_eligibility + // item_number1 + // payer_id + // tax + // payment_date + // payment_status (Pending) + // notify_version + // payer_status + // payer_email + // verify_sign + // tnx_id + // pending_reason + // payment_gross + // auth + + // Create the payment. + $payment_storage = \Drupal::entityTypeManager()->getStorage('commerce_payment'); + $payment = $payment_storage->create([ + 'state' => 'authorization', + 'amount' => $order->getTotalPrice(), + // Gateway plugins cannot reach their matching config entity directly. + 'payment_gateway' => $order->payment_gateway->entity->id(), + 'order_id' => $order->id(), + 'test' => $this->getMode() == 'test', + 'remote_id' => $current_request->request->get('txn_id'), + 'remote_state' => $current_request->request->get('payment_status'), + 'authorized' => REQUEST_TIME, + ]); + $payment->save(); + } + + /** + * {@inheritdoc} + */ + public function onRedirectCancel(OrderInterface $order) { + // Nothing to do. + } + +} diff --git a/src/Plugin/Commerce/PaymentGateway/PaymentsStandardInterface.php b/src/Plugin/Commerce/PaymentGateway/PaymentsStandardInterface.php new file mode 100644 index 0000000..579cf87 --- /dev/null +++ b/src/Plugin/Commerce/PaymentGateway/PaymentsStandardInterface.php @@ -0,0 +1,9 @@ +