PluginProbe ʕ •ᴥ•ʔ
WooCommerce Square / 5.4.3
WooCommerce Square v5.4.3
5.4.3 5.4.2 5.4.1 5.4.0 trunk 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.7.0 2.8.0 2.9.0 2.9.1 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.2.0 3.3.0 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.7.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 4.0.0 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 4.9.8 4.9.9 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.2.0 5.3.0 5.3.1 5.3.2 5.3.3
woocommerce-square / includes / Framework / PaymentGateway / PaymentTokens / Square_Credit_Card_Payment_Token.php
woocommerce-square / includes / Framework / PaymentGateway / PaymentTokens Last commit date
Payment_Gateway_Payment_Token.php 3 years ago Payment_Gateway_Payment_Tokens_Handler.php 1 year ago Square_Credit_Card_Payment_Token.php 3 years ago
Square_Credit_Card_Payment_Token.php
124 lines
1 <?php
2
3 namespace WooCommerce\Square\Framework\PaymentGateway\PaymentTokens;
4
5 /**
6 * Square Payment Gateway Token
7 *
8 * Represents a credit card payment token.
9 *
10 * @since 3.8.0
11 */
12 class Square_Credit_Card_Payment_Token extends \WC_Payment_Token_CC {
13 public function __construct( $token = '' ) {
14 $this->extra_data = array_merge(
15 $this->extra_data,
16 array(
17 'environment' => '',
18 'billing_hash' => '',
19 'nickname' => '',
20 )
21 );
22
23 parent::__construct( $token );
24 }
25
26 /**
27 * Setter for a card's encironment.
28 *
29 * @param string $env Environment of the Square account.
30 * @since 3.8.0
31 */
32 public function set_environment( $env = '' ) {
33 $this->set_prop( 'environment', $env );
34 }
35
36 /**
37 * Setter for billing hash.
38 *
39 * @param string $value The billing hash string.
40 * @since 3.8.0
41 */
42 public function set_billing_hash( $value = '' ) {
43 $this->set_prop( 'billing_hash', $value );
44 }
45
46 /**
47 * Setter for a card's nickname.
48 *
49 * @param string $value The billing hash string.
50 * @since 3.8.0
51 */
52 public function set_nickname( $value = '' ) {
53 $this->set_prop( 'nickname', $value );
54 }
55
56 /**
57 * Getter for a card's environment.
58 *
59 * @since 3.8.0
60 * @return string
61 */
62 public function get_environment( $context = 'view' ) {
63 return $this->get_prop( 'environment', $context );
64 }
65
66 /**
67 * Getter for billing hash.
68 *
69 * @since 3.8.0
70 * @return string
71 */
72 public function get_billing_hash( $context = 'view' ) {
73 return $this->get_prop( 'billing_hash', $context );
74 }
75
76 /**
77 * Get expiry date.
78 *
79 * @since 3.8.0
80 * @return string
81 */
82 public function get_exp_date() {
83 $expiry_month = $this->get_expiry_month();
84 $expiry_year = $this->get_expiry_year();
85
86 $expiry_date = $expiry_month . '/' . substr( $expiry_year, -2 );
87
88 return $expiry_date;
89 }
90
91 /**
92 * Getter for a card's nickname.
93 *
94 * @param string $value The billing hash string.
95 * @since 3.8.0
96 */
97 public function get_nickname( $context = 'view' ) {
98 $this->get_prop( 'nickname', $context );
99 }
100
101 /**
102 * Retrieves array of Square Payment Tokens.
103 *
104 * @param WC_Payment_Token_CC[] $tokens Array of tokens
105 * @since 3.8.0
106 *
107 * @return Square_Credit_Card_Payment_Token[];
108 */
109 public static function get_square_customer_tokens( $tokens = array() ) {
110 $square_customer_tokens = array();
111
112 /** @var \WC_Payment_Token_CC $token */
113 foreach ( $tokens as $token_id => $token ) {
114 if ( \WooCommerce\Square\Plugin::GATEWAY_ID !== $token->get_gateway_id() ) {
115 continue;
116 }
117
118 $square_customer_tokens[ $token_id ] = new Square_Credit_Card_Payment_Token( $token );
119 }
120
121 return $square_customer_tokens;
122 }
123 }
124