-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from omise/ib-make-charge
Be able to make a charge with Internet Banking payment method
- Loading branch information
Showing
9 changed files
with
268 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
namespace Omise\Payment\Gateway\Http\Client; | ||
|
||
class OffsiteInternetbanking extends AbstractOmiseClient | ||
{ | ||
/** | ||
* @param array $body | ||
* | ||
* @return array | ||
*/ | ||
public function request(Array $body) | ||
{ | ||
return \OmiseCharge::create($body, $this->publicKey, $this->secretKey); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
namespace Omise\Payment\Gateway\Request; | ||
|
||
use Magento\Payment\Gateway\Helper\SubjectReader; | ||
use Magento\Payment\Gateway\Request\BuilderInterface; | ||
use Omise\Payment\Observer\OffsiteInternetbankingDataAssignObserver; | ||
|
||
class PaymentOffsiteBuilder implements BuilderInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
const OFFSITE = 'offsite'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
const RETURN_URI = 'return_uri'; | ||
|
||
/** | ||
* @param array $buildSubject | ||
* | ||
* @return array | ||
*/ | ||
public function build(array $buildSubject) | ||
{ | ||
$payment = SubjectReader::readPayment($buildSubject); | ||
$method = $payment->getPayment(); | ||
|
||
return [ | ||
self::OFFSITE => $method->getAdditionalInformation(OffsiteInternetbankingDataAssignObserver::OFFSITE), | ||
self::RETURN_URI => 'http://127.0.0.1' // TODO: Remove this dump-data | ||
]; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Gateway/Validator/Offsite/InternetbankingChargeCommandResponseValidator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
namespace Omise\Payment\Gateway\Validator\Offsite; | ||
|
||
use Magento\Payment\Gateway\Command\CommandException; | ||
use Magento\Payment\Gateway\Validator\AbstractValidator; | ||
|
||
class InternetbankingChargeCommandResponseValidator extends AbstractValidator | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $message; | ||
|
||
/** | ||
* Performs domain-related validation for business object | ||
* | ||
* @param array $validationSubject | ||
* | ||
* @return ResultInterface | ||
*/ | ||
public function validate(array $validationSubject) | ||
{ | ||
return $this->createResult(true, []); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
namespace Omise\Payment\Observer; | ||
|
||
use Magento\Framework\Event\Observer; | ||
use Magento\Payment\Observer\AbstractDataAssignObserver; | ||
use Magento\Quote\Api\Data\PaymentInterface; | ||
|
||
class OffsiteInternetbankingDataAssignObserver extends AbstractDataAssignObserver | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
const OFFSITE = 'offsite'; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $additionalInformationList = [ | ||
self::OFFSITE | ||
]; | ||
|
||
/** | ||
* @param \Magento\Framework\Event\Observer $observer | ||
*/ | ||
public function execute(Observer $observer) | ||
{ | ||
$dataObject = $this->readDataArgument($observer); | ||
|
||
$additionalData = $dataObject->getData(PaymentInterface::KEY_ADDITIONAL_DATA); | ||
|
||
if (! is_array($additionalData)) { | ||
return; | ||
} | ||
|
||
$paymentInfo = $this->readPaymentModelArgument($observer); | ||
|
||
$paymentInfo->setOffsite($additionalData[self::OFFSITE]); | ||
|
||
foreach ($this->additionalInformationList as $additionalInformationKey) { | ||
if (isset($additionalData[$additionalInformationKey])) { | ||
$paymentInfo->setAdditionalInformation( | ||
$additionalInformationKey, | ||
$additionalData[$additionalInformationKey] | ||
); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters