Skip to content

Commit 32b637a

Browse files
Merge pull request #135 from vindi/versionamento/2.1.0
Versão 2.1.0
2 parents cf06de7 + e90f745 commit 32b637a

File tree

128 files changed

+9561
-839
lines changed

Some content is hidden

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

128 files changed

+9561
-839
lines changed

Api/Data/PaymentLinkInterface.php

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* DISCLAIMER
7+
*
8+
* Do not edit or add to this file if you wish to upgrade this extension to newer
9+
* version in the future.
10+
*
11+
* @category Vindi
12+
* @package Vindi_Payment
13+
*/
14+
15+
namespace Vindi\Payment\Api\Data;
16+
17+
use Magento\Framework\Api\ExtensibleDataInterface;
18+
19+
interface PaymentLinkInterface extends ExtensibleDataInterface
20+
{
21+
const ENTITY_ID = 'entity_id';
22+
const LINK = 'link';
23+
const ORDER_ID = 'order_id';
24+
const VINDI_PAYMENT_METHOD = 'vindi_payment_method';
25+
const CUSTOMER_ID = 'customer_id';
26+
const CREATED_AT = 'created_at';
27+
const STATUS = 'status';
28+
29+
/**
30+
* @return int
31+
*/
32+
public function getEntityId();
33+
34+
/**
35+
* @param int $id
36+
*/
37+
public function setEntityId(int $entityId);
38+
39+
/**
40+
* @return string
41+
*/
42+
public function getLink();
43+
44+
/**
45+
* @param string $link
46+
*/
47+
public function setLink(string $link);
48+
49+
/**
50+
* @return int
51+
*/
52+
public function getOrderId();
53+
54+
/**
55+
* @param int $orderId
56+
*/
57+
public function setOrderId(int $orderId);
58+
59+
/**
60+
* @return string
61+
*/
62+
public function getCreatedAt();
63+
64+
/**
65+
* @param string $createdAt
66+
*/
67+
public function setCreatedAt(string $createdAt);
68+
69+
/**
70+
* @return string
71+
*/
72+
public function getVindiPaymentMethod();
73+
74+
/**
75+
* @param string $vindiPaymentMethod
76+
*/
77+
public function setVindiPaymentMethod(string $vindiPaymentMethod);
78+
79+
/**
80+
* @return int
81+
*/
82+
public function getCustomerId();
83+
84+
/**
85+
* @param int $customerId
86+
*/
87+
public function setCustomerId(int $customerId);
88+
89+
/**
90+
* @return string
91+
*/
92+
public function getStatus();
93+
94+
/**
95+
* @param string $status
96+
*/
97+
public function setStatus(string $status);
98+
}
+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Vindi\Payment\Api\Data;
5+
6+
/**
7+
* Interface VindiSubscriptionItemInterface
8+
* @package Vindi\Payment\Api\Data
9+
*/
10+
interface VindiSubscriptionItemInterface
11+
{
12+
const ENTITY_ID = 'entity_id';
13+
const SUBSCRIPTION_ID = 'subscription_id';
14+
const PRODUCT_ITEM_ID = 'product_item_id';
15+
const PRODUCT_NAME = 'product_name';
16+
const PRODUCT_CODE = 'product_code';
17+
const QUANTITY = 'quantity';
18+
const PRICE = 'price';
19+
const PRICING_SCHEMA_ID = 'pricing_schema_id';
20+
const PRICING_SCHEMA_TYPE = 'pricing_schema_type';
21+
const PRICING_SCHEMA_FORMAT = 'pricing_schema_short_format';
22+
const STATUS = 'status';
23+
const USES = 'uses';
24+
const CYCLES = 'cycles';
25+
const DISCOUNT_TYPE = 'discount_type';
26+
const DISCOUNT_PERCENTAGE = 'discount_percentage';
27+
const MAGENTO_PRODUCT_ID = 'magento_product_id';
28+
const MAGENTO_PRODUCT_SKU = 'magento_product_sku';
29+
const CREATED_AT = 'created_at';
30+
const UPDATED_AT = 'updated_at';
31+
32+
public function getId();
33+
34+
public function setId($entityId);
35+
36+
public function getSubscriptionId();
37+
38+
public function setSubscriptionId($subscriptionId);
39+
40+
public function getProductItemId();
41+
42+
public function setProductItemId($productItemId);
43+
44+
public function getProductName();
45+
46+
public function setProductName($productName);
47+
48+
public function getProductCode();
49+
50+
public function setProductCode($productCode);
51+
52+
public function getQuantity();
53+
54+
public function setQuantity($quantity);
55+
56+
public function getPrice();
57+
58+
public function setPrice($price);
59+
60+
public function getPricingSchemaId();
61+
62+
public function setPricingSchemaId($pricingSchemaId);
63+
64+
public function getPricingSchemaType();
65+
66+
public function setPricingSchemaType($pricingSchemaType);
67+
68+
public function getPricingSchemaFormat();
69+
70+
public function setPricingSchemaFormat($pricingSchemaFormat);
71+
72+
public function getStatus();
73+
74+
public function setStatus($status);
75+
76+
public function getUses();
77+
78+
public function setUses($uses);
79+
80+
public function getCycles();
81+
82+
public function setCycles($cycles);
83+
84+
public function getDiscountType();
85+
86+
public function setDiscountType($discountType);
87+
88+
public function getDiscountPercentage();
89+
90+
public function setDiscountPercentage($discountPercentage);
91+
92+
public function getMagentoProductId();
93+
94+
public function setMagentoProductId($magentoProductId);
95+
96+
public function getMagentoProductSku();
97+
98+
public function setMagentoProductSku($magentoProductSku);
99+
100+
public function getCreatedAt();
101+
102+
public function setCreatedAt($createdAt);
103+
104+
public function getUpdatedAt();
105+
106+
public function setUpdatedAt($updatedAt);
107+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Vindi\Payment\Api\Data;
5+
6+
use Magento\Framework\Api\SearchResultsInterface;
7+
8+
/**
9+
* Interface VindiSubscriptionItemSearchResultInterface
10+
* @package Vindi\Payment\Api\Data
11+
*/
12+
interface VindiSubscriptionItemSearchResultInterface extends SearchResultsInterface
13+
{
14+
public function getItems();
15+
16+
public function setItems(array $items);
17+
}
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* DISCLAIMER
7+
*
8+
* Do not edit or add to this file if you wish to upgrade this extension to newer
9+
* version in the future.
10+
*
11+
* @category Vindi
12+
* @package Vindi_Payment
13+
*/
14+
15+
namespace Vindi\Payment\Api;
16+
17+
interface PaymentLinkRepositoryInterface
18+
{
19+
/**
20+
* @param int $id
21+
* @return \Vindi\Payment\Api\Data\PaymentLinkInterface
22+
* @throws \Magento\Framework\Exception\NoSuchEntityException
23+
*/
24+
public function getById($id);
25+
26+
/**
27+
* @param \Vindi\Payment\Api\Data\PaymentLinkInterface $paymentLink
28+
* @return \Vindi\Payment\Api\Data\PaymentLinkInterface
29+
* @throws \Magento\Framework\Exception\CouldNotSaveException
30+
*/
31+
public function save(\Vindi\Payment\Api\Data\PaymentLinkInterface $paymentLink);
32+
33+
/**
34+
* @param \Vindi\Payment\Api\Data\PaymentLinkInterface $paymentLink
35+
* @return bool true on success
36+
* @throws \Magento\Framework\Exception\CouldNotDeleteException
37+
*/
38+
public function delete(\Vindi\Payment\Api\Data\PaymentLinkInterface $paymentLink);
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Vindi\Payment\Api;
5+
6+
use Vindi\Payment\Api\Data\VindiSubscriptionItemInterface;
7+
use Magento\Framework\Api\SearchCriteriaInterface;
8+
use Vindi\Payment\Api\Data\VindiSubscriptionItemSearchResultInterface;
9+
10+
/**
11+
* Interface VindiSubscriptionItemRepositoryInterface
12+
* @package Vindi\Payment\Api
13+
*/
14+
interface VindiSubscriptionItemRepositoryInterface
15+
{
16+
/**
17+
* Get subscription item by ID.
18+
*
19+
* @param int $entityId
20+
* @return VindiSubscriptionItemInterface
21+
*/
22+
public function getById(int $entityId): VindiSubscriptionItemInterface;
23+
24+
/**
25+
* Save subscription item.
26+
*
27+
* @param VindiSubscriptionItemInterface $vindiSubscriptionItem
28+
* @return void
29+
*/
30+
public function save(VindiSubscriptionItemInterface $vindiSubscriptionItem): void;
31+
32+
/**
33+
* Delete subscription item.
34+
*
35+
* @param VindiSubscriptionItemInterface $vindiSubscriptionItem
36+
* @return void
37+
*/
38+
public function delete(VindiSubscriptionItemInterface $vindiSubscriptionItem): void;
39+
40+
/**
41+
* Get list of subscription items.
42+
*
43+
* @param SearchCriteriaInterface $searchCriteria
44+
* @return VindiSubscriptionItemSearchResultInterface
45+
*/
46+
public function getList(SearchCriteriaInterface $searchCriteria): VindiSubscriptionItemSearchResultInterface;
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
namespace Vindi\Payment\Block\Adminhtml\Order\Create\Search\Renderer;
3+
4+
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
5+
use Magento\Framework\DataObject;
6+
use Vindi\Payment\Api\VindiPlanRepositoryInterface;
7+
use Magento\Catalog\Model\ProductRepository;
8+
use Magento\Framework\Exception\NoSuchEntityException;
9+
10+
class RecurrencePlan extends AbstractRenderer
11+
{
12+
/**
13+
* Vindi plan repository interface
14+
*
15+
* @var VindiPlanRepositoryInterface
16+
*/
17+
protected $vindiPlanRepository;
18+
19+
/**
20+
* Product repository
21+
*
22+
* @var ProductRepository
23+
*/
24+
protected $productRepository;
25+
26+
/**
27+
* Constructor
28+
*
29+
* @param VindiPlanRepositoryInterface $vindiPlanRepository
30+
* @param ProductRepository $productRepository
31+
*/
32+
public function __construct(
33+
VindiPlanRepositoryInterface $vindiPlanRepository,
34+
ProductRepository $productRepository
35+
) {
36+
$this->vindiPlanRepository = $vindiPlanRepository;
37+
$this->productRepository = $productRepository;
38+
}
39+
40+
/**
41+
* Render the select dropdown with recurrence plans
42+
*
43+
* @param DataObject $row
44+
* @return string
45+
*/
46+
public function render(DataObject $row)
47+
{
48+
try {
49+
$productId = $row->getData('entity_id');
50+
$product = $this->productRepository->getById($productId);
51+
52+
if ($product->getData('vindi_enable_recurrence') === '1') {
53+
$recurrenceDataJson = $product->getData('vindi_recurrence_data');
54+
55+
if (!empty($recurrenceDataJson)) {
56+
$recurrenceData = json_decode($recurrenceDataJson, true);
57+
58+
$recurrenceData = array_filter($recurrenceData, function($data) {
59+
return isset($data['price']) && is_numeric($data['price']) && $data['price'] > 0;
60+
});
61+
62+
// Generate the HTML for the select dropdown
63+
$html = '<select name="product[' . $productId . '][selected_plan_id]" class="input-select admin__control-select selected_plan_id">';
64+
$html .= '<option value="">' . __('-- Select --') . '</option>';
65+
foreach ($recurrenceData as $data) {
66+
$plan = $this->vindiPlanRepository->getById($data['plan']);
67+
$planName = $plan ? $plan->getName() : $data['plan'];
68+
69+
$selected = '';
70+
71+
$html .= '<option value="' . $data['plan'] . '"' . $selected . '>' . $planName . '</option>';
72+
}
73+
$html .= '</select>';
74+
75+
return $html;
76+
} else {
77+
return __('No recurrence plans available.');
78+
}
79+
} else {
80+
return __('Recurrence is not enabled for this product.');
81+
}
82+
} catch (NoSuchEntityException $e) {
83+
return __('Product not found.');
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)