-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding subscription functionality to payment plugin version 1.5.5 #1
base: master
Are you sure you want to change the base?
Changes from all commits
5d5fe24
c481baa
163d752
a95c15d
b50299e
6710604
ecb9e3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Kiener\MolliePayments\Controller\Api; | ||
|
||
use Shopware\Core\Framework\Routing\Annotation\RouteScope; | ||
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag; | ||
use Shopware\Core\Framework\Context; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Kiener\MolliePayments\Service\Subscription\CancelSubscriptionsService; | ||
|
||
/** | ||
* @RouteScope(scopes={"api"}) | ||
*/ | ||
class SubscriptionController extends AbstractController | ||
{ | ||
/** | ||
* @var CancelSubscriptionsService | ||
*/ | ||
private CancelSubscriptionsService $cancelSubscriptionsService; | ||
|
||
/** | ||
* Creates a new instance of the onboarding controller. | ||
* | ||
* @param CancelSubscriptionsService $cancelSubscriptionsService | ||
*/ | ||
public function __construct(CancelSubscriptionsService $cancelSubscriptionsService) | ||
{ | ||
$this->cancelSubscriptionsService = $cancelSubscriptionsService; | ||
} | ||
|
||
/** | ||
* @RouteScope(scopes={"api"}) | ||
* @Route("/api/_action/mollie/subscription/cancel", | ||
* defaults={"auth_enabled"=true}, name="api.action.mollie.subscription.cancel", methods={"POST"}) | ||
* | ||
* @param RequestDataBag $data | ||
* @param Context $context | ||
* @return JsonResponse | ||
*/ | ||
public function cancel(RequestDataBag $data, Context $context): JsonResponse | ||
{ | ||
return $this->cancelSubscriptionsService->cancelSubscriptions( | ||
$data->get('id'), | ||
$data->get('customerId'), | ||
$data->get('salesChannelId') | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Kiener\MolliePayments\Core\Content\SubscriptionToProduct; | ||
|
||
use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection; | ||
|
||
/** | ||
* @method void add(SubscriptionToProductEntity $entity) | ||
* @method void set(string $key, SubscriptionToProductEntity $entity) | ||
* @method SubscriptionToProductEntity[] getIterator() | ||
* @method SubscriptionToProductEntity[] getElements() | ||
* @method SubscriptionToProductEntity|null get(string $key) | ||
* @method SubscriptionToProductEntity|null first() | ||
* @method SubscriptionToProductEntity|null last() | ||
*/ | ||
class SubscriptionToProductCollection extends EntityCollection | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
protected function getExpectedClass(): string | ||
{ | ||
return SubscriptionToProductEntity::class; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Kiener\MolliePayments\Core\Content\SubscriptionToProduct; | ||
|
||
use Shopware\Core\Content\Product\ProductDefinition; | ||
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\CreatedAtField; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\CustomFields; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\DateTimeField; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ApiAware; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\FloatField; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\UpdatedAtField; | ||
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection; | ||
use Shopware\Core\System\SalesChannel\SalesChannelDefinition; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Field\JsonField; | ||
|
||
class SubscriptionToProductDefinition extends EntityDefinition | ||
{ | ||
public const ENTITY_NAME = 'mollie_subscription_to_product'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getEntityName(): string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you create any definition don't add a direct entity name in the getEntityName function. Please create Const ENTITY_NAME and use that constant as entity name EX. public const ENTITY_NAME = 'mollie_subscription_to_product'; public function getEntityName(): string |
||
{ | ||
return self::ENTITY_NAME; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getEntityClass(): string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
return SubscriptionToProductEntity::class; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCollectionClass(): string | ||
{ | ||
return SubscriptionToProductCollection::class; | ||
} | ||
|
||
/** | ||
* @return FieldCollection | ||
*/ | ||
protected function defineFields(): FieldCollection | ||
{ | ||
return new FieldCollection([ | ||
(new IdField('id', 'id'))->addFlags(new Required(), new PrimaryKey()), | ||
|
||
(new StringField('mollie_customer_id', 'mollieCustomerId')), | ||
(new StringField('subscription_id', 'subscriptionId')), | ||
(new FkField('product_id', 'productId', ProductDefinition::class))->addFlags(new ApiAware()), | ||
(new FkField('sales_channel_id', 'salesChannelId', SalesChannelDefinition::class)) | ||
->addFlags(new ApiAware()), | ||
new DateTimeField('next_payment_date', 'nextPaymentDate'), | ||
new StringField('status', 'status'), | ||
new StringField('description', 'description'), | ||
new StringField('currency', 'currency'), | ||
new FloatField('amount', 'amount'), | ||
|
||
new CreatedAtField(), | ||
new UpdatedAtField() | ||
]); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Kiener\MolliePayments\Core\Content\SubscriptionToProduct; | ||
|
||
use Shopware\Core\Framework\DataAbstractionLayer\Entity; | ||
use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait; | ||
|
||
class SubscriptionToProductEntity extends Entity | ||
{ | ||
use EntityIdTrait; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $mollieCustomerId; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $subscriptionId; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $productId; | ||
|
||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $salesChannelId; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $status; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $description; | ||
|
||
/** | ||
* @var float | ||
*/ | ||
protected float $amount; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $currency; | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMollieCustomerId(): string | ||
{ | ||
return $this->mollieCustomerId; | ||
} | ||
|
||
/** | ||
* @param string $mollieCustomerId | ||
*/ | ||
public function setMollieCustomerId(string $mollieCustomerId): void | ||
{ | ||
$this->mollieCustomerId = $mollieCustomerId; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSubscriptionId(): string | ||
{ | ||
return $this->subscriptionId; | ||
} | ||
|
||
/** | ||
* @param string $subscriptionId | ||
*/ | ||
public function setSubscriptionId(string $subscriptionId): void | ||
{ | ||
$this->subscriptionId = $subscriptionId; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getProductId(): string | ||
{ | ||
return $this->productId; | ||
} | ||
|
||
/** | ||
* @param string $productId | ||
*/ | ||
public function setProductId(string $productId): void | ||
{ | ||
$this->productId = $productId; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSalesChannelId(): string | ||
{ | ||
return $this->salesChannelId; | ||
} | ||
|
||
/** | ||
* @param string $salesChannelId | ||
*/ | ||
public function setSalesChannelId(string $salesChannelId): void | ||
{ | ||
$this->salesChannelId = $salesChannelId; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getStatus(): string | ||
{ | ||
return $this->status; | ||
} | ||
|
||
/** | ||
* @param string $status | ||
*/ | ||
public function setStatus(string $status): void | ||
{ | ||
$this->status = $status; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getDescription(): string | ||
{ | ||
return $this->description; | ||
} | ||
|
||
/** | ||
* @param string $description | ||
*/ | ||
public function setDescription(string $description): void | ||
{ | ||
$this->description = $description; | ||
} | ||
|
||
/** | ||
* @return float | ||
*/ | ||
public function getAmount(): float | ||
{ | ||
return $this->amount; | ||
} | ||
|
||
/** | ||
* @param float $amount | ||
*/ | ||
public function setAmount(float $amount): void | ||
{ | ||
$this->amount = $amount; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCurrency(): string | ||
{ | ||
return $this->currency; | ||
} | ||
|
||
/** | ||
* @param string $currency | ||
*/ | ||
public function setCurrency(string $currency): void | ||
{ | ||
$this->currency = $currency; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write Route scope always before class name Ex.