99use HiEvents \DomainObjects \AccountConfigurationDomainObject ;
1010use HiEvents \DomainObjects \AccountStripePlatformDomainObject ;
1111use HiEvents \DomainObjects \AccountVatSettingDomainObject ;
12+ use HiEvents \DomainObjects \EventDomainObject ;
1213use HiEvents \DomainObjects \Generated \StripePaymentDomainObjectAbstract ;
1314use HiEvents \DomainObjects \OrderItemDomainObject ;
1415use HiEvents \DomainObjects \Status \OrderStatus ;
2728use HiEvents \Services \Infrastructure \Stripe \StripeClientFactory ;
2829use HiEvents \Services \Infrastructure \Stripe \StripeConfigurationService ;
2930use HiEvents \Values \MoneyValue ;
31+ use Illuminate \Support \Str ;
3032use Stripe \Exception \ApiErrorException ;
3133use Throwable ;
3234
@@ -60,6 +62,7 @@ public function handle(string $orderShortId): CreatePaymentIntentResponseDTO
6062 $ order = $ this ->orderRepository
6163 ->loadRelation (new Relationship (OrderItemDomainObject::class))
6264 ->loadRelation (new Relationship (StripePaymentDomainObject::class, name: 'stripe_payment ' ))
65+ ->loadRelation (new Relationship (EventDomainObject::class, name: 'event ' ))
6366 ->findByShortId ($ orderShortId );
6467
6568 if (!$ order || !$ this ->sessionIdentifierService ->verifySession ($ order ->getSessionId ())) {
@@ -110,6 +113,12 @@ public function handle(string $orderShortId): CreatePaymentIntentResponseDTO
110113 );
111114 }
112115
116+ $ description = __ (':item_count item(s) for event: :event_name (Order :order_short_id) ' , [
117+ 'event_name ' => Str::limit ($ order ->getEvent ()?->getTitle() ?? __ ('Event ' ), 75 ),
118+ 'order_short_id ' => $ orderShortId ,
119+ 'item_count ' => $ order ->getOrderItems ()->sum (fn (OrderItemDomainObject $ item ) => $ item ->getQuantity ()),
120+ ]);
121+
113122 $ paymentIntent = $ this ->stripePaymentService ->createPaymentIntentWithClient (
114123 $ stripeClient ,
115124 CreatePaymentIntentRequestDTO::fromArray ([
@@ -119,6 +128,7 @@ public function handle(string $orderShortId): CreatePaymentIntentResponseDTO
119128 'order ' => $ order ,
120129 'stripeAccountId ' => $ stripeAccountId ,
121130 'vatSettings ' => $ account ->getAccountVatSetting (),
131+ 'description ' => Str::limit ($ description , 997 ),
122132 ])
123133 );
124134
0 commit comments