Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
Revert "Send customer data and order metadata to Stripe"
Dave Earley5fb494651fee
diff --git a/backend/app/DomainObjects/Generated/StripeCustomerDomainObjectAbstract.php b/backend/app/DomainObjects/Generated/StripeCustomerDomainObjectAbstract.phpdeleted file mode 100644index 66b6f685a..000000000--- a/backend/app/DomainObjects/Generated/StripeCustomerDomainObjectAbstract.php+++ /dev/null@@ -1,118 +0,0 @@-<?php--namespace HiEvents\DomainObjects\Generated;--/**- * THIS FILE IS AUTOGENERATED - DO NOT EDIT IT DIRECTLY.- * @package HiEvents\DomainObjects\Generated- */-abstract class StripeCustomerDomainObjectAbstract extends \HiEvents\DomainObjects\AbstractDomainObject-{- final public const SINGULAR_NAME = 'stripe_customer';- final public const PLURAL_NAME = 'stripe_customers';- final public const ID = 'id';- final public const NAME = 'name';- final public const EMAIL = 'email';- final public const STRIPE_CUSTOMER_ID = 'stripe_customer_id';- final public const CREATED_AT = 'created_at';- final public const UPDATED_AT = 'updated_at';- final public const DELETED_AT = 'deleted_at';-- protected int $id;- protected string $name;- protected string $email;- protected string $stripe_customer_id;- protected ?string $created_at = null;- protected ?string $updated_at = null;- protected ?string $deleted_at = null;-- public function toArray(): array- {- return [- 'id' => $this->id ?? null,- 'name' => $this->name ?? null,- 'email' => $this->email ?? null,- 'stripe_customer_id' => $this->stripe_customer_id ?? null,- 'created_at' => $this->created_at ?? null,- 'updated_at' => $this->updated_at ?? null,- 'deleted_at' => $this->deleted_at ?? null,- ];- }-- public function setId(int $id): self- {- $this->id = $id;- return $this;- }-- public function getId(): int- {- return $this->id;- }-- public function setName(string $name): self- {- $this->name = $name;- return $this;- }-- public function getName(): string- {- return $this->name;- }-- public function setEmail(string $email): self- {- $this->email = $email;- return $this;- }-- public function getEmail(): string- {- return $this->email;- }-- public function setStripeCustomerId(string $stripe_customer_id): self- {- $this->stripe_customer_id = $stripe_customer_id;- return $this;- }-- public function getStripeCustomerId(): string- {- return $this->stripe_customer_id;- }-- public function setCreatedAt(?string $created_at): self- {- $this->created_at = $created_at;- return $this;- }-- public function getCreatedAt(): ?string- {- return $this->created_at;- }-- public function setUpdatedAt(?string $updated_at): self- {- $this->updated_at = $updated_at;- return $this;- }-- public function getUpdatedAt(): ?string- {- return $this->updated_at;- }-- public function setDeletedAt(?string $deleted_at): self- {- $this->deleted_at = $deleted_at;- return $this;- }-- public function getDeletedAt(): ?string- {- return $this->deleted_at;- }-}diff --git a/backend/app/DomainObjects/StripeCustomerDomainObject.php b/backend/app/DomainObjects/StripeCustomerDomainObject.phpdeleted file mode 100644index dd4aa33fb..000000000--- a/backend/app/DomainObjects/StripeCustomerDomainObject.php+++ /dev/null@@ -1,7 +0,0 @@-<?php--namespace HiEvents\DomainObjects;--class StripeCustomerDomainObject extends Generated\StripeCustomerDomainObjectAbstract-{-}diff --git a/backend/app/Models/StripeCustomer.php b/backend/app/Models/StripeCustomer.phpdeleted file mode 100644index 870527ad5..000000000--- a/backend/app/Models/StripeCustomer.php+++ /dev/null@@ -1,16 +0,0 @@-<?php--namespace HiEvents\Models;--class StripeCustomer extends BaseModel-{- protected function getCastMap(): array- {- return [];- }-- protected function getFillableFields(): array- {- return [];- }-}diff --git a/backend/app/Providers/RepositoryServiceProvider.php b/backend/app/Providers/RepositoryServiceProvider.phpindex 4c9366529..d5317967f 100644--- a/backend/app/Providers/RepositoryServiceProvider.php+++ b/backend/app/Providers/RepositoryServiceProvider.php@@ -22,7 +22,7 @@ use HiEvents\Repository\Eloquent\PasswordResetTokenRepository;use HiEvents\Repository\Eloquent\PromoCodeRepository;use HiEvents\Repository\Eloquent\QuestionAnswerRepository;use HiEvents\Repository\Eloquent\QuestionRepository;-use HiEvents\Repository\Eloquent\StripeCustomerRepository;+use HiEvents\Repository\Eloquent\ReservationRepository;use HiEvents\Repository\Eloquent\StripePaymentsRepository;use HiEvents\Repository\Eloquent\TaxAndFeeRepository;use HiEvents\Repository\Eloquent\TicketPriceRepository;@@ -46,7 +46,7 @@ use HiEvents\Repository\Interfaces\PasswordResetTokenRepositoryInterface;use HiEvents\Repository\Interfaces\PromoCodeRepositoryInterface;use HiEvents\Repository\Interfaces\QuestionAnswerRepositoryInterface;use HiEvents\Repository\Interfaces\QuestionRepositoryInterface;-use HiEvents\Repository\Interfaces\StripeCustomerRepositoryInterface;+use HiEvents\Repository\Interfaces\ReservationRepositoryInterface;use HiEvents\Repository\Interfaces\StripePaymentsRepositoryInterface;use HiEvents\Repository\Interfaces\TaxAndFeeRepositoryInterface;use HiEvents\Repository\Interfaces\TicketPriceRepositoryInterface;@@ -83,7 +83,7 @@ class RepositoryServiceProvider extends ServiceProviderOrganizerRepositoryInterface::class => OrganizerRepository::class,AccountUserRepositoryInterface::class => AccountUserRepository::class,CapacityAssignmentRepositoryInterface::class => CapacityAssignmentRepository::class,- StripeCustomerRepositoryInterface::class => StripeCustomerRepository::class,+ ReservationRepositoryInterface::class => ReservationRepository::class,];public function register(): voiddiff --git a/backend/app/Repository/Eloquent/StripeCustomerRepository.php b/backend/app/Repository/Eloquent/StripeCustomerRepository.phpdeleted file mode 100644index 799203c4d..000000000--- a/backend/app/Repository/Eloquent/StripeCustomerRepository.php+++ /dev/null@@ -1,20 +0,0 @@-<?php--namespace HiEvents\Repository\Eloquent;--use HiEvents\DomainObjects\StripeCustomerDomainObject;-use HiEvents\Models\StripeCustomer;-use HiEvents\Repository\Interfaces\StripeCustomerRepositoryInterface;--class StripeCustomerRepository extends BaseRepository implements StripeCustomerRepositoryInterface-{- protected function getModel(): string- {- return StripeCustomer::class;- }-- public function getDomainObject(): string- {- return StripeCustomerDomainObject::class;- }-}diff --git a/backend/app/Repository/Interfaces/StripeCustomerRepositoryInterface.php b/backend/app/Repository/Interfaces/StripeCustomerRepositoryInterface.phpdeleted file mode 100644index 37484b3f5..000000000--- a/backend/app/Repository/Interfaces/StripeCustomerRepositoryInterface.php+++ /dev/null@@ -1,14 +0,0 @@-<?php--namespace HiEvents\Repository\Interfaces;--use HiEvents\DomainObjects\StripeCustomerDomainObject;-use HiEvents\Repository\Eloquent\BaseRepository;--/**- * @extends BaseRepository<StripeCustomerDomainObject>- */-interface StripeCustomerRepositoryInterface extends RepositoryInterface-{--}diff --git a/backend/app/Services/Domain/Payment/Stripe/DTOs/CreatePaymentIntentRequestDTO.php b/backend/app/Services/Domain/Payment/Stripe/DTOs/CreatePaymentIntentRequestDTO.phpindex fa27bf2ee..a63c1b0de 100644--- a/backend/app/Services/Domain/Payment/Stripe/DTOs/CreatePaymentIntentRequestDTO.php+++ b/backend/app/Services/Domain/Payment/Stripe/DTOs/CreatePaymentIntentRequestDTO.php@@ -4,7 +4,6 @@ namespace HiEvents\Services\Domain\Payment\Stripe\DTOs;use HiEvents\DataTransferObjects\BaseDTO;use HiEvents\DomainObjects\AccountDomainObject;-use HiEvents\DomainObjects\OrderDomainObject;class CreatePaymentIntentRequestDTO extends BaseDTO{@@ -12,7 +11,6 @@ class CreatePaymentIntentRequestDTO extends BaseDTOpublic readonly int $amount,public readonly string $currencyCode,public AccountDomainObject $account,- public OrderDomainObject $order,){}diff --git a/backend/app/Services/Domain/Payment/Stripe/StripePaymentIntentCreationService.php b/backend/app/Services/Domain/Payment/Stripe/StripePaymentIntentCreationService.phpindex b88c16043..5a9f18585 100644--- a/backend/app/Services/Domain/Payment/Stripe/StripePaymentIntentCreationService.php+++ b/backend/app/Services/Domain/Payment/Stripe/StripePaymentIntentCreationService.php@@ -2,26 +2,20 @@namespace HiEvents\Services\Domain\Payment\Stripe;-use HiEvents\DomainObjects\StripeCustomerDomainObject;use HiEvents\Exceptions\Stripe\CreatePaymentIntentFailedException;-use HiEvents\Repository\Interfaces\StripeCustomerRepositoryInterface;use HiEvents\Services\Domain\Payment\Stripe\DTOs\CreatePaymentIntentRequestDTO;use HiEvents\Services\Domain\Payment\Stripe\DTOs\CreatePaymentIntentResponseDTO;use Illuminate\Config\Repository;-use Illuminate\Database\DatabaseManager;use Psr\Log\LoggerInterface;use Stripe\Exception\ApiErrorException;use Stripe\StripeClient;-use Throwable;-class StripePaymentIntentCreationService+readonly class StripePaymentIntentCreationService{public function __construct(- readonly private StripeClient $stripeClient,- readonly private LoggerInterface $logger,- readonly private Repository $config,- readonly private StripeCustomerRepositoryInterface $stripeCustomerRepository,- readonly private DatabaseManager $databaseManager,+ private StripeClient $stripeClient,+ private LoggerInterface $logger,+ private Repository $config,){}@@ -53,26 +47,16 @@ class StripePaymentIntentCreationService/*** @throws CreatePaymentIntentFailedException- * @throws ApiErrorException|Throwable*/public function createPaymentIntent(CreatePaymentIntentRequestDTO $paymentIntentDTO): CreatePaymentIntentResponseDTO{try {- $this->databaseManager->beginTransaction();-$applicationFee = $this->getApplicationFee($paymentIntentDTO);$paymentIntent = $this->stripeClient->paymentIntents->create(['amount' => $paymentIntentDTO->amount,'currency' => $paymentIntentDTO->currencyCode,- 'customer' => $this->upsertStripeCustomer($paymentIntentDTO)->getStripeCustomerId(),'setup_future_usage' => 'on_session',- 'metadata' => [- 'order_id' => $paymentIntentDTO->order->getId(),- 'event_id' => $paymentIntentDTO->order->getEventId(),- 'order_short_id' => $paymentIntentDTO->order->getShortId(),- 'account_id' => $paymentIntentDTO->account->getId(),- ],'automatic_payment_methods' => ['enabled' => true,],@@ -84,8 +68,6 @@ class StripePaymentIntentCreationService'paymentIntentDTO' => $paymentIntentDTO->toArray(['account']),]);- $this->databaseManager->commit();-return new CreatePaymentIntentResponseDTO(paymentIntentId: $paymentIntent->id,clientSecret: $paymentIntent->client_secret,@@ -100,10 +82,6 @@ class StripePaymentIntentCreationServicethrow new CreatePaymentIntentFailedException(__('There was an error communicating with the payment provider. Please try again later.'));- } catch (Throwable $exception) {- $this->databaseManager->rollBack();-- throw $exception;}}@@ -141,42 +119,4 @@ class StripePaymentIntentCreationService'stripe_account' => $paymentIntentDTO->account->getStripeAccountId()];}-- /**- * @throws ApiErrorException- */- private function upsertStripeCustomer(CreatePaymentIntentRequestDTO $paymentIntentDTO): StripeCustomerDomainObject- {- $customer = $this->stripeCustomerRepository->findFirstWhere([- 'email' => $paymentIntentDTO->order->getEmail(),- ]);-- if ($customer === null) {- $stripeCustomer = $this->stripeClient->customers->create([- 'email' => $paymentIntentDTO->order->getEmail(),- 'name' => $paymentIntentDTO->order->getFullName(),- ]);-- return $this->stripeCustomerRepository->create([- 'name' => $stripeCustomer->name,- 'email' => $stripeCustomer->email,- 'stripe_customer_id' => $stripeCustomer->id,- ]);- }-- if ($customer->getName() === $paymentIntentDTO->order->getFullName()) {- return $customer;- }-- $stripeCustomer = $this->stripeClient->customers->update(- $customer->getStripeCustomerId(),- ['name' => $paymentIntentDTO->order->getFullName()]- );-- $this->stripeCustomerRepository->updateFromArray($customer->getId(), [- 'name' => $stripeCustomer->name,- ]);-- return $customer;- }}diff --git a/backend/app/Services/Handlers/Order/Payment/Stripe/CreatePaymentIntentHandler.php b/backend/app/Services/Handlers/Order/Payment/Stripe/CreatePaymentIntentHandler.phpindex 30423a3ef..08f6daaf4 100644--- a/backend/app/Services/Handlers/Order/Payment/Stripe/CreatePaymentIntentHandler.php+++ b/backend/app/Services/Handlers/Order/Payment/Stripe/CreatePaymentIntentHandler.php@@ -69,7 +69,6 @@ readonly class CreatePaymentIntentHandler'amount' => Money::of($order->getTotalGross(), $order->getCurrency())->getMinorAmount()->toInt(),'currencyCode' => $order->getCurrency(),'account' => $account,- 'order' => $order,]));$this->stripePaymentsRepository->create([diff --git a/backend/database/migrations/2024_08_07_005807_create_stripe_customers_table.php b/backend/database/migrations/2024_08_07_005807_create_stripe_customers_table.phpdeleted file mode 100644index 6b62ad4db..000000000--- a/backend/database/migrations/2024_08_07_005807_create_stripe_customers_table.php+++ /dev/null@@ -1,26 +0,0 @@-<?php--use Illuminate\Database\Migrations\Migration;-use Illuminate\Database\Schema\Blueprint;-use Illuminate\Support\Facades\Schema;--return new class extends Migration {- public function up(): void- {- Schema::create('stripe_customers', function (Blueprint $table) {- $table->id();-- $table->string('name');- $table->string('email');- $table->string('stripe_customer_id');-- $table->timestamps();- $table->softDeletes();- });- }-- public function down(): void- {- Schema::dropIfExists('stripe_customers');- }-};