This repository has been archived by the owner on Jan 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #104 from heidelpay/develop
initial release
- Loading branch information
Showing
107 changed files
with
12,915 additions
and
4,663 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/.idea | ||
/.php_cs.cache | ||
/vendor | ||
/composer.lock | ||
/vendor |
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,86 @@ | ||
<?php | ||
|
||
namespace Heidelpay\MGW\Api; | ||
|
||
use Exception; | ||
use Heidelpay\MGW\Api\Data\Customer; | ||
use Heidelpay\MGW\Helper\Order as OrderHelper; | ||
use Magento\Checkout\Model\Session; | ||
use Magento\Quote\Model\Quote; | ||
|
||
/** | ||
* Checkout API Interface Implementation. | ||
* | ||
* Copyright (C) 2019 heidelpay GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @link https://docs.heidelpay.com/ | ||
* | ||
* @author Justin Nuß | ||
* | ||
* @package heidelpay/magento2-merchant-gateway | ||
*/ | ||
class Checkout implements CheckoutInterface | ||
{ | ||
/** | ||
* @var Session | ||
*/ | ||
protected $_checkoutSession; | ||
|
||
/** | ||
* @var OrderHelper | ||
*/ | ||
protected $_orderHelper; | ||
|
||
/** | ||
* Checkout constructor. | ||
* @param Session $checkoutSession | ||
* @param OrderHelper $orderHelper | ||
*/ | ||
public function __construct(Session $checkoutSession, OrderHelper $orderHelper) | ||
{ | ||
$this->_checkoutSession = $checkoutSession; | ||
$this->_orderHelper = $orderHelper; | ||
} | ||
|
||
/** | ||
* Returns the external customer for the current quote. | ||
* | ||
* @param string|null $guestEmail E-Mail address used for quote, in case customer is not logged in. | ||
* | ||
* @return Customer|null | ||
* | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
*/ | ||
public function getExternalCustomer(?string $guestEmail = null): ?Customer | ||
{ | ||
/** @var Quote $quote */ | ||
$quote = $this->_checkoutSession->getQuote(); | ||
|
||
$email = $guestEmail ?? $quote->getCustomerEmail(); | ||
|
||
if ($email === null) { | ||
return null; | ||
} | ||
|
||
try { | ||
$customerResource = $this->_orderHelper->createCustomerFromQuote($quote, $email); | ||
} catch (Exception $e) { | ||
$customerResource = null; | ||
} | ||
|
||
return $customerResource !== null ? Customer::fromResource($customerResource) : null; | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace Heidelpay\MGW\Api; | ||
|
||
use Heidelpay\MGW\Api\Data\Customer; | ||
|
||
/** | ||
* Checkout API Interface. | ||
* | ||
* Copyright (C) 2019 heidelpay GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @link https://docs.heidelpay.com/ | ||
* | ||
* @author Justin Nuß | ||
* | ||
* @package heidelpay/magento2-merchant-gateway | ||
*/ | ||
interface CheckoutInterface | ||
{ | ||
/** | ||
* Returns the external customer ID for the current quote. | ||
* | ||
* @param string|null $guestEmail Customer E-Mail address. | ||
* | ||
* @return Customer|null | ||
*/ | ||
public function getExternalCustomer(?string $guestEmail = null): ?Customer; | ||
} |
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,118 @@ | ||
<?php | ||
|
||
namespace Heidelpay\MGW\Api\Data; | ||
|
||
/** | ||
* Checkout API Address DTO. | ||
* | ||
* Copyright (C) 2019 heidelpay GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @link https://docs.heidelpay.com/ | ||
* | ||
* @author Justin Nuß | ||
* | ||
* @package heidelpay/magento2-merchant-gateway | ||
*/ | ||
class Address | ||
{ | ||
/** @var string $name */ | ||
protected $name; | ||
|
||
/** @var string $street */ | ||
protected $street; | ||
|
||
/** @var string $state */ | ||
protected $state; | ||
|
||
/** @var string $zip */ | ||
protected $zip; | ||
|
||
/** @var string city */ | ||
protected $city; | ||
|
||
/** @var string country */ | ||
protected $country; | ||
|
||
/** | ||
* CompanyInfo constructor. | ||
*/ | ||
private function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* @param \heidelpayPHP\Resources\EmbeddedResources\Address $addressResource | ||
* @return static | ||
*/ | ||
public static function fromResource(\heidelpayPHP\Resources\EmbeddedResources\Address $addressResource): self | ||
{ | ||
$address = new self(); | ||
$address->name = $addressResource->getName(); | ||
$address->street = $addressResource->getStreet(); | ||
$address->state = $addressResource->getState(); | ||
$address->zip = $addressResource->getZip(); | ||
$address->city = $addressResource->getCity(); | ||
$address->country = $addressResource->getCountry(); | ||
return $address; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getStreet(): string | ||
{ | ||
return $this->street; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getState(): ?string | ||
{ | ||
return $this->state; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getZip(): string | ||
{ | ||
return $this->zip; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCity(): string | ||
{ | ||
return $this->city; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCountry(): string | ||
{ | ||
return $this->country; | ||
} | ||
} |
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,94 @@ | ||
<?php | ||
|
||
namespace Heidelpay\MGW\Api\Data; | ||
|
||
/** | ||
* Checkout API CompanyInfo DTO. | ||
* | ||
* Copyright (C) 2019 heidelpay GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @link https://docs.heidelpay.com/ | ||
* | ||
* @author Justin Nuß | ||
* | ||
* @package heidelpay/magento2-merchant-gateway | ||
*/ | ||
class CompanyInfo | ||
{ | ||
/** @var string $registrationType */ | ||
protected $registrationType; | ||
|
||
/** @var string|null $commercialRegisterNumber */ | ||
protected $commercialRegisterNumber; | ||
|
||
/** @var string|null $function */ | ||
protected $function; | ||
|
||
/** @var string $commercialSector */ | ||
protected $commercialSector; | ||
|
||
/** | ||
* CompanyInfo constructor. | ||
*/ | ||
private function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* @param \heidelpayPHP\Resources\EmbeddedResources\CompanyInfo $companyInfoResource | ||
* @return static | ||
*/ | ||
public static function fromResource(\heidelpayPHP\Resources\EmbeddedResources\CompanyInfo $companyInfoResource): self | ||
{ | ||
$companyInfo = new self(); | ||
$companyInfo->registrationType = $companyInfoResource->getRegistrationType(); | ||
$companyInfo->commercialRegisterNumber = $companyInfoResource->getCommercialRegisterNumber(); | ||
$companyInfo->function = $companyInfoResource->getFunction(); | ||
$companyInfo->commercialSector = $companyInfoResource->getCommercialSector(); | ||
return $companyInfo; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getRegistrationType(): string | ||
{ | ||
return $this->registrationType; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getCommercialRegisterNumber(): ?string | ||
{ | ||
return $this->commercialRegisterNumber; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getFunction(): ?string | ||
{ | ||
return $this->function; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCommercialSector(): string | ||
{ | ||
return $this->commercialSector; | ||
} | ||
} |
Oops, something went wrong.