Skip to content

Commit

Permalink
only unsetting payment_method parameter when called in adminhtml orders.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmajidian committed Apr 25, 2020
1 parent e9b9124 commit c719e77
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Gateway/Http/Client/AbstractTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Magento\Payment\Model\Method\Logger;
use Psr\Log\LoggerInterface;
use Stripe\StripeObject;
use Magento\Framework\App\State;

abstract class AbstractTransaction implements ClientInterface
{
Expand All @@ -39,7 +40,10 @@ abstract class AbstractTransaction implements ClientInterface
* @var StripeAdapterFactory
*/
protected $adapterFactory;

/**
* @var State
*/
protected $state;
/**
* AbstractTransaction constructor.
* @param LoggerInterface $logger
Expand All @@ -49,11 +53,13 @@ abstract class AbstractTransaction implements ClientInterface
public function __construct(
LoggerInterface $logger,
Logger $customLogger,
StripeAdapterFactory $adapterFactory
StripeAdapterFactory $adapterFactory,
State $state
) {
$this->logger = $logger;
$this->customLogger = $customLogger;
$this->adapterFactory = $adapterFactory;
$this->state = $state;
}

/**
Expand Down
17 changes: 15 additions & 2 deletions Gateway/Http/Client/TransactionSale.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,23 @@ protected function process(array $data)
$storeId = $data['store_id'] ? $data['store_id'] : null;
// sending store id and other additional keys are restricted by Stripe API
unset($data['store_id']);
unset($data['payment_method']);
unset($data['shipping']);

// only unset payment_method param in backend.
if ($this->getArea() === 'adminhtml') {
unset($data['payment_method']);
}
return $this->adapterFactory->create($storeId)
->sale($data);
}

/**
* Get the current Area
*
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
private function getArea()
{
return $this->state->getAreaCode();
}
}

0 comments on commit c719e77

Please sign in to comment.