PluginProbe
MultiSafepay plugin for WooCommerce / trunk
MultiSafepay plugin for WooCommerce vtrunk
6.11.1 6.12.0 6.13.0 6.2.0 6.2.1 6.3.0 6.3.1 6.4.0 6.4.1 6.4.2 6.4.3 6.5.0 6.5.1 6.6.0 6.6.1 6.6.2 6.7.0 6.7.1 6.7.2 6.7.3 6.8.0 6.8.1 6.8.2 6.8.3 6.9.0 All 84 releases
multisafepay / src / Services / Qr / QrCustomerService.php

QrCustomerService.php in MultiSafepay plugin for WooCommerce trunk, at src/Services/Qr/QrCustomerService.php

51 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace MultiSafepay\WooCommerce\Services\Qr;
4
5 use MultiSafepay\Api\Transactions\OrderRequest\Arguments\CustomerDetails;
6 use MultiSafepay\WooCommerce\Services\CustomerService;
7 use MultiSafepay\WooCommerce\Utils\QrOrder;
8
9 /**
10 * Class QrCustomerService
11 *
12 * Handles customer data processing for QR-based transactions.
13 *
14 * @package MultiSafepay\WooCommerce\Services\Qr
15 */
16 class QrCustomerService extends CustomerService {
17
18 /**
19 * Create customer details from the current cart and user data.
20 *
21 * @param array $customer
22 * @param string $type
23 * @return CustomerDetails
24 */
25 public function create_customer_details_from_cart(
26 array $customer,
27 string $type = 'billing'
28 ): CustomerDetails {
29
30 $customer_address = $this->create_address(
31 $customer[ $type ]['address_1'],
32 $customer[ $type ]['address_2'],
33 $customer[ $type ]['country'],
34 $customer[ $type ]['state'] ?? '',
35 $customer[ $type ]['city'] ?? '',
36 $customer[ $type ]['postcode']
37 );
38
39 return $this->create_customer(
40 $customer_address,
41 $customer[ $type ]['email'] ?? $customer['billing']['email'],
42 $customer[ $type ]['phone'] ?? $customer['billing']['phone'],
43 $customer[ $type ]['first_name'] ?? $customer['billing']['first_name'],
44 $customer[ $type ]['last_name'] ?? $customer['billing']['last_name'],
45 ( new QrOrder() )->get_customer_ip_address() ?? '',
46 ( new QrOrder() )->get_user_agent() ?? '',
47 $customer[ $type ]['company'] ?? $customer['billing']['company'],
48 );
49 }
50 }
51