1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Subscription Payment Data |
4
|
|
|
* |
5
|
|
|
* @author Pronamic <[email protected]> |
6
|
|
|
* @copyright 2005-2018 Pronamic |
7
|
|
|
* @license GPL-3.0-or-later |
8
|
|
|
* @package Pronamic\WordPress\Pay\Payments |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Subscriptions; |
12
|
|
|
|
13
|
|
|
use Pronamic\WordPress\Pay\Payments\Item; |
14
|
|
|
use Pronamic\WordPress\Pay\Payments\Items; |
15
|
|
|
use Pronamic\WordPress\Pay\Payments\PaymentData; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* WordPress subscription payment data |
19
|
|
|
* |
20
|
|
|
* @author Reüel van der Steege |
21
|
|
|
* @version 1.0 |
22
|
|
|
*/ |
23
|
|
|
class SubscriptionPaymentData extends PaymentData { |
24
|
|
|
/** |
25
|
|
|
* The subscription. |
26
|
|
|
* |
27
|
|
|
* @var Subscription $subscription |
28
|
|
|
*/ |
29
|
|
|
public $subscription; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Constructs and initializes WordPress subscription payment data. |
33
|
|
|
* |
34
|
|
|
* @param Subscription $subscription The subscription. |
35
|
|
|
*/ |
36
|
|
|
public function __construct( Subscription $subscription ) { |
37
|
|
|
parent::__construct(); |
38
|
|
|
|
39
|
|
|
$this->subscription = $subscription; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Get config id. |
44
|
|
|
* |
45
|
|
|
* @return int |
46
|
|
|
*/ |
47
|
|
|
public function get_config_id() { |
48
|
|
|
return $this->subscription->config_id; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get user id. |
53
|
|
|
* |
54
|
|
|
* @return int |
55
|
|
|
*/ |
56
|
|
|
public function get_user_id() { |
57
|
|
|
return $this->subscription->post->post_author; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Get source. |
62
|
|
|
* |
63
|
|
|
* @return mixed |
64
|
|
|
*/ |
65
|
|
|
public function get_source() { |
66
|
|
|
return $this->subscription->source; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get source id. |
71
|
|
|
* |
72
|
|
|
* @return mixed |
73
|
|
|
*/ |
74
|
|
|
public function get_source_id() { |
75
|
|
|
return $this->subscription->source_id; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Get description. |
80
|
|
|
* |
81
|
|
|
* @return mixed |
82
|
|
|
*/ |
83
|
|
|
public function get_description() { |
84
|
|
|
return $this->subscription->description; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Get order id. |
89
|
|
|
* |
90
|
|
|
* @return mixed |
91
|
|
|
*/ |
92
|
|
|
public function get_order_id() { |
93
|
|
|
$this->subscription->order_id; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Get items. |
98
|
|
|
* |
99
|
|
|
* @return mixed |
100
|
|
|
*/ |
101
|
|
|
public function get_items() { |
102
|
|
|
// Items. |
103
|
|
|
$items = new Items(); |
104
|
|
|
|
105
|
|
|
// Item. |
106
|
|
|
$item = new Item(); |
107
|
|
|
$item->setNumber( $this->get_order_id() ); |
|
|
|
|
108
|
|
|
$item->setDescription( $this->get_description() ); |
109
|
|
|
$item->setPrice( $this->subscription->get_amount()->get_amount() ); |
110
|
|
|
$item->setQuantity( 1 ); |
111
|
|
|
|
112
|
|
|
$items->addItem( $item ); |
113
|
|
|
|
114
|
|
|
return $items; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Get currency alphabetic code. |
119
|
|
|
* |
120
|
|
|
* @return mixed |
121
|
|
|
*/ |
122
|
|
|
public function get_currency_alphabetic_code() { |
123
|
|
|
return $this->subscription->get_amount()->get_currency()->get_alphabetic_code(); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Get customer name. |
128
|
|
|
* |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
|
|
public function get_customer_name() { |
132
|
|
|
return $this->subscription->customer_name; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Get email. |
137
|
|
|
* |
138
|
|
|
* @return string |
139
|
|
|
*/ |
140
|
|
|
public function get_email() { |
141
|
|
|
return $this->subscription->email; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.