Skip to content

Commit 7725d6b

Browse files
Merge pull request #35 from Adyen/develop
Release 1.0.0-rc1
2 parents 0d8ea87 + 157eefe commit 7725d6b

File tree

82 files changed

+5776
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+5776
-1
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @Adyen/plugin-developers
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: Bug report
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Magento version**
24+
[e.g. 2.4.7]
25+
26+
**Plugin version**
27+
[e.g. 1.0.0]
28+
29+
**Screenshots**
30+
If applicable, add screenshots to help explain your problem.
31+
32+
**Desktop (please complete the following information):**
33+
- OS: [e.g. iOS]
34+
- Browser [e.g. chrome, safari]
35+
- Version [e.g. 22]
36+
37+
**Smartphone (please complete the following information):**
38+
- Device: [e.g. iPhone6]
39+
- OS: [e.g. iOS8.1]
40+
- Browser [e.g. stock browser, safari]
41+
- Version [e.g. 22]
42+
43+
**Additional context**
44+
Add any other context about the problem here.

.github/release.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
changelog:
2+
categories:
3+
- title: Breaking Changes 🛠
4+
labels:
5+
- Breaking change
6+
- title: New Features 💎
7+
labels:
8+
- Feature
9+
- title: Fixes ⛑️
10+
labels:
11+
- Fix
12+
- title: Other Changes 🖇️
13+
labels:
14+
- "*"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Adyen\Hyva\Api\Data;
6+
7+
use Magewirephp\Magewire\Component;
8+
9+
interface MagewireComponentInterface
10+
{
11+
const NAME = 'name';
12+
const MAGEWIRE = 'magewire';
13+
const STORED_CARD = 'storedCard';
14+
const TEMPLATE = 'template';
15+
16+
/**
17+
* @param string $name
18+
* @return $this
19+
*/
20+
public function setName(string $name): self;
21+
22+
/**
23+
* @param Component $component
24+
* @return $this
25+
*/
26+
public function setMagewire(Component $component): self;
27+
28+
/**
29+
* @param StoredCreditCardInterface $storedCard
30+
* @return $this
31+
*/
32+
public function setStoredCard(StoredCreditCardInterface $storedCard): self;
33+
34+
/**
35+
* @param string $template
36+
* @return $this
37+
*/
38+
public function setTemplate(string $template): self;
39+
40+
/**
41+
* @return string|null
42+
*/
43+
public function getName(): ?string;
44+
45+
/**
46+
* @return Component|null
47+
*/
48+
public function getMagewire(): ?Component;
49+
50+
/**
51+
* @return StoredCreditCardInterface|null
52+
*/
53+
public function getStoredCard(): ?StoredCreditCardInterface;
54+
55+
/**
56+
* @return string|null
57+
*/
58+
public function getTemplate(): ?string;
59+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Adyen\Hyva\Api\Data;
6+
7+
interface StoredCreditCardInterface
8+
{
9+
const GATEWAY_TOKEN = 'gateway_token';
10+
const PUBLIC_HASH = 'public_hash';
11+
const TYPE = 'type';
12+
const MASKED_CC = 'masked_cc';
13+
const EXPIRY_MONTH = 'expiry_month';
14+
const EXPIRY_YEAR = 'expiry_year';
15+
const LAYOUT_ID = 'layout_id';
16+
17+
/**
18+
* @param string $token
19+
* @return $this
20+
*/
21+
public function setGatewayToken(string $token): self;
22+
23+
/**
24+
* @param string $publicHash
25+
* @return $this
26+
*/
27+
public function setPublicHash(string $publicHash): self;
28+
29+
/**
30+
* @param string $type
31+
* @return $this
32+
*/
33+
public function setType(string $type): self;
34+
35+
/**
36+
* @param string $maskedCc
37+
* @return $this
38+
*/
39+
public function setMaskedCc(string $maskedCc): self;
40+
41+
/**
42+
* @param string $expiryMonth
43+
* @return $this
44+
*/
45+
public function setExpiryMonth(string $expiryMonth): self;
46+
47+
/**
48+
* @param string $expiryYear
49+
* @return $this
50+
*/
51+
public function setExpiryYear(string $expiryYear): self;
52+
53+
/**
54+
* @param string $layoutId
55+
* @return $this
56+
*/
57+
public function setLayoutId(string $layoutId): self;
58+
59+
/**
60+
* @return string|null
61+
*/
62+
public function getGatewayToken(): ?string;
63+
64+
/**
65+
* @return string|null
66+
*/
67+
public function getPublicHash(): ?string;
68+
69+
/**
70+
* @return string|null
71+
*/
72+
public function getType(): ?string;
73+
74+
/**
75+
* @return string|null
76+
*/
77+
public function getMaskedCc(): ?string;
78+
79+
/**
80+
* @return string|null
81+
*/
82+
public function getExpiryMonth(): ?string;
83+
84+
/**
85+
* @return string|null
86+
*/
87+
public function getExpiryYear(): ?string;
88+
89+
/**
90+
* @return string
91+
*/
92+
public function getLayoutId(): string;
93+
94+
/**
95+
* @return string
96+
*/
97+
public function getPublicLabel(): string;
98+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Adyen\Hyva\Api;
6+
7+
interface ProcessingMetadataInterface
8+
{
9+
const METHOD_ADYEN_PREFIX = 'adyen_';
10+
const POST_KEY_STATE_DATA = 'stateData';
11+
const PUBLIC_HASH = 'public_hash';
12+
const POST_KEY_PUBLIC_HASH = 'publicHash';
13+
const POST_KEY_ORDER_ID = 'order_id';
14+
const POST_KEY_NUMBER_OF_INSTALLMENTS = 'installments';
15+
const POST_KEY_CC_TYPE = 'ccType';
16+
const VAULT_LAYOUT_PREFIX = 'adyen_vault_';
17+
const BLOCK_PROPERTY_MAGEWIRE = 'magewire';
18+
const BLOCK_PROPERTY_STORED_CARD = 'storedCard';
19+
}

Block/PaymentMethod.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Adyen\Hyva\Block;
6+
7+
use Adyen\Hyva\Model\Configuration;
8+
use Adyen\Hyva\Model\MethodList;
9+
use Exception;
10+
use Magento\Checkout\Model\Session;
11+
use Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
12+
use Magento\Framework\View\Element\Template;
13+
use Magento\Quote\Model\Quote;
14+
15+
class PaymentMethod extends Template
16+
{
17+
public function __construct(
18+
Template\Context $context,
19+
private Configuration $configuration,
20+
private MethodList $methodList,
21+
private Session $checkoutSession,
22+
private JsonSerializer $jsonSerializer,
23+
array $data = []
24+
) {
25+
parent::__construct($context, $data);
26+
}
27+
28+
/**
29+
* @return Configuration
30+
*/
31+
public function getConfiguration(): Configuration
32+
{
33+
return $this->configuration;
34+
}
35+
36+
public function getAvailableMethods(): array
37+
{
38+
return $this->methodList->collectAvailableMethods();
39+
}
40+
41+
public function getQuoteShippingAddress(): string
42+
{
43+
try {
44+
$quote = $this->getQuote();
45+
46+
if ($quote && $quote->getShippingAddress()) {
47+
return $this->jsonSerializer->serialize($quote->getShippingAddress()->getData());
48+
}
49+
} catch (\InvalidArgumentException $exception) {
50+
return $this->defaultResponse();
51+
}
52+
53+
return $this->defaultResponse();
54+
}
55+
56+
public function getQuoteBillingAddress(): string
57+
{
58+
try {
59+
$quote = $this->getQuote();
60+
61+
if ($quote && $quote->getBillingAddress()) {
62+
return $this->jsonSerializer->serialize($quote->getBillingAddress()->getData());
63+
}
64+
} catch (\InvalidArgumentException $exception) {
65+
return $this->defaultResponse();
66+
}
67+
68+
69+
return $this->defaultResponse();
70+
}
71+
72+
/**
73+
* @return Quote|null
74+
*/
75+
private function getQuote(): ?Quote
76+
{
77+
try {
78+
/** @var Quote $quote */
79+
$quote = $this->checkoutSession->getQuote();
80+
81+
return $quote;
82+
} catch (Exception $exception) {
83+
return null;
84+
}
85+
}
86+
87+
/**
88+
* @return string
89+
*/
90+
private function defaultResponse(): string
91+
{
92+
return $this->jsonSerializer->serialize([]);
93+
}
94+
}

0 commit comments

Comments
 (0)