From 823b3ec06ee18d7deb28190d4394a745126d38f2 Mon Sep 17 00:00:00 2001 From: Lukas Rosenfeldt Date: Wed, 31 Jul 2024 14:51:46 +0200 Subject: [PATCH] chore: remove obsolete example code --- .../src/Examples/CheckoutApiExample.php | 101 ------------- .../src/Examples/CommerceCaseApiExample.php | 135 ------------------ ...derManagementCheckoutActionsApiExample.php | 76 ---------- .../Examples/PaymentExecutionApiExample.php | 84 ----------- .../Examples/PaymentInformationApiExample.php | 70 --------- 5 files changed, 466 deletions(-) delete mode 100644 examples/demo-app/src/Examples/CheckoutApiExample.php delete mode 100644 examples/demo-app/src/Examples/CommerceCaseApiExample.php delete mode 100644 examples/demo-app/src/Examples/OrderManagementCheckoutActionsApiExample.php delete mode 100644 examples/demo-app/src/Examples/PaymentExecutionApiExample.php delete mode 100644 examples/demo-app/src/Examples/PaymentInformationApiExample.php diff --git a/examples/demo-app/src/Examples/CheckoutApiExample.php b/examples/demo-app/src/Examples/CheckoutApiExample.php deleted file mode 100644 index efa8040..0000000 --- a/examples/demo-app/src/Examples/CheckoutApiExample.php +++ /dev/null @@ -1,101 +0,0 @@ -merchantId = getenv('MERCHANT_ID'); - $this->commerceCaseId = getenv('COMMERCE_CASE_ID'); - $this->checkoutId = getenv('CHECKOUT_ID'); - - if (empty($this->merchantId)) { - throw new \RuntimeException('required environment variable MERCHANT_ID is not set'); - } - - $this->client = new CheckoutApiClient($config); - } - - protected function getCommerceCaseId(): string - { - if (empty($this->commerceCaseId)) { - throw new \RuntimeException('required environment variable COMMERCE_CASE_ID is not set'); - } - return $this->commerceCaseId; - } - - protected function getCheckoutId(): string - { - if (empty($this->checkoutId)) { - throw new \RuntimeException('required environment variable CHECKOUT_ID is not set'); - } - return $this->checkoutId; - } - - public function runPostOne(): void - { - /** @var CreateCheckoutRequest */ - $request = new CreateCheckoutRequest(); - /** @var AmountOfMoney */ - $amount = new AmountOfMoney(36000, 'USD'); - $request->setAmountOfMoney($amount); - - $response = $this->client->createCheckout($this->merchantId, $this->getCommerceCaseId(), $request); - $this->createdCheckoutId = $response->getCheckoutId(); - var_dump($response); - } - - public function runFilterAll(): void - { - /** @var GetCheckoutsQuery */ - $query = (new GetCheckoutsQuery()) - ->setSize(10) - ->setIncludeCheckoutStatus([StatusCheckout::OPEN, StatusCheckout::PENDING_COMPLETION]); - $response = $this->client->getCheckouts($this->merchantId, $query); - var_dump($response); - } - - public function runGetOne(): void - { - $response = $this->client->getCheckout($this->merchantId, $this->getCommerceCaseId(), $this->getCheckoutId()); - var_dump($response); - } - - public function runUpdateOne(): void - { - /** @var PatchCheckoutRequest */ - $request = new PatchCheckoutRequest(); - /** @var AmountOfMoney */ - $amount = new AmountOfMoney(37000, 'USD'); - $request->setAmountOfMoney($amount); - - $this->client->updateCheckout($this->merchantId, $this->getCommerceCaseId(), $this->getCheckoutId(), $request); - $response = $this->client->getCheckout($this->merchantId, $this->getCommerceCaseId(), $this->getCheckoutId()); - var_dump($response); - } - - public function runDeleteOne(): void - { - if (empty($this->createdCheckoutId)) { - throw new \RuntimeException('No checkout created yet, make sure to call runPostOne() first'); - } - $this->client->deleteCheckout($this->merchantId, $this->getCommerceCaseId(), $this->createdCheckoutId); - } -} diff --git a/examples/demo-app/src/Examples/CommerceCaseApiExample.php b/examples/demo-app/src/Examples/CommerceCaseApiExample.php deleted file mode 100644 index 9fb87a2..0000000 --- a/examples/demo-app/src/Examples/CommerceCaseApiExample.php +++ /dev/null @@ -1,135 +0,0 @@ -config = $config; - - $this->merchantId = getenv('MERCHANT_ID'); - $this->commerceCaseId = getenv('COMMERCE_CASE_ID'); - - if (empty($this->merchantId)) { - throw new \RuntimeException('required environment variable MERCHANT_ID is not set'); - } - - $this->client = new CommerceCaseApiClient($this->config); - } - - protected function getCommerceCaseId(): string - { - if (empty($this->commerceCaseId)) { - throw new \RuntimeException('required environment variable COMMERCE_CASE_ID is not set'); - } - return $this->commerceCaseId; - } - - public function runPostOne(): void - { - /** @var CreateCommerceCaseRequest */ - $request = new CreateCommerceCaseRequest(); - $customer = (new Customer()) - ->setLocale('de') - ->setBillingAddress(new Address( - city: 'Kerken', - countryCode: 'DE', - street: 'Hochstr.', - houseNumber: '6', - )); - $request->setCustomer($customer); - - $response = $this->client->createCommerceCase($this->merchantId, $request); - var_dump($response); - } - - public function runGetAll(): void - { - $response = $this->client->getCommerceCases($this->merchantId); - var_dump($response); - } - - public function runGetOne(): void - { - $response = $this->client->getCommerceCase($this->merchantId, $this->getCommerceCaseId()); - var_dump($response); - } - - public function runUpdateOne(): void - { - $customer = (new Customer()); - $personalInformation = (new PersonalInformation()) - ->setDateOfBirth('1980-12-12') - ->setName(new PersonalName(firstName: 'Rich', surname: 'Harris')); - $customer->setPersonalInformation($personalInformation); - - $this->client->updateCommerceCase($this->merchantId, $this->commerceCaseId, new Customer()); - - $response = $this->client->getCommerceCase($this->merchantId, $this->getCommerceCaseId()); - var_dump($response); - } - - public function runAndComplete(): void - { - $createCheckoutRequest = new CreateCheckoutRequest( - amountOfMoney: new AmountOfMoney(1600, 'EUR'), - orderRequest: new OrderRequest( - orderReferences: new References('ref'), - orderType: OrderType::FULL, - paymentMethodSpecificInput: new PaymentMethodSpecificInput( - financingPaymentMethodSpecificInput: new FinancingPaymentMethodSpecificInput( - paymentProductId: 3392, - requiresApproval: false, - paymentProduct3392SpecificInput: new PaymentProduct3392SpecificInput( - new BankAccountInformation( - iban: 'DE05500105178431848295', - accountHolder: 'Robert Jordan', - ), - ), - ) - ), - ), - shoppingCart: new ShoppingCartInput( - items: [new CartItemInput(invoiceData: new CartItemInvoiceData('shiny thing'))] - ), - autoExecuteOrder: true - ); - $request = new CreateCommerceCaseRequest(checkout: $createCheckoutRequest); - - try { - $response = $this->client->createCommerceCase($this->merchantId, $request); - var_dump($response); - } catch (ApiErrorResponseException $e) { - var_dump($e->getErrors()); - } - } -} diff --git a/examples/demo-app/src/Examples/OrderManagementCheckoutActionsApiExample.php b/examples/demo-app/src/Examples/OrderManagementCheckoutActionsApiExample.php deleted file mode 100644 index b75936b..0000000 --- a/examples/demo-app/src/Examples/OrderManagementCheckoutActionsApiExample.php +++ /dev/null @@ -1,76 +0,0 @@ -merchantId = getenv('MERCHANT_ID'); - $this->commerceCaseId = getenv('COMMERCE_CASE_ID'); - $this->checkoutId = getenv('CHECKOUT_ID'); - - if (empty($this->merchantId)) { - throw new \RuntimeException('required environment variable MERCHANT_ID is not set'); - } - - $this->client = new OrderManagementCheckoutActionsApiClient($config); - } - - protected function getCommerceCaseId(): string - { - if (empty($this->commerceCaseId)) { - throw new \RuntimeException('required environment variable COMMERCE_CASE_ID is not set'); - } - return $this->commerceCaseId; - } - - protected function getCheckoutId(): string - { - if (empty($this->checkoutId)) { - throw new \RuntimeException('required environment variable CHECKOUT_ID is not set'); - } - return $this->checkoutId; - } - - public function createOne(): string - { - $request = new OrderRequest( - orderReferences: new References( - merchantReference: 'merchantReference', - descriptor: 'Hi, there', - ), - /* items: [new OrderItem(id: 'ID12345', quantity: 10)], */ - /* orderType: OrderType::PARTIAL, */ - paymentMethodSpecificInput: new PaymentMethodSpecificInput( - financingPaymentMethodSpecificInput: new FinancingPaymentMethodSpecificInput( - paymentProductId: 3392, - requiresApproval: false, - paymentProduct3392SpecificInput: new PaymentProduct3392SpecificInput( - new BankAccountInformation( - iban: 'DE05500105178431848295', - accountHolder: 'Robert Jordan', - ), - ), - ), - ), - ); - $response = $this->client->createOrder($this->merchantId, $this->getCommerceCaseId(), $this->getCheckoutId(), $request); - var_dump($response); - } -} diff --git a/examples/demo-app/src/Examples/PaymentExecutionApiExample.php b/examples/demo-app/src/Examples/PaymentExecutionApiExample.php deleted file mode 100644 index 38f4cca..0000000 --- a/examples/demo-app/src/Examples/PaymentExecutionApiExample.php +++ /dev/null @@ -1,84 +0,0 @@ -merchantId = getenv('MERCHANT_ID'); - $this->commerceCaseId = getenv('COMMERCE_CASE_ID'); - $this->checkoutId = getenv('CHECKOUT_ID'); - - if (empty($this->merchantId)) { - throw new \RuntimeException('required environment variable MERCHANT_ID is not set'); - } - - $this->client = new PaymentExecutionApiClient($config); - } - - protected function getCommerceCaseId(): string - { - if (empty($this->commerceCaseId)) { - throw new \RuntimeException('required environment variable COMMERCE_CASE_ID is not set'); - } - return $this->commerceCaseId; - } - - protected function getCheckoutId(): string - { - if (empty($this->checkoutId)) { - throw new \RuntimeException('required environment variable CHECKOUT_ID is not set'); - } - return $this->checkoutId; - } - - protected function getPaymentId(): string - { - if (empty($this->paymentId)) { - throw new \RuntimeException('required environment variable PAYMENT_ID is not set'); - } - return $this->paymentId; - } - - public function createOne(): void - { - $request = new PaymentExecutionRequest( - paymentMethodSpecificInput: new PaymentMethodSpecificInput( - financingPaymentMethodSpecificInput: new FinancingPaymentMethodSpecificInput( - paymentProductId: 3392, - requiresApproval: false, - paymentProduct3392SpecificInput: new PaymentProduct3392SpecificInput( - new BankAccountInformation( - iban: 'DE05500105178431848295', - accountHolder: 'Robert Jordan', - ), - ), - ) - ), - paymentExecutionSpecificInput: new PaymentExecutionSpecificInput( - paymentReferences: new References('order-1234'), - amountOfMoney: new AmountOfMoney(36000, 'USD') - ), - ); - $this->client->createPayment($this->merchantId, $this->getCommerceCaseId(), $this->getCheckoutId(), $request); - } -} diff --git a/examples/demo-app/src/Examples/PaymentInformationApiExample.php b/examples/demo-app/src/Examples/PaymentInformationApiExample.php deleted file mode 100644 index fdf3399..0000000 --- a/examples/demo-app/src/Examples/PaymentInformationApiExample.php +++ /dev/null @@ -1,70 +0,0 @@ -merchantId = getenv('MERCHANT_ID'); - $this->commerceCaseId = getenv('COMMERCE_CASE_ID'); - $this->checkoutId = getenv('CHECKOUT_ID'); - - if (empty($this->merchantId)) { - throw new \RuntimeException('required environment variable MERCHANT_ID is not set'); - } - - $this->client = new PaymentInformationApiClient($config); - } - - protected function getCommerceCaseId(): string - { - if (empty($this->commerceCaseId)) { - throw new \RuntimeException('required environment variable COMMERCE_CASE_ID is not set'); - } - return $this->commerceCaseId; - } - - protected function getCheckoutId(): string - { - if (empty($this->checkoutId)) { - throw new \RuntimeException('required environment variable CHECKOUT_ID is not set'); - } - return $this->checkoutId; - } - - public function postOne(): void - { - $request = new PaymentInformationRequest( - amountOfMoney: new AmountOfMoney(36000, 'USD'), - type: PaymentType::SALE, - paymentChannel: PaymentChannel::ECOMMERCE, - paymentProductId: 1, - ); - $response = $this->client->createPaymentInformation($this->merchantId, $this->getCommerceCaseId(), $this->getCheckoutId(), $request); - var_dump($response); - } - - public function getOne(): void - { - if ($this->createdPaymentId === null) { - throw new \RuntimeException("No payment id available. Please run postOne() first."); - } - $response = $this->client-> getPaymentInformation($this->merchantId, $this->getCommerceCaseId(), $this->getCheckoutId(), $this->createdPaymentId); - var_dump($response); - } -}