diff --git a/Gateway/Config/Config.php b/Gateway/Config/Config.php
index 1abcbb4..491f8aa 100755
--- a/Gateway/Config/Config.php
+++ b/Gateway/Config/Config.php
@@ -29,6 +29,7 @@ class Config extends \Magento\Payment\Gateway\Config\Config
const KEY_USE_CCV = 'useccv';
const KEY_ALLOW_SPECIFIC = 'allowspecific';
const KEY_SPECIFIC_COUNTRY = 'specificcountry';
+ const KEY_DEBUG = 'debug';
/**
* @return array
@@ -105,4 +106,11 @@ public function getSecretKey() {
public function isTestMode() {
return (bool) $this->getValue(self::KEY_ENVIRONMENT);
}
+
+ /**
+ * @return bool
+ */
+ public function isDebugOn() {
+ return (bool) $this->getValue(self::KEY_DEBUG);
+ }
}
\ No newline at end of file
diff --git a/Gateway/Http/Client/AbstractTransaction.php b/Gateway/Http/Client/AbstractTransaction.php
index b340790..8f42216 100755
--- a/Gateway/Http/Client/AbstractTransaction.php
+++ b/Gateway/Http/Client/AbstractTransaction.php
@@ -21,6 +21,8 @@
use Magento\Payment\Gateway\Http\TransferInterface;
use Magento\Payment\Model\Method\Logger;
use Psr\Log\LoggerInterface;
+use Pmclain\Stripe\Gateway\Config\Config;
+use Magento\Framework\App\ObjectManager;
abstract class AbstractTransaction implements ClientInterface
{
@@ -30,14 +32,18 @@ abstract class AbstractTransaction implements ClientInterface
protected $adapter;
+ protected $config;
+
public function __construct(
LoggerInterface $logger,
Logger $customLogger,
- StripeAdapter $adapter
+ StripeAdapter $adapter,
+ Config $config = null
) {
$this->logger = $logger;
$this->customLogger = $customLogger;
$this->adapter = $adapter;
+ $this->config = $config ?: ObjectManager::getInstance()->get(Config::class);
}
public function placeRequest(
@@ -54,10 +60,21 @@ public function placeRequest(
$response['object'] = $this->process($data);
}catch (\Exception $e) {
$message = __($e->getMessage() ?: 'Sorry, but something went wrong.');
- $this->logger->critical($message);
+ $this->logger->critical($e);
throw new ClientException($message);
}finally {
- $log['response'] = (array) $response['object'];
+ if ($response['object'] instanceof \Stripe\Error\Base
+ || $response['object'] instanceof \Stripe\StripeObject
+ ) {
+ $log['response'] = $response['object']->__toString();
+ } else {
+ $log['response'] = $response['object'];
+ }
+
+ if ($this->config->isDebugOn()) {
+ $this->logger->warning(var_export($log, true));
+ }
+
$this->customLogger->debug($log);
}
diff --git a/Gateway/Request/PaymentDataBuilder.php b/Gateway/Request/PaymentDataBuilder.php
index 994df8b..dc2563c 100755
--- a/Gateway/Request/PaymentDataBuilder.php
+++ b/Gateway/Request/PaymentDataBuilder.php
@@ -22,6 +22,8 @@
use Magento\Customer\Model\Session;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Stripe\Customer;
+use Psr\Log\LoggerInterface;
+use Magento\Framework\App\ObjectManager;
class PaymentDataBuilder implements BuilderInterface
{
@@ -47,6 +49,8 @@ class PaymentDataBuilder implements BuilderInterface
/** @var CustomerRepositoryInterface */
protected $customerRepository;
+ /** @var LoggerInterface */
+ protected $logger;
/**
* PaymentDataBuilder constructor.
@@ -54,17 +58,20 @@ class PaymentDataBuilder implements BuilderInterface
* @param SubjectReader $subjectReader
* @param Session $customerSession
* @param CustomerRepositoryInterface $customerRepository
+ * @param LoggerInterface $logger
*/
public function __construct(
Config $config,
SubjectReader $subjectReader,
Session $customerSession,
- CustomerRepositoryInterface $customerRepository
+ CustomerRepositoryInterface $customerRepository,
+ LoggerInterface $logger = null
) {
$this->config = $config;
$this->subjectReader = $subjectReader;
$this->customerSession = $customerSession;
$this->customerRepository = $customerRepository;
+ $this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
}
/**
@@ -126,6 +133,7 @@ protected function createNewStripeCustomer($email) {
'description' => 'Customer for ' . $email,
]);
}catch (\Exception $e) {
+ $this->logger->critical($e);
throw new \Magento\Framework\Validator\Exception(__($e->getMessage()));
}
diff --git a/README.md b/README.md
index d8f5f6d..6983460 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@ In your Magento 2 root directory run
| ------- | --------------- |
| 1.x.x | 2.2.x |
| 1.x.x | 2.1.x |
-| 0.0.3 | 2.0.x |
+| None | 2.0.x |
## Configuration
The configuration can be found in the Magento 2 admin panel under
diff --git a/Test/Unit/Gateway/Http/Client/TransactionSaleTest.php b/Test/Unit/Gateway/Http/Client/TransactionSaleTest.php
index 060d246..3456c58 100755
--- a/Test/Unit/Gateway/Http/Client/TransactionSaleTest.php
+++ b/Test/Unit/Gateway/Http/Client/TransactionSaleTest.php
@@ -92,7 +92,6 @@ public function testPlaceRequestSuccess() {
$actualResult = $this->model->placeRequest($this->getTransferObjectMock());
- $this->assertTrue(is_object($actualResult['object']));
$this->assertEquals(['object' => $response], $actualResult);
}
@@ -110,9 +109,6 @@ private function getTransferObjectMock() {
}
private function getResponseObject() {
- $object = new \stdClass();
- $object->success = true;
-
- return $object;
+ return ['success' => true];
}
}
\ No newline at end of file
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 6c66eef..ef19aad 100755
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -67,6 +67,10 @@
Magento\Config\Model\Config\Source\Yesno
+
+
+ Magento\Config\Model\Config\Source\Yesno
+
Magento\Payment\Model\Config\Source\Allspecificcountries
diff --git a/etc/config.xml b/etc/config.xml
index 30f3032..83c1899 100755
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -41,6 +41,7 @@
1
processing
+ 0
StripeCreditCardVaultFacade
diff --git a/etc/di.xml b/etc/di.xml
index f3fe76f..16354c5 100755
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -309,5 +309,18 @@
-
+
+
+
+ - 1
+ - 1
+ - 1
+ - 1
+
+
+ - 1
+ - 1
+
+
+
\ No newline at end of file
diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js
deleted file mode 100755
index 91df5c9..0000000
--- a/view/frontend/requirejs-config.js
+++ /dev/null
@@ -1,7 +0,0 @@
-var config = {
- map: {
- '*': {
- stripejs: 'https://js.stripe.com/v3/'
- }
- }
-};
\ No newline at end of file
diff --git a/view/frontend/web/js/view/payment/method-renderer/pmclain_stripe.js b/view/frontend/web/js/view/payment/method-renderer/pmclain_stripe.js
index 2f9dee8..0004fc6 100755
--- a/view/frontend/web/js/view/payment/method-renderer/pmclain_stripe.js
+++ b/view/frontend/web/js/view/payment/method-renderer/pmclain_stripe.js
@@ -9,7 +9,7 @@ define(
'Magento_Checkout/js/action/redirect-on-success',
'Magento_Vault/js/view/payment/vault-enabler',
'Magento_Checkout/js/model/quote',
- 'stripejs'
+ 'https://js.stripe.com/v3/'
],
function (
$,