From c0483d727fb1e5b1027af0d7f47e353a28784765 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 7 Sep 2024 17:27:00 +1000 Subject: [PATCH] Symfony Serializer --- app/PaymentDrivers/CBAPowerBoard/Customer.php | 4 +- .../CBAPowerBoard/Models/Customer.php | 84 +++++++++++++++++ .../CBAPowerBoard/Models/Parse.php | 70 ++++++++++++++ .../CBAPowerBoard/Models/PaymentSources.php | 92 +++++++++++++++++++ 4 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 app/PaymentDrivers/CBAPowerBoard/Models/Customer.php create mode 100644 app/PaymentDrivers/CBAPowerBoard/Models/Parse.php create mode 100644 app/PaymentDrivers/CBAPowerBoard/Models/PaymentSources.php diff --git a/app/PaymentDrivers/CBAPowerBoard/Customer.php b/app/PaymentDrivers/CBAPowerBoard/Customer.php index 953825c8ebe0..480fdb5f05e0 100644 --- a/app/PaymentDrivers/CBAPowerBoard/Customer.php +++ b/app/PaymentDrivers/CBAPowerBoard/Customer.php @@ -13,6 +13,7 @@ namespace App\PaymentDrivers\CBAPowerBoard; use App\Models\ClientGatewayToken; +use App\PaymentDrivers\CBAPowerBoard\Models\Customer as ModelsCustomer; use App\PaymentDrivers\CBAPowerBoardPaymentDriver; class Customer @@ -31,7 +32,7 @@ class Customer ->first(); if($token && $customer = $this->getCustomer($token->gateway_customer_reference)){ - return $customer->resource->data; + return (new \App\PaymentDrivers\CBAPowerBoard\Models\Parse())->decode(ModelsCustomer::class, $customer->resource->data); } if($customer = $this->findCustomer()) @@ -113,6 +114,7 @@ class Customer // 'address_postcode' => $this->powerboard->client->postal_code ?? '', $payload = [ + 'company_name' => $this->powerboard->client->present()->name(), 'first_name' => $this->powerboard->client->present()->first_name(), 'last_name' => $this->powerboard->client->present()->first_name(), 'email' => $this->powerboard->client->present()->email(), diff --git a/app/PaymentDrivers/CBAPowerBoard/Models/Customer.php b/app/PaymentDrivers/CBAPowerBoard/Models/Customer.php new file mode 100644 index 000000000000..b04600c658a6 --- /dev/null +++ b/app/PaymentDrivers/CBAPowerBoard/Models/Customer.php @@ -0,0 +1,84 @@ +_id = $_id; + $this->_source_ip_address = $_source_ip_address; + $this->first_name = $first_name; + $this->last_name = $last_name; + $this->email = $email; + $this->reference = $reference; + $this->default_source = $default_source; + $this->status = $status; + $this->archived = $archived; + $this->created_at = $created_at; + $this->updated_at = $updated_at; + $this->_check_expire_date = $_check_expire_date; + $this->payment_sources = $payment_sources; + $this->payment_destinations = $payment_destinations; + $this->company_id = $company_id; + } +} \ No newline at end of file diff --git a/app/PaymentDrivers/CBAPowerBoard/Models/Parse.php b/app/PaymentDrivers/CBAPowerBoard/Models/Parse.php new file mode 100644 index 000000000000..b6693c387224 --- /dev/null +++ b/app/PaymentDrivers/CBAPowerBoard/Models/Parse.php @@ -0,0 +1,70 @@ +deserialize(json_encode($document), $object_type, 'json', [\Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer::SKIP_NULL_VALUES => true]); + + return $data; + + } +} \ No newline at end of file diff --git a/app/PaymentDrivers/CBAPowerBoard/Models/PaymentSources.php b/app/PaymentDrivers/CBAPowerBoard/Models/PaymentSources.php new file mode 100644 index 000000000000..8bd4c579218e --- /dev/null +++ b/app/PaymentDrivers/CBAPowerBoard/Models/PaymentSources.php @@ -0,0 +1,92 @@ +_id = $_id; + $this->type = $type; + $this->vault_token = $vault_token; + $this->card_name = $card_name; + $this->card_number_bin = $card_number_bin; + $this->card_number_last4 = $card_number_last4; + $this->card_scheme = $card_scheme; + $this->address_line1 = $address_line1; + $this->address_line2 = $address_line2; + $this->address_city = $address_city; + $this->address_country = $address_country; + $this->address_state = $address_state; + $this->expire_month = $expire_month; + $this->expire_year = $expire_year; + $this->status = $status; + $this->created_at = $created_at; + $this->updated_at = $updated_at; + $this->vault_type = $vault_type; + } +}