diff --git a/src/Connector.php b/src/Connector.php index 9c85501..8d0a44d 100644 --- a/src/Connector.php +++ b/src/Connector.php @@ -88,6 +88,17 @@ public function charges(): Repositories\ChargeRepository ); } + /** + * @return Repositories\CustomerRepository + */ + public function customers(): Repositories\CustomerRepository + { + return new Repositories\CustomerRepository( + app(Client::class), + $this->accountId() + ); + } + /** * @return Repositories\EventRepository */ @@ -99,6 +110,28 @@ public function events(): Repositories\EventRepository ); } + /** + * @return Repositories\InvoiceRepository + */ + public function invoices(): Repositories\InvoiceRepository + { + return new Repositories\InvoiceRepository( + app(Client::class), + $this->accountId() + ); + } + + /** + * @return Repositories\InvoiceItemRepository + */ + public function invoiceItems(): Repositories\InvoiceItemRepository + { + return new Repositories\InvoiceItemRepository( + app(Client::class), + $this->accountId() + ); + } + /** * Create a payment intents client for the provided account. * diff --git a/src/Repositories/CustomerRepository.php b/src/Repositories/CustomerRepository.php new file mode 100644 index 0000000..101a659 --- /dev/null +++ b/src/Repositories/CustomerRepository.php @@ -0,0 +1,57 @@ +params($params); + + return $this->send( + 'create', + $this->params ?: null, + $this->options ?: null + ); + } + + /** + * @inheritDoc + */ + protected function fqn(): string + { + return Customer::class; + } +} diff --git a/src/Repositories/InvoiceItemRepository.php b/src/Repositories/InvoiceItemRepository.php new file mode 100644 index 0000000..7a054a2 --- /dev/null +++ b/src/Repositories/InvoiceItemRepository.php @@ -0,0 +1,67 @@ +params($params)->params( + compact('customer') + ); + + return $this->send( + 'create', + $this->params ?: null, + $this->options ?: null + ); + } + + /** + * @inheritDoc + */ + protected function fqn(): string + { + return InvoiceItem::class; + } +} diff --git a/src/Repositories/InvoiceRepository.php b/src/Repositories/InvoiceRepository.php new file mode 100644 index 0000000..08d65db --- /dev/null +++ b/src/Repositories/InvoiceRepository.php @@ -0,0 +1,80 @@ +params($params)->params( + compact('customer') + ); + + return $this->send( + 'create', + $this->params ?: null, + $this->options ?: null + ); + } + + /** + * Send an invoice to the customer. + * + * @param iterable|array $params + * additional optional parameters. + * @return Invoice + */ + public function sendInvoice(iterable $params = []): Invoice + { + $this->params($params); + + return $this->send( + 'sendInvoice', + $this->params ?: null, + $this->options ?: null + ); + } + + /** + * @inheritDoc + */ + protected function fqn(): string + { + return Invoice::class; + } +}