Skip to content

Commit

Permalink
Merge pull request #35 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 1.0.0-rc1
  • Loading branch information
khushboo-singhvi authored May 22, 2024
2 parents 0d8ea87 + 157eefe commit 7725d6b
Show file tree
Hide file tree
Showing 82 changed files with 5,776 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Adyen/plugin-developers
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: Bug report
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Magento version**
[e.g. 2.4.7]

**Plugin version**
[e.g. 1.0.0]

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
14 changes: 14 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
changelog:
categories:
- title: Breaking Changes 🛠
labels:
- Breaking change
- title: New Features 💎
labels:
- Feature
- title: Fixes ⛑️
labels:
- Fix
- title: Other Changes 🖇️
labels:
- "*"
59 changes: 59 additions & 0 deletions Api/Data/MagewireComponentInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

declare(strict_types=1);

namespace Adyen\Hyva\Api\Data;

use Magewirephp\Magewire\Component;

interface MagewireComponentInterface
{
const NAME = 'name';
const MAGEWIRE = 'magewire';
const STORED_CARD = 'storedCard';
const TEMPLATE = 'template';

/**
* @param string $name
* @return $this
*/
public function setName(string $name): self;

/**
* @param Component $component
* @return $this
*/
public function setMagewire(Component $component): self;

/**
* @param StoredCreditCardInterface $storedCard
* @return $this
*/
public function setStoredCard(StoredCreditCardInterface $storedCard): self;

/**
* @param string $template
* @return $this
*/
public function setTemplate(string $template): self;

/**
* @return string|null
*/
public function getName(): ?string;

/**
* @return Component|null
*/
public function getMagewire(): ?Component;

/**
* @return StoredCreditCardInterface|null
*/
public function getStoredCard(): ?StoredCreditCardInterface;

/**
* @return string|null
*/
public function getTemplate(): ?string;
}
98 changes: 98 additions & 0 deletions Api/Data/StoredCreditCardInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

declare(strict_types=1);

namespace Adyen\Hyva\Api\Data;

interface StoredCreditCardInterface
{
const GATEWAY_TOKEN = 'gateway_token';
const PUBLIC_HASH = 'public_hash';
const TYPE = 'type';
const MASKED_CC = 'masked_cc';
const EXPIRY_MONTH = 'expiry_month';
const EXPIRY_YEAR = 'expiry_year';
const LAYOUT_ID = 'layout_id';

/**
* @param string $token
* @return $this
*/
public function setGatewayToken(string $token): self;

/**
* @param string $publicHash
* @return $this
*/
public function setPublicHash(string $publicHash): self;

/**
* @param string $type
* @return $this
*/
public function setType(string $type): self;

/**
* @param string $maskedCc
* @return $this
*/
public function setMaskedCc(string $maskedCc): self;

/**
* @param string $expiryMonth
* @return $this
*/
public function setExpiryMonth(string $expiryMonth): self;

/**
* @param string $expiryYear
* @return $this
*/
public function setExpiryYear(string $expiryYear): self;

/**
* @param string $layoutId
* @return $this
*/
public function setLayoutId(string $layoutId): self;

/**
* @return string|null
*/
public function getGatewayToken(): ?string;

/**
* @return string|null
*/
public function getPublicHash(): ?string;

/**
* @return string|null
*/
public function getType(): ?string;

/**
* @return string|null
*/
public function getMaskedCc(): ?string;

/**
* @return string|null
*/
public function getExpiryMonth(): ?string;

/**
* @return string|null
*/
public function getExpiryYear(): ?string;

/**
* @return string
*/
public function getLayoutId(): string;

/**
* @return string
*/
public function getPublicLabel(): string;
}
19 changes: 19 additions & 0 deletions Api/ProcessingMetadataInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Adyen\Hyva\Api;

interface ProcessingMetadataInterface
{
const METHOD_ADYEN_PREFIX = 'adyen_';
const POST_KEY_STATE_DATA = 'stateData';
const PUBLIC_HASH = 'public_hash';
const POST_KEY_PUBLIC_HASH = 'publicHash';
const POST_KEY_ORDER_ID = 'order_id';
const POST_KEY_NUMBER_OF_INSTALLMENTS = 'installments';
const POST_KEY_CC_TYPE = 'ccType';
const VAULT_LAYOUT_PREFIX = 'adyen_vault_';
const BLOCK_PROPERTY_MAGEWIRE = 'magewire';
const BLOCK_PROPERTY_STORED_CARD = 'storedCard';
}
94 changes: 94 additions & 0 deletions Block/PaymentMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

declare(strict_types=1);

namespace Adyen\Hyva\Block;

use Adyen\Hyva\Model\Configuration;
use Adyen\Hyva\Model\MethodList;
use Exception;
use Magento\Checkout\Model\Session;
use Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
use Magento\Framework\View\Element\Template;
use Magento\Quote\Model\Quote;

class PaymentMethod extends Template
{
public function __construct(
Template\Context $context,
private Configuration $configuration,
private MethodList $methodList,
private Session $checkoutSession,
private JsonSerializer $jsonSerializer,
array $data = []
) {
parent::__construct($context, $data);
}

/**
* @return Configuration
*/
public function getConfiguration(): Configuration
{
return $this->configuration;
}

public function getAvailableMethods(): array
{
return $this->methodList->collectAvailableMethods();
}

public function getQuoteShippingAddress(): string
{
try {
$quote = $this->getQuote();

if ($quote && $quote->getShippingAddress()) {
return $this->jsonSerializer->serialize($quote->getShippingAddress()->getData());
}
} catch (\InvalidArgumentException $exception) {
return $this->defaultResponse();
}

return $this->defaultResponse();
}

public function getQuoteBillingAddress(): string
{
try {
$quote = $this->getQuote();

if ($quote && $quote->getBillingAddress()) {
return $this->jsonSerializer->serialize($quote->getBillingAddress()->getData());
}
} catch (\InvalidArgumentException $exception) {
return $this->defaultResponse();
}


return $this->defaultResponse();
}

/**
* @return Quote|null
*/
private function getQuote(): ?Quote
{
try {
/** @var Quote $quote */
$quote = $this->checkoutSession->getQuote();

return $quote;
} catch (Exception $exception) {
return null;
}
}

/**
* @return string
*/
private function defaultResponse(): string
{
return $this->jsonSerializer->serialize([]);
}
}
Loading

0 comments on commit 7725d6b

Please sign in to comment.