@@ -13,233 +13,233 @@ |
||
| 13 | 13 | |
| 14 | 14 | return array( |
| 15 | 15 | |
| 16 | - 'id' => array( |
|
| 17 | - 'description' => __( 'Unique identifier for the item.', 'invoicing' ), |
|
| 18 | - 'type' => 'integer', |
|
| 19 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 20 | - 'readonly' => true, |
|
| 21 | - ), |
|
| 22 | - |
|
| 23 | - 'parent_id' => array( |
|
| 24 | - 'description' => __( 'Parent item ID.', 'invoicing' ), |
|
| 25 | - 'type' => 'integer', |
|
| 26 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 27 | - 'default' => 0, |
|
| 28 | - ), |
|
| 29 | - |
|
| 30 | - 'status' => array( |
|
| 31 | - 'description' => __( 'A named status for the item.', 'invoicing' ), |
|
| 32 | - 'type' => 'string', |
|
| 33 | - 'enum' => array( 'draft', 'pending', 'publish' ), |
|
| 34 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 35 | - 'default' => 'draft', |
|
| 36 | - ), |
|
| 37 | - |
|
| 38 | - 'version' => array( |
|
| 39 | - 'description' => __( 'Plugin version when the item was created.', 'invoicing' ), |
|
| 40 | - 'type' => 'string', |
|
| 41 | - 'context' => array( 'view', 'edit' ), |
|
| 42 | - 'readonly' => true, |
|
| 43 | - ), |
|
| 44 | - |
|
| 45 | - 'date_created' => array( |
|
| 46 | - 'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ), |
|
| 47 | - 'type' => 'string', |
|
| 48 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 49 | - ), |
|
| 50 | - |
|
| 51 | - 'date_created_gmt' => array( |
|
| 52 | - 'description' => __( 'The GMT date the item was created.', 'invoicing' ), |
|
| 53 | - 'type' => 'string', |
|
| 54 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 55 | - 'readonly' => true, |
|
| 56 | - ), |
|
| 57 | - |
|
| 58 | - 'date_modified' => array( |
|
| 59 | - 'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ), |
|
| 60 | - 'type' => 'string', |
|
| 61 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 62 | - 'readonly' => true, |
|
| 63 | - ), |
|
| 64 | - |
|
| 65 | - 'date_modified_gmt' => array( |
|
| 66 | - 'description' => __( 'The GMT date the item was last modified.', 'invoicing' ), |
|
| 67 | - 'type' => 'string', |
|
| 68 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 69 | - 'readonly' => true, |
|
| 70 | - ), |
|
| 71 | - |
|
| 72 | - 'name' => array( |
|
| 73 | - 'description' => __( "The item's name.", 'invoicing' ), |
|
| 74 | - 'type' => 'string', |
|
| 75 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 76 | - 'required' => true, |
|
| 77 | - ), |
|
| 78 | - |
|
| 79 | - 'description' => array( |
|
| 80 | - 'description' => __( "The item's description.", 'invoicing' ), |
|
| 81 | - 'type' => 'string', |
|
| 82 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 83 | - ), |
|
| 84 | - |
|
| 85 | - 'owner' => array( |
|
| 86 | - 'description' => __( 'The owner of the item (user id).', 'invoicing' ), |
|
| 87 | - 'type' => 'integer', |
|
| 88 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 89 | - ), |
|
| 90 | - |
|
| 91 | - 'price' => array( |
|
| 92 | - 'description' => __( 'The price of the item.', 'invoicing' ), |
|
| 93 | - 'type' => 'number', |
|
| 94 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 95 | - 'required' => true, |
|
| 96 | - ), |
|
| 97 | - |
|
| 98 | - 'the_price' => array( |
|
| 99 | - 'description' => __( 'The formatted price of the item.', 'invoicing' ), |
|
| 100 | - 'type' => 'string', |
|
| 101 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 102 | - 'readonly' => true, |
|
| 103 | - ), |
|
| 104 | - |
|
| 105 | - 'type' => array( |
|
| 106 | - 'description' => __( 'The item type.', 'invoicing' ), |
|
| 107 | - 'type' => 'string', |
|
| 108 | - 'enum' => wpinv_item_types(), |
|
| 109 | - 'default' => 'custom', |
|
| 110 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 111 | - ), |
|
| 112 | - |
|
| 113 | - 'vat_rule' => array( |
|
| 114 | - 'description' => __( 'VAT rule applied to the item.', 'invoicing' ), |
|
| 115 | - 'type' => 'string', |
|
| 116 | - 'enum' => array_keys( getpaid_get_tax_rules() ), |
|
| 117 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 118 | - ), |
|
| 119 | - |
|
| 120 | - 'vat_class' => array( |
|
| 121 | - 'description' => __( 'VAT class for the item.', 'invoicing' ), |
|
| 122 | - 'type' => 'string', |
|
| 123 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 124 | - 'enum' => array_keys( getpaid_get_tax_classes() ), |
|
| 125 | - ), |
|
| 126 | - |
|
| 127 | - 'custom_id' => array( |
|
| 128 | - 'description' => __( 'Custom id for the item.', 'invoicing' ), |
|
| 129 | - 'type' => 'string', |
|
| 130 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 131 | - ), |
|
| 16 | + 'id' => array( |
|
| 17 | + 'description' => __( 'Unique identifier for the item.', 'invoicing' ), |
|
| 18 | + 'type' => 'integer', |
|
| 19 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 20 | + 'readonly' => true, |
|
| 21 | + ), |
|
| 22 | + |
|
| 23 | + 'parent_id' => array( |
|
| 24 | + 'description' => __( 'Parent item ID.', 'invoicing' ), |
|
| 25 | + 'type' => 'integer', |
|
| 26 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 27 | + 'default' => 0, |
|
| 28 | + ), |
|
| 29 | + |
|
| 30 | + 'status' => array( |
|
| 31 | + 'description' => __( 'A named status for the item.', 'invoicing' ), |
|
| 32 | + 'type' => 'string', |
|
| 33 | + 'enum' => array( 'draft', 'pending', 'publish' ), |
|
| 34 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 35 | + 'default' => 'draft', |
|
| 36 | + ), |
|
| 37 | + |
|
| 38 | + 'version' => array( |
|
| 39 | + 'description' => __( 'Plugin version when the item was created.', 'invoicing' ), |
|
| 40 | + 'type' => 'string', |
|
| 41 | + 'context' => array( 'view', 'edit' ), |
|
| 42 | + 'readonly' => true, |
|
| 43 | + ), |
|
| 44 | + |
|
| 45 | + 'date_created' => array( |
|
| 46 | + 'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ), |
|
| 47 | + 'type' => 'string', |
|
| 48 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 49 | + ), |
|
| 50 | + |
|
| 51 | + 'date_created_gmt' => array( |
|
| 52 | + 'description' => __( 'The GMT date the item was created.', 'invoicing' ), |
|
| 53 | + 'type' => 'string', |
|
| 54 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 55 | + 'readonly' => true, |
|
| 56 | + ), |
|
| 57 | + |
|
| 58 | + 'date_modified' => array( |
|
| 59 | + 'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ), |
|
| 60 | + 'type' => 'string', |
|
| 61 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 62 | + 'readonly' => true, |
|
| 63 | + ), |
|
| 64 | + |
|
| 65 | + 'date_modified_gmt' => array( |
|
| 66 | + 'description' => __( 'The GMT date the item was last modified.', 'invoicing' ), |
|
| 67 | + 'type' => 'string', |
|
| 68 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 69 | + 'readonly' => true, |
|
| 70 | + ), |
|
| 71 | + |
|
| 72 | + 'name' => array( |
|
| 73 | + 'description' => __( "The item's name.", 'invoicing' ), |
|
| 74 | + 'type' => 'string', |
|
| 75 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 76 | + 'required' => true, |
|
| 77 | + ), |
|
| 78 | + |
|
| 79 | + 'description' => array( |
|
| 80 | + 'description' => __( "The item's description.", 'invoicing' ), |
|
| 81 | + 'type' => 'string', |
|
| 82 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 83 | + ), |
|
| 84 | + |
|
| 85 | + 'owner' => array( |
|
| 86 | + 'description' => __( 'The owner of the item (user id).', 'invoicing' ), |
|
| 87 | + 'type' => 'integer', |
|
| 88 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 89 | + ), |
|
| 90 | + |
|
| 91 | + 'price' => array( |
|
| 92 | + 'description' => __( 'The price of the item.', 'invoicing' ), |
|
| 93 | + 'type' => 'number', |
|
| 94 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 95 | + 'required' => true, |
|
| 96 | + ), |
|
| 97 | + |
|
| 98 | + 'the_price' => array( |
|
| 99 | + 'description' => __( 'The formatted price of the item.', 'invoicing' ), |
|
| 100 | + 'type' => 'string', |
|
| 101 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 102 | + 'readonly' => true, |
|
| 103 | + ), |
|
| 104 | + |
|
| 105 | + 'type' => array( |
|
| 106 | + 'description' => __( 'The item type.', 'invoicing' ), |
|
| 107 | + 'type' => 'string', |
|
| 108 | + 'enum' => wpinv_item_types(), |
|
| 109 | + 'default' => 'custom', |
|
| 110 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 111 | + ), |
|
| 112 | + |
|
| 113 | + 'vat_rule' => array( |
|
| 114 | + 'description' => __( 'VAT rule applied to the item.', 'invoicing' ), |
|
| 115 | + 'type' => 'string', |
|
| 116 | + 'enum' => array_keys( getpaid_get_tax_rules() ), |
|
| 117 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 118 | + ), |
|
| 119 | + |
|
| 120 | + 'vat_class' => array( |
|
| 121 | + 'description' => __( 'VAT class for the item.', 'invoicing' ), |
|
| 122 | + 'type' => 'string', |
|
| 123 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 124 | + 'enum' => array_keys( getpaid_get_tax_classes() ), |
|
| 125 | + ), |
|
| 126 | + |
|
| 127 | + 'custom_id' => array( |
|
| 128 | + 'description' => __( 'Custom id for the item.', 'invoicing' ), |
|
| 129 | + 'type' => 'string', |
|
| 130 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 131 | + ), |
|
| 132 | 132 | |
| 133 | - 'custom_name' => array( |
|
| 134 | - 'description' => __( 'Custom name for the item.', 'invoicing' ), |
|
| 135 | - 'type' => 'string', |
|
| 136 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 137 | - ), |
|
| 138 | - |
|
| 139 | - 'custom_singular_name' => array( |
|
| 140 | - 'description' => __( 'Custom singular name for the item.', 'invoicing' ), |
|
| 141 | - 'type' => 'string', |
|
| 142 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 143 | - ), |
|
| 144 | - |
|
| 145 | - 'is_dynamic_pricing' => array( |
|
| 146 | - 'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ), |
|
| 147 | - 'type' => 'integer', |
|
| 148 | - 'enum' => array( 0, 1 ), |
|
| 149 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 150 | - ), |
|
| 151 | - |
|
| 152 | - 'minimum_price' => array( |
|
| 153 | - 'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ), |
|
| 154 | - 'type' => 'number', |
|
| 155 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 156 | - ), |
|
| 157 | - |
|
| 158 | - 'is_recurring' => array( |
|
| 159 | - 'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ), |
|
| 160 | - 'type' => 'integer', |
|
| 161 | - 'enum' => array( 0, 1 ), |
|
| 162 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 163 | - ), |
|
| 164 | - |
|
| 165 | - 'initial_price' => array( |
|
| 166 | - 'description' => __( 'The initial price of the item.', 'invoicing' ), |
|
| 167 | - 'type' => 'number', |
|
| 168 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 169 | - 'readonly' => true, |
|
| 170 | - ), |
|
| 171 | - |
|
| 172 | - 'the_initial_price' => array( |
|
| 173 | - 'description' => __( 'The formatted initial price of the item.', 'invoicing' ), |
|
| 174 | - 'type' => 'string', |
|
| 175 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 176 | - 'readonly' => true, |
|
| 177 | - ), |
|
| 178 | - |
|
| 179 | - 'recurring_price' => array( |
|
| 180 | - 'description' => __( 'The recurring price of the item.', 'invoicing' ), |
|
| 181 | - 'type' => 'number', |
|
| 182 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 183 | - 'readonly' => true, |
|
| 184 | - ), |
|
| 185 | - |
|
| 186 | - 'the_recurring_price' => array( |
|
| 187 | - 'description' => __( 'The formatted recurring price of the item.', 'invoicing' ), |
|
| 188 | - 'type' => 'string', |
|
| 189 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 190 | - 'readonly' => true, |
|
| 191 | - ), |
|
| 192 | - |
|
| 193 | - 'recurring_period' => array( |
|
| 194 | - 'description' => __( 'The recurring period for a recurring item.', 'invoicing' ), |
|
| 195 | - 'type' => 'string', |
|
| 196 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 197 | - 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 198 | - ), |
|
| 199 | - |
|
| 200 | - 'recurring_interval' => array( |
|
| 201 | - 'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ), |
|
| 202 | - 'type' => 'integer', |
|
| 203 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 204 | - ), |
|
| 205 | - |
|
| 206 | - 'recurring_limit' => array( |
|
| 207 | - 'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ), |
|
| 208 | - 'type' => 'integer', |
|
| 209 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 210 | - ), |
|
| 211 | - |
|
| 212 | - 'is_free_trial' => array( |
|
| 213 | - 'description' => __( 'Whether the item has a free trial period.', 'invoicing' ), |
|
| 214 | - 'type' => 'integer', |
|
| 215 | - 'enum' => array( 0, 1 ), |
|
| 216 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 217 | - ), |
|
| 218 | - |
|
| 219 | - 'trial_period' => array( |
|
| 220 | - 'description' => __( 'The trial period.', 'invoicing' ), |
|
| 221 | - 'type' => 'string', |
|
| 222 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 223 | - 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 224 | - ), |
|
| 225 | - |
|
| 226 | - 'trial_interval' => array( |
|
| 227 | - 'description' => __( 'The trial interval.', 'invoicing' ), |
|
| 228 | - 'type' => 'integer', |
|
| 229 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 230 | - ), |
|
| 231 | - |
|
| 232 | - 'first_renewal_date' => array( |
|
| 233 | - 'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ), |
|
| 234 | - 'type' => 'string', |
|
| 235 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 236 | - 'readonly' => true, |
|
| 237 | - ), |
|
| 238 | - |
|
| 239 | - 'edit_url' => array( |
|
| 240 | - 'description' => __( 'The URL to edit an item.', 'invoicing' ), |
|
| 241 | - 'type' => 'string', |
|
| 242 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 243 | - 'readonly' => true, |
|
| 244 | - ), |
|
| 133 | + 'custom_name' => array( |
|
| 134 | + 'description' => __( 'Custom name for the item.', 'invoicing' ), |
|
| 135 | + 'type' => 'string', |
|
| 136 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 137 | + ), |
|
| 138 | + |
|
| 139 | + 'custom_singular_name' => array( |
|
| 140 | + 'description' => __( 'Custom singular name for the item.', 'invoicing' ), |
|
| 141 | + 'type' => 'string', |
|
| 142 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 143 | + ), |
|
| 144 | + |
|
| 145 | + 'is_dynamic_pricing' => array( |
|
| 146 | + 'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ), |
|
| 147 | + 'type' => 'integer', |
|
| 148 | + 'enum' => array( 0, 1 ), |
|
| 149 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 150 | + ), |
|
| 151 | + |
|
| 152 | + 'minimum_price' => array( |
|
| 153 | + 'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ), |
|
| 154 | + 'type' => 'number', |
|
| 155 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 156 | + ), |
|
| 157 | + |
|
| 158 | + 'is_recurring' => array( |
|
| 159 | + 'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ), |
|
| 160 | + 'type' => 'integer', |
|
| 161 | + 'enum' => array( 0, 1 ), |
|
| 162 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 163 | + ), |
|
| 164 | + |
|
| 165 | + 'initial_price' => array( |
|
| 166 | + 'description' => __( 'The initial price of the item.', 'invoicing' ), |
|
| 167 | + 'type' => 'number', |
|
| 168 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 169 | + 'readonly' => true, |
|
| 170 | + ), |
|
| 171 | + |
|
| 172 | + 'the_initial_price' => array( |
|
| 173 | + 'description' => __( 'The formatted initial price of the item.', 'invoicing' ), |
|
| 174 | + 'type' => 'string', |
|
| 175 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 176 | + 'readonly' => true, |
|
| 177 | + ), |
|
| 178 | + |
|
| 179 | + 'recurring_price' => array( |
|
| 180 | + 'description' => __( 'The recurring price of the item.', 'invoicing' ), |
|
| 181 | + 'type' => 'number', |
|
| 182 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 183 | + 'readonly' => true, |
|
| 184 | + ), |
|
| 185 | + |
|
| 186 | + 'the_recurring_price' => array( |
|
| 187 | + 'description' => __( 'The formatted recurring price of the item.', 'invoicing' ), |
|
| 188 | + 'type' => 'string', |
|
| 189 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 190 | + 'readonly' => true, |
|
| 191 | + ), |
|
| 192 | + |
|
| 193 | + 'recurring_period' => array( |
|
| 194 | + 'description' => __( 'The recurring period for a recurring item.', 'invoicing' ), |
|
| 195 | + 'type' => 'string', |
|
| 196 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 197 | + 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 198 | + ), |
|
| 199 | + |
|
| 200 | + 'recurring_interval' => array( |
|
| 201 | + 'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ), |
|
| 202 | + 'type' => 'integer', |
|
| 203 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 204 | + ), |
|
| 205 | + |
|
| 206 | + 'recurring_limit' => array( |
|
| 207 | + 'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ), |
|
| 208 | + 'type' => 'integer', |
|
| 209 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 210 | + ), |
|
| 211 | + |
|
| 212 | + 'is_free_trial' => array( |
|
| 213 | + 'description' => __( 'Whether the item has a free trial period.', 'invoicing' ), |
|
| 214 | + 'type' => 'integer', |
|
| 215 | + 'enum' => array( 0, 1 ), |
|
| 216 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 217 | + ), |
|
| 218 | + |
|
| 219 | + 'trial_period' => array( |
|
| 220 | + 'description' => __( 'The trial period.', 'invoicing' ), |
|
| 221 | + 'type' => 'string', |
|
| 222 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 223 | + 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 224 | + ), |
|
| 225 | + |
|
| 226 | + 'trial_interval' => array( |
|
| 227 | + 'description' => __( 'The trial interval.', 'invoicing' ), |
|
| 228 | + 'type' => 'integer', |
|
| 229 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 230 | + ), |
|
| 231 | + |
|
| 232 | + 'first_renewal_date' => array( |
|
| 233 | + 'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ), |
|
| 234 | + 'type' => 'string', |
|
| 235 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 236 | + 'readonly' => true, |
|
| 237 | + ), |
|
| 238 | + |
|
| 239 | + 'edit_url' => array( |
|
| 240 | + 'description' => __( 'The URL to edit an item.', 'invoicing' ), |
|
| 241 | + 'type' => 'string', |
|
| 242 | + 'context' => array( 'view', 'edit', 'embed' ), |
|
| 243 | + 'readonly' => true, |
|
| 244 | + ), |
|
| 245 | 245 | ); |
@@ -9,237 +9,237 @@ |
||
| 9 | 9 | * @version 1.0.19 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | return array( |
| 15 | 15 | |
| 16 | 16 | 'id' => array( |
| 17 | - 'description' => __( 'Unique identifier for the item.', 'invoicing' ), |
|
| 17 | + 'description' => __('Unique identifier for the item.', 'invoicing'), |
|
| 18 | 18 | 'type' => 'integer', |
| 19 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 19 | + 'context' => array('view', 'edit', 'embed'), |
|
| 20 | 20 | 'readonly' => true, |
| 21 | 21 | ), |
| 22 | 22 | |
| 23 | 23 | 'parent_id' => array( |
| 24 | - 'description' => __( 'Parent item ID.', 'invoicing' ), |
|
| 24 | + 'description' => __('Parent item ID.', 'invoicing'), |
|
| 25 | 25 | 'type' => 'integer', |
| 26 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 26 | + 'context' => array('view', 'edit', 'embed'), |
|
| 27 | 27 | 'default' => 0, |
| 28 | 28 | ), |
| 29 | 29 | |
| 30 | 30 | 'status' => array( |
| 31 | - 'description' => __( 'A named status for the item.', 'invoicing' ), |
|
| 31 | + 'description' => __('A named status for the item.', 'invoicing'), |
|
| 32 | 32 | 'type' => 'string', |
| 33 | - 'enum' => array( 'draft', 'pending', 'publish' ), |
|
| 34 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 33 | + 'enum' => array('draft', 'pending', 'publish'), |
|
| 34 | + 'context' => array('view', 'edit', 'embed'), |
|
| 35 | 35 | 'default' => 'draft', |
| 36 | 36 | ), |
| 37 | 37 | |
| 38 | 38 | 'version' => array( |
| 39 | - 'description' => __( 'Plugin version when the item was created.', 'invoicing' ), |
|
| 39 | + 'description' => __('Plugin version when the item was created.', 'invoicing'), |
|
| 40 | 40 | 'type' => 'string', |
| 41 | - 'context' => array( 'view', 'edit' ), |
|
| 41 | + 'context' => array('view', 'edit'), |
|
| 42 | 42 | 'readonly' => true, |
| 43 | 43 | ), |
| 44 | 44 | |
| 45 | 45 | 'date_created' => array( |
| 46 | - 'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ), |
|
| 46 | + 'description' => __("The date the item was created, in the site's timezone.", 'invoicing'), |
|
| 47 | 47 | 'type' => 'string', |
| 48 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 48 | + 'context' => array('view', 'edit', 'embed'), |
|
| 49 | 49 | ), |
| 50 | 50 | |
| 51 | 51 | 'date_created_gmt' => array( |
| 52 | - 'description' => __( 'The GMT date the item was created.', 'invoicing' ), |
|
| 52 | + 'description' => __('The GMT date the item was created.', 'invoicing'), |
|
| 53 | 53 | 'type' => 'string', |
| 54 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 54 | + 'context' => array('view', 'edit', 'embed'), |
|
| 55 | 55 | 'readonly' => true, |
| 56 | 56 | ), |
| 57 | 57 | |
| 58 | 58 | 'date_modified' => array( |
| 59 | - 'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ), |
|
| 59 | + 'description' => __("The date the item was last modified, in the site's timezone.", 'invoicing'), |
|
| 60 | 60 | 'type' => 'string', |
| 61 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 61 | + 'context' => array('view', 'edit', 'embed'), |
|
| 62 | 62 | 'readonly' => true, |
| 63 | 63 | ), |
| 64 | 64 | |
| 65 | 65 | 'date_modified_gmt' => array( |
| 66 | - 'description' => __( 'The GMT date the item was last modified.', 'invoicing' ), |
|
| 66 | + 'description' => __('The GMT date the item was last modified.', 'invoicing'), |
|
| 67 | 67 | 'type' => 'string', |
| 68 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 68 | + 'context' => array('view', 'edit', 'embed'), |
|
| 69 | 69 | 'readonly' => true, |
| 70 | 70 | ), |
| 71 | 71 | |
| 72 | 72 | 'name' => array( |
| 73 | - 'description' => __( "The item's name.", 'invoicing' ), |
|
| 73 | + 'description' => __("The item's name.", 'invoicing'), |
|
| 74 | 74 | 'type' => 'string', |
| 75 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 75 | + 'context' => array('view', 'edit', 'embed'), |
|
| 76 | 76 | 'required' => true, |
| 77 | 77 | ), |
| 78 | 78 | |
| 79 | 79 | 'description' => array( |
| 80 | - 'description' => __( "The item's description.", 'invoicing' ), |
|
| 80 | + 'description' => __("The item's description.", 'invoicing'), |
|
| 81 | 81 | 'type' => 'string', |
| 82 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 82 | + 'context' => array('view', 'edit', 'embed'), |
|
| 83 | 83 | ), |
| 84 | 84 | |
| 85 | 85 | 'owner' => array( |
| 86 | - 'description' => __( 'The owner of the item (user id).', 'invoicing' ), |
|
| 86 | + 'description' => __('The owner of the item (user id).', 'invoicing'), |
|
| 87 | 87 | 'type' => 'integer', |
| 88 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 88 | + 'context' => array('view', 'edit', 'embed'), |
|
| 89 | 89 | ), |
| 90 | 90 | |
| 91 | 91 | 'price' => array( |
| 92 | - 'description' => __( 'The price of the item.', 'invoicing' ), |
|
| 92 | + 'description' => __('The price of the item.', 'invoicing'), |
|
| 93 | 93 | 'type' => 'number', |
| 94 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 94 | + 'context' => array('view', 'edit', 'embed'), |
|
| 95 | 95 | 'required' => true, |
| 96 | 96 | ), |
| 97 | 97 | |
| 98 | 98 | 'the_price' => array( |
| 99 | - 'description' => __( 'The formatted price of the item.', 'invoicing' ), |
|
| 99 | + 'description' => __('The formatted price of the item.', 'invoicing'), |
|
| 100 | 100 | 'type' => 'string', |
| 101 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 101 | + 'context' => array('view', 'edit', 'embed'), |
|
| 102 | 102 | 'readonly' => true, |
| 103 | 103 | ), |
| 104 | 104 | |
| 105 | 105 | 'type' => array( |
| 106 | - 'description' => __( 'The item type.', 'invoicing' ), |
|
| 106 | + 'description' => __('The item type.', 'invoicing'), |
|
| 107 | 107 | 'type' => 'string', |
| 108 | 108 | 'enum' => wpinv_item_types(), |
| 109 | 109 | 'default' => 'custom', |
| 110 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 110 | + 'context' => array('view', 'edit', 'embed'), |
|
| 111 | 111 | ), |
| 112 | 112 | |
| 113 | 113 | 'vat_rule' => array( |
| 114 | - 'description' => __( 'VAT rule applied to the item.', 'invoicing' ), |
|
| 114 | + 'description' => __('VAT rule applied to the item.', 'invoicing'), |
|
| 115 | 115 | 'type' => 'string', |
| 116 | - 'enum' => array_keys( getpaid_get_tax_rules() ), |
|
| 117 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 116 | + 'enum' => array_keys(getpaid_get_tax_rules()), |
|
| 117 | + 'context' => array('view', 'edit', 'embed'), |
|
| 118 | 118 | ), |
| 119 | 119 | |
| 120 | 120 | 'vat_class' => array( |
| 121 | - 'description' => __( 'VAT class for the item.', 'invoicing' ), |
|
| 121 | + 'description' => __('VAT class for the item.', 'invoicing'), |
|
| 122 | 122 | 'type' => 'string', |
| 123 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 124 | - 'enum' => array_keys( getpaid_get_tax_classes() ), |
|
| 123 | + 'context' => array('view', 'edit', 'embed'), |
|
| 124 | + 'enum' => array_keys(getpaid_get_tax_classes()), |
|
| 125 | 125 | ), |
| 126 | 126 | |
| 127 | 127 | 'custom_id' => array( |
| 128 | - 'description' => __( 'Custom id for the item.', 'invoicing' ), |
|
| 128 | + 'description' => __('Custom id for the item.', 'invoicing'), |
|
| 129 | 129 | 'type' => 'string', |
| 130 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 130 | + 'context' => array('view', 'edit', 'embed'), |
|
| 131 | 131 | ), |
| 132 | 132 | |
| 133 | 133 | 'custom_name' => array( |
| 134 | - 'description' => __( 'Custom name for the item.', 'invoicing' ), |
|
| 134 | + 'description' => __('Custom name for the item.', 'invoicing'), |
|
| 135 | 135 | 'type' => 'string', |
| 136 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 136 | + 'context' => array('view', 'edit', 'embed'), |
|
| 137 | 137 | ), |
| 138 | 138 | |
| 139 | 139 | 'custom_singular_name' => array( |
| 140 | - 'description' => __( 'Custom singular name for the item.', 'invoicing' ), |
|
| 140 | + 'description' => __('Custom singular name for the item.', 'invoicing'), |
|
| 141 | 141 | 'type' => 'string', |
| 142 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 142 | + 'context' => array('view', 'edit', 'embed'), |
|
| 143 | 143 | ), |
| 144 | 144 | |
| 145 | 145 | 'is_dynamic_pricing' => array( |
| 146 | - 'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ), |
|
| 146 | + 'description' => __('Whether or not customers can enter their own prices when checking out.', 'invoicing'), |
|
| 147 | 147 | 'type' => 'integer', |
| 148 | - 'enum' => array( 0, 1 ), |
|
| 149 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 148 | + 'enum' => array(0, 1), |
|
| 149 | + 'context' => array('view', 'edit', 'embed'), |
|
| 150 | 150 | ), |
| 151 | 151 | |
| 152 | 152 | 'minimum_price' => array( |
| 153 | - 'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ), |
|
| 153 | + 'description' => __('For dynamic prices, this is the minimum price that a user can set.', 'invoicing'), |
|
| 154 | 154 | 'type' => 'number', |
| 155 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 155 | + 'context' => array('view', 'edit', 'embed'), |
|
| 156 | 156 | ), |
| 157 | 157 | |
| 158 | 158 | 'is_recurring' => array( |
| 159 | - 'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ), |
|
| 159 | + 'description' => __('Whether or not this is a subscription item.', 'invoicing'), |
|
| 160 | 160 | 'type' => 'integer', |
| 161 | - 'enum' => array( 0, 1 ), |
|
| 162 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 161 | + 'enum' => array(0, 1), |
|
| 162 | + 'context' => array('view', 'edit', 'embed'), |
|
| 163 | 163 | ), |
| 164 | 164 | |
| 165 | 165 | 'initial_price' => array( |
| 166 | - 'description' => __( 'The initial price of the item.', 'invoicing' ), |
|
| 166 | + 'description' => __('The initial price of the item.', 'invoicing'), |
|
| 167 | 167 | 'type' => 'number', |
| 168 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 168 | + 'context' => array('view', 'edit', 'embed'), |
|
| 169 | 169 | 'readonly' => true, |
| 170 | 170 | ), |
| 171 | 171 | |
| 172 | 172 | 'the_initial_price' => array( |
| 173 | - 'description' => __( 'The formatted initial price of the item.', 'invoicing' ), |
|
| 173 | + 'description' => __('The formatted initial price of the item.', 'invoicing'), |
|
| 174 | 174 | 'type' => 'string', |
| 175 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 175 | + 'context' => array('view', 'edit', 'embed'), |
|
| 176 | 176 | 'readonly' => true, |
| 177 | 177 | ), |
| 178 | 178 | |
| 179 | 179 | 'recurring_price' => array( |
| 180 | - 'description' => __( 'The recurring price of the item.', 'invoicing' ), |
|
| 180 | + 'description' => __('The recurring price of the item.', 'invoicing'), |
|
| 181 | 181 | 'type' => 'number', |
| 182 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 182 | + 'context' => array('view', 'edit', 'embed'), |
|
| 183 | 183 | 'readonly' => true, |
| 184 | 184 | ), |
| 185 | 185 | |
| 186 | 186 | 'the_recurring_price' => array( |
| 187 | - 'description' => __( 'The formatted recurring price of the item.', 'invoicing' ), |
|
| 187 | + 'description' => __('The formatted recurring price of the item.', 'invoicing'), |
|
| 188 | 188 | 'type' => 'string', |
| 189 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 189 | + 'context' => array('view', 'edit', 'embed'), |
|
| 190 | 190 | 'readonly' => true, |
| 191 | 191 | ), |
| 192 | 192 | |
| 193 | 193 | 'recurring_period' => array( |
| 194 | - 'description' => __( 'The recurring period for a recurring item.', 'invoicing' ), |
|
| 194 | + 'description' => __('The recurring period for a recurring item.', 'invoicing'), |
|
| 195 | 195 | 'type' => 'string', |
| 196 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 197 | - 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 196 | + 'context' => array('view', 'edit', 'embed'), |
|
| 197 | + 'enum' => array('D', 'W', 'M', 'Y'), |
|
| 198 | 198 | ), |
| 199 | 199 | |
| 200 | 200 | 'recurring_interval' => array( |
| 201 | - 'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ), |
|
| 201 | + 'description' => __('The recurring interval for a subscription item.', 'invoicing'), |
|
| 202 | 202 | 'type' => 'integer', |
| 203 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 203 | + 'context' => array('view', 'edit', 'embed'), |
|
| 204 | 204 | ), |
| 205 | 205 | |
| 206 | 206 | 'recurring_limit' => array( |
| 207 | - 'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ), |
|
| 207 | + 'description' => __('The maximum number of renewals for a subscription item.', 'invoicing'), |
|
| 208 | 208 | 'type' => 'integer', |
| 209 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 209 | + 'context' => array('view', 'edit', 'embed'), |
|
| 210 | 210 | ), |
| 211 | 211 | |
| 212 | 212 | 'is_free_trial' => array( |
| 213 | - 'description' => __( 'Whether the item has a free trial period.', 'invoicing' ), |
|
| 213 | + 'description' => __('Whether the item has a free trial period.', 'invoicing'), |
|
| 214 | 214 | 'type' => 'integer', |
| 215 | - 'enum' => array( 0, 1 ), |
|
| 216 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 215 | + 'enum' => array(0, 1), |
|
| 216 | + 'context' => array('view', 'edit', 'embed'), |
|
| 217 | 217 | ), |
| 218 | 218 | |
| 219 | 219 | 'trial_period' => array( |
| 220 | - 'description' => __( 'The trial period.', 'invoicing' ), |
|
| 220 | + 'description' => __('The trial period.', 'invoicing'), |
|
| 221 | 221 | 'type' => 'string', |
| 222 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 223 | - 'enum' => array( 'D', 'W', 'M', 'Y' ), |
|
| 222 | + 'context' => array('view', 'edit', 'embed'), |
|
| 223 | + 'enum' => array('D', 'W', 'M', 'Y'), |
|
| 224 | 224 | ), |
| 225 | 225 | |
| 226 | 226 | 'trial_interval' => array( |
| 227 | - 'description' => __( 'The trial interval.', 'invoicing' ), |
|
| 227 | + 'description' => __('The trial interval.', 'invoicing'), |
|
| 228 | 228 | 'type' => 'integer', |
| 229 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 229 | + 'context' => array('view', 'edit', 'embed'), |
|
| 230 | 230 | ), |
| 231 | 231 | |
| 232 | 232 | 'first_renewal_date' => array( |
| 233 | - 'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ), |
|
| 233 | + 'description' => __('The first renewal date in case the item was to be bought today.', 'invoicing'), |
|
| 234 | 234 | 'type' => 'string', |
| 235 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 235 | + 'context' => array('view', 'edit', 'embed'), |
|
| 236 | 236 | 'readonly' => true, |
| 237 | 237 | ), |
| 238 | 238 | |
| 239 | 239 | 'edit_url' => array( |
| 240 | - 'description' => __( 'The URL to edit an item.', 'invoicing' ), |
|
| 240 | + 'description' => __('The URL to edit an item.', 'invoicing'), |
|
| 241 | 241 | 'type' => 'string', |
| 242 | - 'context' => array( 'view', 'edit', 'embed' ), |
|
| 242 | + 'context' => array('view', 'edit', 'embed'), |
|
| 243 | 243 | 'readonly' => true, |
| 244 | 244 | ), |
| 245 | 245 | ); |
@@ -7,20 +7,20 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Fetch the invoice. |
| 13 | -if ( empty( $invoice ) ) { |
|
| 14 | - $invoice = new WPInv_Invoice( $GLOBALS['post'] ); |
|
| 13 | +if (empty($invoice)) { |
|
| 14 | + $invoice = new WPInv_Invoice($GLOBALS['post']); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Abort if it does not exist. |
| 18 | -if ( $invoice->get_id() == 0 ) { |
|
| 18 | +if ($invoice->get_id() == 0) { |
|
| 19 | 19 | exit; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // Fires before printing an invoice. |
| 23 | -do_action( 'wpinv_invoice_print_before_display', $invoice ); |
|
| 23 | +do_action('wpinv_invoice_print_before_display', $invoice); |
|
| 24 | 24 | |
| 25 | 25 | ?><!DOCTYPE html> |
| 26 | 26 | |
@@ -29,24 +29,24 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | <head> |
| 31 | 31 | |
| 32 | - <meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
| 32 | + <meta charset="<?php bloginfo('charset'); ?>"> |
|
| 33 | 33 | <meta name="viewport" content="width=device-width, initial-scale=1.0" > |
| 34 | 34 | |
| 35 | 35 | <meta name="robots" content="noindex,nofollow"> |
| 36 | 36 | |
| 37 | 37 | <link rel="profile" href="https://gmpg.org/xfn/11"> |
| 38 | 38 | |
| 39 | - <title>#<?php echo sanitize_text_field( $invoice->get_number() ); ?></title> |
|
| 39 | + <title>#<?php echo sanitize_text_field($invoice->get_number()); ?></title> |
|
| 40 | 40 | |
| 41 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
| 41 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
| 42 | 42 | |
| 43 | 43 | </head> |
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | <body class="body wpinv wpinv-print" style="font-weight: 400;"> |
| 47 | 47 | |
| 48 | - <?php do_action( 'getpaid_invoice', $invoice ); ?> |
|
| 49 | - <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?> |
|
| 48 | + <?php do_action('getpaid_invoice', $invoice); ?> |
|
| 49 | + <?php do_action('wpinv_invoice_print_body_end', $invoice); ?> |
|
| 50 | 50 | |
| 51 | 51 | </body> |
| 52 | 52 | |
@@ -8,25 +8,25 @@ |
||
| 8 | 8 | * @var WPInv_Invoice $invoice |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | <div class="getpaid-header-left-actions"> |
| 16 | 16 | |
| 17 | - <?php if ( $invoice->is_type( 'invoice' ) && $invoice->needs_payment() && ! $invoice->is_held() ): ?> |
|
| 18 | - <a class="btn btn-sm btn-primary m-1 d-inline-block invoice-action-pay" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"> |
|
| 19 | - <?php _e( 'Pay For Invoice', 'invoicing' ); ?> |
|
| 17 | + <?php if ($invoice->is_type('invoice') && $invoice->needs_payment() && !$invoice->is_held()): ?> |
|
| 18 | + <a class="btn btn-sm btn-primary m-1 d-inline-block invoice-action-pay" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"> |
|
| 19 | + <?php _e('Pay For Invoice', 'invoicing'); ?> |
|
| 20 | 20 | </a> |
| 21 | 21 | <?php endif; ?> |
| 22 | 22 | |
| 23 | - <?php if ( $invoice->is_type( 'invoice' ) && $invoice->is_paid() ): ?> |
|
| 24 | - <a class="btn btn-sm btn-info m-1 d-inline-block invoice-action-receipt" href="<?php echo esc_url( $invoice->get_receipt_url() ); ?>"> |
|
| 25 | - <?php _e( 'View Receipt', 'invoicing' ); ?> |
|
| 23 | + <?php if ($invoice->is_type('invoice') && $invoice->is_paid()): ?> |
|
| 24 | + <a class="btn btn-sm btn-info m-1 d-inline-block invoice-action-receipt" href="<?php echo esc_url($invoice->get_receipt_url()); ?>"> |
|
| 25 | + <?php _e('View Receipt', 'invoicing'); ?> |
|
| 26 | 26 | </a> |
| 27 | 27 | <?php endif; ?> |
| 28 | 28 | |
| 29 | - <?php do_action( 'wpinv_invoice_display_left_actions', $invoice ); ?> |
|
| 29 | + <?php do_action('wpinv_invoice_display_left_actions', $invoice); ?> |
|
| 30 | 30 | |
| 31 | 31 | </div> |
| 32 | 32 | |
@@ -7,16 +7,16 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | 14 | <div class="border-top pt-4 bg-white"> |
| 15 | 15 | <div class="container pr-0 pl-0"> |
| 16 | 16 | |
| 17 | - <?php if ( $term_text = wpinv_get_terms_text() ) : ?> |
|
| 17 | + <?php if ($term_text = wpinv_get_terms_text()) : ?> |
|
| 18 | 18 | <div class="terms-text"> |
| 19 | - <?php echo wpautop( $term_text ); ?> |
|
| 19 | + <?php echo wpautop($term_text); ?> |
|
| 20 | 20 | </div> |
| 21 | 21 | <?php endif; ?> |
| 22 | 22 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | <div class="row"> |
| 17 | 17 | |
| 18 | 18 | <div class="col-12 col-sm-6 text-sm-left pl-sm-0"> |
| 19 | - <?php do_action( 'getpaid_invoice_header_left', $invoice );?> |
|
| 19 | + <?php do_action('getpaid_invoice_header_left', $invoice); ?> |
|
| 20 | 20 | </div> |
| 21 | 21 | |
| 22 | 22 | <div class="col-12 col-sm-6 text-sm-right pr-sm-0"> |
| 23 | - <?php do_action( 'getpaid_invoice_header_right', $invoice );?> |
|
| 23 | + <?php do_action('getpaid_invoice_header_right', $invoice); ?> |
|
| 24 | 24 | </div> |
| 25 | 25 | |
| 26 | 26 | </div> |
@@ -7,24 +7,24 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | - <?php do_action( 'getpaid_before_invoice_details_top', $invoice ); ?> |
|
| 14 | + <?php do_action('getpaid_before_invoice_details_top', $invoice); ?> |
|
| 15 | 15 | |
| 16 | 16 | <div class="getpaid-invoice-details-top mb-5"> |
| 17 | 17 | <div class="row"> |
| 18 | 18 | <div class="col-12 col-sm-6 text-sm-left"> |
| 19 | - <?php do_action( 'getpaid_invoice_details_top_left', $invoice ); ?> |
|
| 19 | + <?php do_action('getpaid_invoice_details_top_left', $invoice); ?> |
|
| 20 | 20 | </div> |
| 21 | 21 | |
| 22 | 22 | <div class="col-12 col-sm-6 text-sm-right"> |
| 23 | - <?php do_action( 'getpaid_invoice_details_top_right', $invoice ); ?> |
|
| 23 | + <?php do_action('getpaid_invoice_details_top_right', $invoice); ?> |
|
| 24 | 24 | </div> |
| 25 | 25 | </div> |
| 26 | 26 | </div> |
| 27 | 27 | |
| 28 | - <?php do_action( 'getpaid_after_invoice_details_top', $invoice ); ?> |
|
| 28 | + <?php do_action('getpaid_after_invoice_details_top', $invoice); ?> |
|
| 29 | 29 | |
| 30 | 30 | <?php |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | <?php |
| 19 | 19 | |
| 20 | 20 | // Fires when printing the header. |
| 21 | - do_action( 'getpaid_invoice_header', $invoice ); |
|
| 21 | + do_action('getpaid_invoice_header', $invoice); |
|
| 22 | 22 | |
| 23 | 23 | // Print the opening wrapper. |
| 24 | 24 | echo '<div class="container bg-white border mt-4 mb-4 p-4 position-relative flex-grow-1">'; |
@@ -27,16 +27,16 @@ discard block |
||
| 27 | 27 | wpinv_print_errors(); |
| 28 | 28 | |
| 29 | 29 | // Fires when printing the invoice details. |
| 30 | - do_action( 'getpaid_invoice_details', $invoice ); |
|
| 30 | + do_action('getpaid_invoice_details', $invoice); |
|
| 31 | 31 | |
| 32 | 32 | // Fires when printing the invoice line items. |
| 33 | - do_action( 'getpaid_invoice_line_items', $invoice ); |
|
| 33 | + do_action('getpaid_invoice_line_items', $invoice); |
|
| 34 | 34 | |
| 35 | 35 | // Print the closing wrapper. |
| 36 | 36 | echo '</div>'; |
| 37 | 37 | |
| 38 | 38 | // Fires when printing the invoice footer. |
| 39 | - do_action( 'getpaid_invoice_footer', $invoice ); |
|
| 39 | + do_action('getpaid_invoice_footer', $invoice); |
|
| 40 | 40 | |
| 41 | 41 | ?> |
| 42 | 42 | |
@@ -36,36 +36,36 @@ discard block |
||
| 36 | 36 | 'desc_tip' => true, |
| 37 | 37 | 'default' => '', |
| 38 | 38 | 'advanced' => false |
| 39 | - ), |
|
| 39 | + ), |
|
| 40 | 40 | |
| 41 | 41 | 'form' => array( |
| 42 | - 'title' => __( 'Form', 'invoicing' ), |
|
| 43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
| 44 | - 'type' => 'text', |
|
| 45 | - 'desc_tip' => true, |
|
| 46 | - 'default' => '', |
|
| 47 | - 'placeholder' => __('1','invoicing'), |
|
| 48 | - 'advanced' => false |
|
| 49 | - ), |
|
| 50 | - |
|
| 51 | - 'item' => array( |
|
| 52 | - 'title' => __( 'Items', 'invoicing' ), |
|
| 53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
| 54 | - 'type' => 'text', |
|
| 55 | - 'desc_tip' => true, |
|
| 56 | - 'default' => '', |
|
| 57 | - 'placeholder' => __('1','invoicing'), |
|
| 58 | - 'advanced' => false |
|
| 59 | - ), |
|
| 42 | + 'title' => __( 'Form', 'invoicing' ), |
|
| 43 | + 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
| 44 | + 'type' => 'text', |
|
| 45 | + 'desc_tip' => true, |
|
| 46 | + 'default' => '', |
|
| 47 | + 'placeholder' => __('1','invoicing'), |
|
| 48 | + 'advanced' => false |
|
| 49 | + ), |
|
| 50 | + |
|
| 51 | + 'item' => array( |
|
| 52 | + 'title' => __( 'Items', 'invoicing' ), |
|
| 53 | + 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
| 54 | + 'type' => 'text', |
|
| 55 | + 'desc_tip' => true, |
|
| 56 | + 'default' => '', |
|
| 57 | + 'placeholder' => __('1','invoicing'), |
|
| 58 | + 'advanced' => false |
|
| 59 | + ), |
|
| 60 | 60 | |
| 61 | 61 | 'button' => array( |
| 62 | - 'title' => __( 'Button', 'invoicing' ), |
|
| 63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
| 64 | - 'type' => 'text', |
|
| 65 | - 'desc_tip' => true, |
|
| 66 | - 'default' => '', |
|
| 67 | - 'advanced' => false |
|
| 68 | - ) |
|
| 62 | + 'title' => __( 'Button', 'invoicing' ), |
|
| 63 | + 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
| 64 | + 'type' => 'text', |
|
| 65 | + 'desc_tip' => true, |
|
| 66 | + 'default' => '', |
|
| 67 | + 'advanced' => false |
|
| 68 | + ) |
|
| 69 | 69 | |
| 70 | 70 | ) |
| 71 | 71 | |
@@ -75,96 +75,96 @@ discard block |
||
| 75 | 75 | parent::__construct( $options ); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * The Super block output function. |
|
| 80 | - * |
|
| 81 | - * @param array $args |
|
| 82 | - * @param array $widget_args |
|
| 83 | - * @param string $content |
|
| 84 | - * |
|
| 85 | - * @return string |
|
| 86 | - */ |
|
| 78 | + /** |
|
| 79 | + * The Super block output function. |
|
| 80 | + * |
|
| 81 | + * @param array $args |
|
| 82 | + * @param array $widget_args |
|
| 83 | + * @param string $content |
|
| 84 | + * |
|
| 85 | + * @return string |
|
| 86 | + */ |
|
| 87 | 87 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 88 | 88 | |
| 89 | - // Is the shortcode set up correctly? |
|
| 90 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
| 91 | - return aui()->alert( |
|
| 92 | - array( |
|
| 93 | - 'type' => 'warning', |
|
| 94 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
| 95 | - ) |
|
| 96 | - ); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - // Payment form or button? |
|
| 100 | - if ( ! empty( $args['form'] ) ) { |
|
| 101 | - return $this->handle_payment_form( $args ); |
|
| 102 | - } else { |
|
| 103 | - return $this->handle_buy_item( $args ); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Displaying a payment form |
|
| 110 | - * |
|
| 111 | - * @return string |
|
| 112 | - */ |
|
| 89 | + // Is the shortcode set up correctly? |
|
| 90 | + if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
| 91 | + return aui()->alert( |
|
| 92 | + array( |
|
| 93 | + 'type' => 'warning', |
|
| 94 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
| 95 | + ) |
|
| 96 | + ); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + // Payment form or button? |
|
| 100 | + if ( ! empty( $args['form'] ) ) { |
|
| 101 | + return $this->handle_payment_form( $args ); |
|
| 102 | + } else { |
|
| 103 | + return $this->handle_buy_item( $args ); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Displaying a payment form |
|
| 110 | + * |
|
| 111 | + * @return string |
|
| 112 | + */ |
|
| 113 | 113 | protected function handle_payment_form( $args = array() ) { |
| 114 | 114 | |
| 115 | - if ( empty( $args['button'] ) ) { |
|
| 116 | - ob_start(); |
|
| 117 | - getpaid_display_payment_form( $args['form'] ); |
|
| 118 | - return ob_get_clean(); |
|
| 119 | - } |
|
| 115 | + if ( empty( $args['button'] ) ) { |
|
| 116 | + ob_start(); |
|
| 117 | + getpaid_display_payment_form( $args['form'] ); |
|
| 118 | + return ob_get_clean(); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
| 122 | - } |
|
| 121 | + return $this->payment_form_button( $args['form'], $args['button'] ); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Displays a payment form button. |
|
| 126 | - * |
|
| 127 | - * @return string |
|
| 128 | - */ |
|
| 124 | + /** |
|
| 125 | + * Displays a payment form button. |
|
| 126 | + * |
|
| 127 | + * @return string |
|
| 128 | + */ |
|
| 129 | 129 | protected function payment_form_button( $form, $button ) { |
| 130 | - return getpaid_get_payment_button( $button, $form ); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Selling an item |
|
| 135 | - * |
|
| 136 | - * @return string |
|
| 137 | - */ |
|
| 130 | + return getpaid_get_payment_button( $button, $form ); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Selling an item |
|
| 135 | + * |
|
| 136 | + * @return string |
|
| 137 | + */ |
|
| 138 | 138 | protected function handle_buy_item( $args = array() ) { |
| 139 | 139 | |
| 140 | - if ( empty( $args['button'] ) ) { |
|
| 141 | - return $this->buy_item_form( $args['item'] ); |
|
| 142 | - } |
|
| 140 | + if ( empty( $args['button'] ) ) { |
|
| 141 | + return $this->buy_item_form( $args['item'] ); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
| 144 | + return $this->buy_item_button( $args['item'], $args['button'] ); |
|
| 145 | 145 | |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Displays a buy item form. |
|
| 150 | - * |
|
| 151 | - * @return string |
|
| 152 | - */ |
|
| 148 | + /** |
|
| 149 | + * Displays a buy item form. |
|
| 150 | + * |
|
| 151 | + * @return string |
|
| 152 | + */ |
|
| 153 | 153 | protected function buy_item_form( $item ) { |
| 154 | - $items = getpaid_convert_items_to_array( $item ); |
|
| 155 | - ob_start(); |
|
| 156 | - getpaid_display_item_payment_form( $items ); |
|
| 157 | - return ob_get_clean(); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Displays a buy item button. |
|
| 162 | - * |
|
| 163 | - * @return string |
|
| 164 | - */ |
|
| 154 | + $items = getpaid_convert_items_to_array( $item ); |
|
| 155 | + ob_start(); |
|
| 156 | + getpaid_display_item_payment_form( $items ); |
|
| 157 | + return ob_get_clean(); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Displays a buy item button. |
|
| 162 | + * |
|
| 163 | + * @return string |
|
| 164 | + */ |
|
| 165 | 165 | protected function buy_item_button( $item, $button ) { |
| 166 | - $button = getpaid_get_payment_button( $button, null, $item ); |
|
| 167 | - return apply_filters( 'getpaid_buy_item_button_widget', $button, $item ); |
|
| 166 | + $button = getpaid_get_payment_button( $button, null, $item ); |
|
| 167 | + return apply_filters( 'getpaid_buy_item_button_widget', $button, $item ); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | 'block-keywords'=> "['invoicing','buy', 'buy item', 'form']", |
| 23 | 23 | 'class_name' => __CLASS__, |
| 24 | 24 | 'base_id' => 'getpaid', |
| 25 | - 'name' => __('GetPaid','invoicing'), |
|
| 25 | + 'name' => __('GetPaid', 'invoicing'), |
|
| 26 | 26 | 'widget_ops' => array( |
| 27 | 27 | 'classname' => 'getpaid bsui', |
| 28 | - 'description' => esc_html__('Show payment forms or buttons.','invoicing'), |
|
| 28 | + 'description' => esc_html__('Show payment forms or buttons.', 'invoicing'), |
|
| 29 | 29 | ), |
| 30 | 30 | 'arguments' => array( |
| 31 | 31 | |
| 32 | 32 | 'title' => array( |
| 33 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 34 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 33 | + 'title' => __('Widget title', 'invoicing'), |
|
| 34 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 35 | 35 | 'type' => 'text', |
| 36 | 36 | 'desc_tip' => true, |
| 37 | 37 | 'default' => '', |
@@ -39,28 +39,28 @@ discard block |
||
| 39 | 39 | ), |
| 40 | 40 | |
| 41 | 41 | 'form' => array( |
| 42 | - 'title' => __( 'Form', 'invoicing' ), |
|
| 43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
| 42 | + 'title' => __('Form', 'invoicing'), |
|
| 43 | + 'desc' => __('Enter a form id in case you want to display a specific payment form', 'invoicing'), |
|
| 44 | 44 | 'type' => 'text', |
| 45 | 45 | 'desc_tip' => true, |
| 46 | 46 | 'default' => '', |
| 47 | - 'placeholder' => __('1','invoicing'), |
|
| 47 | + 'placeholder' => __('1', 'invoicing'), |
|
| 48 | 48 | 'advanced' => false |
| 49 | 49 | ), |
| 50 | 50 | |
| 51 | 51 | 'item' => array( |
| 52 | - 'title' => __( 'Items', 'invoicing' ), |
|
| 53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
| 52 | + 'title' => __('Items', 'invoicing'), |
|
| 53 | + 'desc' => __('Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing'), |
|
| 54 | 54 | 'type' => 'text', |
| 55 | 55 | 'desc_tip' => true, |
| 56 | 56 | 'default' => '', |
| 57 | - 'placeholder' => __('1','invoicing'), |
|
| 57 | + 'placeholder' => __('1', 'invoicing'), |
|
| 58 | 58 | 'advanced' => false |
| 59 | 59 | ), |
| 60 | 60 | |
| 61 | 61 | 'button' => array( |
| 62 | - 'title' => __( 'Button', 'invoicing' ), |
|
| 63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
| 62 | + 'title' => __('Button', 'invoicing'), |
|
| 63 | + 'desc' => __('Enter button label in case you would like to display the forms in a popup.', 'invoicing'), |
|
| 64 | 64 | 'type' => 'text', |
| 65 | 65 | 'desc_tip' => true, |
| 66 | 66 | 'default' => '', |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | 74 | |
| 75 | - parent::__construct( $options ); |
|
| 75 | + parent::__construct($options); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -84,23 +84,23 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return string |
| 86 | 86 | */ |
| 87 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 87 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 88 | 88 | |
| 89 | 89 | // Is the shortcode set up correctly? |
| 90 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
| 90 | + if (empty($args['form']) && empty($args['item'])) { |
|
| 91 | 91 | return aui()->alert( |
| 92 | 92 | array( |
| 93 | 93 | 'type' => 'warning', |
| 94 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
| 94 | + 'content' => __('No payment form or item selected', 'invoicing'), |
|
| 95 | 95 | ) |
| 96 | 96 | ); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Payment form or button? |
| 100 | - if ( ! empty( $args['form'] ) ) { |
|
| 101 | - return $this->handle_payment_form( $args ); |
|
| 100 | + if (!empty($args['form'])) { |
|
| 101 | + return $this->handle_payment_form($args); |
|
| 102 | 102 | } else { |
| 103 | - return $this->handle_buy_item( $args ); |
|
| 103 | + return $this->handle_buy_item($args); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | } |
@@ -110,15 +110,15 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | - protected function handle_payment_form( $args = array() ) { |
|
| 113 | + protected function handle_payment_form($args = array()) { |
|
| 114 | 114 | |
| 115 | - if ( empty( $args['button'] ) ) { |
|
| 115 | + if (empty($args['button'])) { |
|
| 116 | 116 | ob_start(); |
| 117 | - getpaid_display_payment_form( $args['form'] ); |
|
| 117 | + getpaid_display_payment_form($args['form']); |
|
| 118 | 118 | return ob_get_clean(); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
| 121 | + return $this->payment_form_button($args['form'], $args['button']); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return string |
| 128 | 128 | */ |
| 129 | - protected function payment_form_button( $form, $button ) { |
|
| 130 | - return getpaid_get_payment_button( $button, $form ); |
|
| 129 | + protected function payment_form_button($form, $button) { |
|
| 130 | + return getpaid_get_payment_button($button, $form); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return string |
| 137 | 137 | */ |
| 138 | - protected function handle_buy_item( $args = array() ) { |
|
| 138 | + protected function handle_buy_item($args = array()) { |
|
| 139 | 139 | |
| 140 | - if ( empty( $args['button'] ) ) { |
|
| 141 | - return $this->buy_item_form( $args['item'] ); |
|
| 140 | + if (empty($args['button'])) { |
|
| 141 | + return $this->buy_item_form($args['item']); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
| 144 | + return $this->buy_item_button($args['item'], $args['button']); |
|
| 145 | 145 | |
| 146 | 146 | } |
| 147 | 147 | |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @return string |
| 152 | 152 | */ |
| 153 | - protected function buy_item_form( $item ) { |
|
| 154 | - $items = getpaid_convert_items_to_array( $item ); |
|
| 153 | + protected function buy_item_form($item) { |
|
| 154 | + $items = getpaid_convert_items_to_array($item); |
|
| 155 | 155 | ob_start(); |
| 156 | - getpaid_display_item_payment_form( $items ); |
|
| 156 | + getpaid_display_item_payment_form($items); |
|
| 157 | 157 | return ob_get_clean(); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return string |
| 164 | 164 | */ |
| 165 | - protected function buy_item_button( $item, $button ) { |
|
| 166 | - $button = getpaid_get_payment_button( $button, null, $item ); |
|
| 167 | - return apply_filters( 'getpaid_buy_item_button_widget', $button, $item ); |
|
| 165 | + protected function buy_item_button($item, $button) { |
|
| 166 | + $button = getpaid_get_payment_button($button, null, $item); |
|
| 167 | + return apply_filters('getpaid_buy_item_button_widget', $button, $item); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | } |
@@ -13,58 +13,58 @@ discard block |
||
| 13 | 13 | class GetPaid_Authorize_Net_Gateway extends GetPaid_Authorize_Net_Legacy_Gateway { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Payment method id. |
|
| 17 | - * |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 16 | + * Payment method id. |
|
| 17 | + * |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | 20 | public $id = 'authorizenet'; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * An array of features that this gateway supports. |
|
| 24 | - * |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 23 | + * An array of features that this gateway supports. |
|
| 24 | + * |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | 27 | protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons' ); |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * Payment method order. |
|
| 31 | - * |
|
| 32 | - * @var int |
|
| 33 | - */ |
|
| 30 | + * Payment method order. |
|
| 31 | + * |
|
| 32 | + * @var int |
|
| 33 | + */ |
|
| 34 | 34 | public $order = 4; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Endpoint for requests from Authorize.net. |
|
| 38 | - * |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - protected $notify_url; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Endpoint for requests to Authorize.net. |
|
| 45 | - * |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 37 | + * Endpoint for requests from Authorize.net. |
|
| 38 | + * |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + protected $notify_url; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Endpoint for requests to Authorize.net. |
|
| 45 | + * |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | 48 | protected $endpoint; |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * Currencies this gateway is allowed for. |
|
| 52 | - * |
|
| 53 | - * @var array |
|
| 54 | - */ |
|
| 55 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
| 51 | + * Currencies this gateway is allowed for. |
|
| 52 | + * |
|
| 53 | + * @var array |
|
| 54 | + */ |
|
| 55 | + public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * URL to view a transaction. |
|
| 59 | - * |
|
| 60 | - * @var string |
|
| 61 | - */ |
|
| 58 | + * URL to view a transaction. |
|
| 59 | + * |
|
| 60 | + * @var string |
|
| 61 | + */ |
|
| 62 | 62 | public $view_transaction_url = 'https://{sandbox}authorize.net/ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=%s'; |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | - * Class constructor. |
|
| 66 | - */ |
|
| 67 | - public function __construct() { |
|
| 65 | + * Class constructor. |
|
| 66 | + */ |
|
| 67 | + public function __construct() { |
|
| 68 | 68 | |
| 69 | 69 | $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
| 70 | 70 | $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * Displays the payment method select field. |
|
| 80 | - * |
|
| 81 | - * @param int $invoice_id 0 or invoice id. |
|
| 82 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
| 83 | - */ |
|
| 79 | + * Displays the payment method select field. |
|
| 80 | + * |
|
| 81 | + * @param int $invoice_id 0 or invoice id. |
|
| 82 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
| 83 | + */ |
|
| 84 | 84 | public function payment_fields( $invoice_id, $form ) { |
| 85 | 85 | |
| 86 | 86 | // Let the user select a payment method. |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | - * Creates a customer profile. |
|
| 95 | - * |
|
| 96 | - * |
|
| 97 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 94 | + * Creates a customer profile. |
|
| 95 | + * |
|
| 96 | + * |
|
| 97 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 98 | 98 | * @param array $submission_data Posted checkout fields. |
| 99 | 99 | * @param bool $save Whether or not to save the payment as a token. |
| 100 | 100 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
| 101 | - * @return string|WP_Error Payment profile id. |
|
| 102 | - */ |
|
| 103 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
| 101 | + * @return string|WP_Error Payment profile id. |
|
| 102 | + */ |
|
| 103 | + public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
| 104 | 104 | |
| 105 | 105 | // Remove non-digits from the number |
| 106 | 106 | $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | - * Retrieves a customer profile. |
|
| 171 | - * |
|
| 172 | - * |
|
| 173 | - * @param string $profile_id profile id. |
|
| 174 | - * @return string|WP_Error Profile id. |
|
| 170 | + * Retrieves a customer profile. |
|
| 171 | + * |
|
| 172 | + * |
|
| 173 | + * @param string $profile_id profile id. |
|
| 174 | + * @return string|WP_Error Profile id. |
|
| 175 | 175 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
| 176 | - */ |
|
| 177 | - public function get_customer_profile( $profile_id ) { |
|
| 176 | + */ |
|
| 177 | + public function get_customer_profile( $profile_id ) { |
|
| 178 | 178 | |
| 179 | 179 | // Generate args. |
| 180 | 180 | $args = array( |
@@ -189,17 +189,17 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | - * Creates a customer profile. |
|
| 193 | - * |
|
| 194 | - * |
|
| 192 | + * Creates a customer profile. |
|
| 193 | + * |
|
| 194 | + * |
|
| 195 | 195 | * @param string $profile_id profile id. |
| 196 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 196 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 197 | 197 | * @param array $submission_data Posted checkout fields. |
| 198 | 198 | * @param bool $save Whether or not to save the payment as a token. |
| 199 | 199 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
| 200 | - * @return string|WP_Error Profile id. |
|
| 201 | - */ |
|
| 202 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
| 200 | + * @return string|WP_Error Profile id. |
|
| 201 | + */ |
|
| 202 | + public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
| 203 | 203 | |
| 204 | 204 | // Remove non-digits from the number |
| 205 | 205 | $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
@@ -259,15 +259,15 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | - * Retrieves a customer payment profile. |
|
| 263 | - * |
|
| 264 | - * |
|
| 265 | - * @param string $customer_profile_id customer profile id. |
|
| 262 | + * Retrieves a customer payment profile. |
|
| 263 | + * |
|
| 264 | + * |
|
| 265 | + * @param string $customer_profile_id customer profile id. |
|
| 266 | 266 | * @param string $payment_profile_id payment profile id. |
| 267 | - * @return string|WP_Error Profile id. |
|
| 267 | + * @return string|WP_Error Profile id. |
|
| 268 | 268 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
| 269 | - */ |
|
| 270 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
| 269 | + */ |
|
| 270 | + public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
| 271 | 271 | |
| 272 | 272 | // Generate args. |
| 273 | 273 | $args = array( |
@@ -283,15 +283,15 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | - * Charges a customer payment profile. |
|
| 287 | - * |
|
| 286 | + * Charges a customer payment profile. |
|
| 287 | + * |
|
| 288 | 288 | * @param string $customer_profile_id customer profile id. |
| 289 | 289 | * @param string $payment_profile_id payment profile id. |
| 290 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 290 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 291 | 291 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
| 292 | - * @return WP_Error|object |
|
| 293 | - */ |
|
| 294 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
| 292 | + * @return WP_Error|object |
|
| 293 | + */ |
|
| 294 | + public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
| 295 | 295 | |
| 296 | 296 | // Generate args. |
| 297 | 297 | $args = array( |
@@ -337,41 +337,41 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /** |
| 340 | - * Processes a customer charge. |
|
| 341 | - * |
|
| 340 | + * Processes a customer charge. |
|
| 341 | + * |
|
| 342 | 342 | * @param stdClass $result Api response. |
| 343 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 344 | - */ |
|
| 345 | - public function process_charge_response( $result, $invoice ) { |
|
| 343 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 344 | + */ |
|
| 345 | + public function process_charge_response( $result, $invoice ) { |
|
| 346 | 346 | |
| 347 | 347 | wpinv_clear_errors(); |
| 348 | - $response_code = (int) $result->transactionResponse->responseCode; |
|
| 348 | + $response_code = (int) $result->transactionResponse->responseCode; |
|
| 349 | 349 | |
| 350 | - // Succeeded. |
|
| 351 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
| 350 | + // Succeeded. |
|
| 351 | + if ( 1 == $response_code || 4 == $response_code ) { |
|
| 352 | 352 | |
| 353 | - // Maybe set a transaction id. |
|
| 354 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
| 355 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
| 356 | - } |
|
| 353 | + // Maybe set a transaction id. |
|
| 354 | + if ( ! empty( $result->transactionResponse->transId ) ) { |
|
| 355 | + $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | - $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
| 358 | + $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
| 359 | 359 | |
| 360 | - if ( 1 == $response_code ) { |
|
| 361 | - return $invoice->mark_paid(); |
|
| 362 | - } |
|
| 360 | + if ( 1 == $response_code ) { |
|
| 361 | + return $invoice->mark_paid(); |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - $invoice->set_status( 'wpi-onhold' ); |
|
| 365 | - $invoice->add_note( |
|
| 364 | + $invoice->set_status( 'wpi-onhold' ); |
|
| 365 | + $invoice->add_note( |
|
| 366 | 366 | sprintf( |
| 367 | 367 | __( 'Held for review: %s', 'invoicing' ), |
| 368 | 368 | $result->transactionResponse->messages->message[0]->description |
| 369 | 369 | ) |
| 370 | - ); |
|
| 370 | + ); |
|
| 371 | 371 | |
| 372 | - return $invoice->save(); |
|
| 372 | + return $invoice->save(); |
|
| 373 | 373 | |
| 374 | - } |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | 376 | wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) ); |
| 377 | 377 | |
@@ -383,13 +383,13 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
| 386 | - * Returns payment information. |
|
| 387 | - * |
|
| 388 | - * |
|
| 389 | - * @param array $card Card details. |
|
| 390 | - * @return array |
|
| 391 | - */ |
|
| 392 | - public function get_payment_information( $card ) { |
|
| 386 | + * Returns payment information. |
|
| 387 | + * |
|
| 388 | + * |
|
| 389 | + * @param array $card Card details. |
|
| 390 | + * @return array |
|
| 391 | + */ |
|
| 392 | + public function get_payment_information( $card ) { |
|
| 393 | 393 | return array( |
| 394 | 394 | |
| 395 | 395 | 'creditCard' => array ( |
@@ -402,25 +402,25 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
| 405 | - * Returns the customer profile meta name. |
|
| 406 | - * |
|
| 407 | - * |
|
| 408 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 409 | - * @return string |
|
| 410 | - */ |
|
| 411 | - public function get_customer_profile_meta_name( $invoice ) { |
|
| 405 | + * Returns the customer profile meta name. |
|
| 406 | + * |
|
| 407 | + * |
|
| 408 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 409 | + * @return string |
|
| 410 | + */ |
|
| 411 | + public function get_customer_profile_meta_name( $invoice ) { |
|
| 412 | 412 | return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
| 416 | - * Validates the submitted data. |
|
| 417 | - * |
|
| 418 | - * |
|
| 419 | - * @param array $submission_data Posted checkout fields. |
|
| 416 | + * Validates the submitted data. |
|
| 417 | + * |
|
| 418 | + * |
|
| 419 | + * @param array $submission_data Posted checkout fields. |
|
| 420 | 420 | * @param WPInv_Invoice $invoice |
| 421 | - * @return WP_Error|string The payment profile id |
|
| 422 | - */ |
|
| 423 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
| 421 | + * @return WP_Error|string The payment profile id |
|
| 422 | + */ |
|
| 423 | + public function validate_submission_data( $submission_data, $invoice ) { |
|
| 424 | 424 | |
| 425 | 425 | // Validate authentication details. |
| 426 | 426 | $auth = $this->get_auth_params(); |
@@ -452,13 +452,13 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
| 455 | - * Returns invoice line items. |
|
| 456 | - * |
|
| 457 | - * |
|
| 458 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 459 | - * @return array |
|
| 460 | - */ |
|
| 461 | - public function get_line_items( $invoice ) { |
|
| 455 | + * Returns invoice line items. |
|
| 456 | + * |
|
| 457 | + * |
|
| 458 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 459 | + * @return array |
|
| 460 | + */ |
|
| 461 | + public function get_line_items( $invoice ) { |
|
| 462 | 462 | $items = array(); |
| 463 | 463 | |
| 464 | 464 | foreach ( $invoice->get_items() as $item ) { |
@@ -496,15 +496,15 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | /** |
| 499 | - * Process Payment. |
|
| 500 | - * |
|
| 501 | - * |
|
| 502 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 503 | - * @param array $submission_data Posted checkout fields. |
|
| 504 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 505 | - * @return array |
|
| 506 | - */ |
|
| 507 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 499 | + * Process Payment. |
|
| 500 | + * |
|
| 501 | + * |
|
| 502 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 503 | + * @param array $submission_data Posted checkout fields. |
|
| 504 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 505 | + * @return array |
|
| 506 | + */ |
|
| 507 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 508 | 508 | |
| 509 | 509 | // Validate the submitted data. |
| 510 | 510 | $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
@@ -537,69 +537,69 @@ discard block |
||
| 537 | 537 | |
| 538 | 538 | exit; |
| 539 | 539 | |
| 540 | - } |
|
| 540 | + } |
|
| 541 | 541 | |
| 542 | - /** |
|
| 543 | - * Processes the initial payment. |
|
| 544 | - * |
|
| 542 | + /** |
|
| 543 | + * Processes the initial payment. |
|
| 544 | + * |
|
| 545 | 545 | * @param WPInv_Invoice $invoice Invoice. |
| 546 | - */ |
|
| 547 | - protected function process_initial_payment( $invoice ) { |
|
| 546 | + */ |
|
| 547 | + protected function process_initial_payment( $invoice ) { |
|
| 548 | 548 | |
| 549 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 549 | + $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 550 | 550 | $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
| 551 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
| 551 | + $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
| 552 | 552 | |
| 553 | - // Do we have an error? |
|
| 554 | - if ( is_wp_error( $result ) ) { |
|
| 555 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
| 556 | - wpinv_send_back_to_checkout( $invoice ); |
|
| 557 | - } |
|
| 553 | + // Do we have an error? |
|
| 554 | + if ( is_wp_error( $result ) ) { |
|
| 555 | + wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
| 556 | + wpinv_send_back_to_checkout( $invoice ); |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - // Process the response. |
|
| 560 | - $this->process_charge_response( $result, $invoice ); |
|
| 559 | + // Process the response. |
|
| 560 | + $this->process_charge_response( $result, $invoice ); |
|
| 561 | 561 | |
| 562 | - if ( wpinv_get_errors() ) { |
|
| 563 | - wpinv_send_back_to_checkout( $invoice ); |
|
| 564 | - } |
|
| 562 | + if ( wpinv_get_errors() ) { |
|
| 563 | + wpinv_send_back_to_checkout( $invoice ); |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - } |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | 568 | /** |
| 569 | - * Processes recurring payments. |
|
| 570 | - * |
|
| 569 | + * Processes recurring payments. |
|
| 570 | + * |
|
| 571 | 571 | * @param WPInv_Invoice $invoice Invoice. |
| 572 | 572 | * @param WPInv_Subscription $subscription Subscription. |
| 573 | - */ |
|
| 574 | - public function process_subscription( $invoice, $subscription ) { |
|
| 573 | + */ |
|
| 574 | + public function process_subscription( $invoice, $subscription ) { |
|
| 575 | 575 | |
| 576 | 576 | // Check if there is an initial amount to charge. |
| 577 | 577 | if ( (float) $invoice->get_total() > 0 ) { |
| 578 | - $this->process_initial_payment( $invoice ); |
|
| 578 | + $this->process_initial_payment( $invoice ); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | // Activate the subscription. |
| 582 | 582 | $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
| 583 | 583 | $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
| 584 | 584 | |
| 585 | - $subscription->set_next_renewal_date( $expiry ); |
|
| 586 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 587 | - $subscription->set_profile_id( $invoice->generate_key() ); |
|
| 588 | - $subscription->activate(); |
|
| 585 | + $subscription->set_next_renewal_date( $expiry ); |
|
| 586 | + $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 587 | + $subscription->set_profile_id( $invoice->generate_key() ); |
|
| 588 | + $subscription->activate(); |
|
| 589 | 589 | |
| 590 | - // Redirect to the success page. |
|
| 590 | + // Redirect to the success page. |
|
| 591 | 591 | wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
| 592 | 592 | |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - /** |
|
| 596 | - * (Maybe) renews an authorize.net subscription profile. |
|
| 597 | - * |
|
| 598 | - * |
|
| 599 | - * @param bool $should_expire |
|
| 595 | + /** |
|
| 596 | + * (Maybe) renews an authorize.net subscription profile. |
|
| 597 | + * |
|
| 598 | + * |
|
| 599 | + * @param bool $should_expire |
|
| 600 | 600 | * @param WPInv_Subscription $subscription |
| 601 | - */ |
|
| 602 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
| 601 | + */ |
|
| 602 | + public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
| 603 | 603 | |
| 604 | 604 | // Ensure its our subscription && it's active. |
| 605 | 605 | if ( $this->id != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
@@ -616,18 +616,18 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | return false; |
| 618 | 618 | |
| 619 | - } |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | 621 | /** |
| 622 | - * Renews a subscription. |
|
| 623 | - * |
|
| 622 | + * Renews a subscription. |
|
| 623 | + * |
|
| 624 | 624 | * @param WPInv_Subscription $subscription |
| 625 | - */ |
|
| 626 | - public function renew_subscription( $subscription ) { |
|
| 625 | + */ |
|
| 626 | + public function renew_subscription( $subscription ) { |
|
| 627 | 627 | |
| 628 | - // Generate the renewal invoice. |
|
| 629 | - $new_invoice = $subscription->create_payment(); |
|
| 630 | - $old_invoice = $subscription->get_parent_payment(); |
|
| 628 | + // Generate the renewal invoice. |
|
| 629 | + $new_invoice = $subscription->create_payment(); |
|
| 630 | + $old_invoice = $subscription->get_parent_payment(); |
|
| 631 | 631 | |
| 632 | 632 | if ( empty( $new_invoice ) ) { |
| 633 | 633 | $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
@@ -636,37 +636,37 @@ discard block |
||
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | // Charge the payment method. |
| 639 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 640 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
| 641 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
| 642 | - |
|
| 643 | - // Do we have an error? |
|
| 644 | - if ( is_wp_error( $result ) ) { |
|
| 645 | - |
|
| 646 | - $old_invoice->add_note( |
|
| 647 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
| 648 | - true, |
|
| 649 | - false, |
|
| 650 | - true |
|
| 651 | - ); |
|
| 652 | - $subscription->failing(); |
|
| 653 | - return; |
|
| 654 | - |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - // Process the response. |
|
| 658 | - $this->process_charge_response( $result, $new_invoice ); |
|
| 659 | - |
|
| 660 | - if ( wpinv_get_errors() ) { |
|
| 661 | - |
|
| 662 | - $old_invoice->add_note( |
|
| 663 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
| 664 | - true, |
|
| 665 | - false, |
|
| 666 | - true |
|
| 667 | - ); |
|
| 668 | - $subscription->failing(); |
|
| 669 | - return; |
|
| 639 | + $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 640 | + $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
| 641 | + $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
| 642 | + |
|
| 643 | + // Do we have an error? |
|
| 644 | + if ( is_wp_error( $result ) ) { |
|
| 645 | + |
|
| 646 | + $old_invoice->add_note( |
|
| 647 | + sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
| 648 | + true, |
|
| 649 | + false, |
|
| 650 | + true |
|
| 651 | + ); |
|
| 652 | + $subscription->failing(); |
|
| 653 | + return; |
|
| 654 | + |
|
| 655 | + } |
|
| 656 | + |
|
| 657 | + // Process the response. |
|
| 658 | + $this->process_charge_response( $result, $new_invoice ); |
|
| 659 | + |
|
| 660 | + if ( wpinv_get_errors() ) { |
|
| 661 | + |
|
| 662 | + $old_invoice->add_note( |
|
| 663 | + sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
| 664 | + true, |
|
| 665 | + false, |
|
| 666 | + true |
|
| 667 | + ); |
|
| 668 | + $subscription->failing(); |
|
| 669 | + return; |
|
| 670 | 670 | |
| 671 | 671 | } |
| 672 | 672 | |
@@ -675,13 +675,13 @@ discard block |
||
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | /** |
| 678 | - * Processes invoice addons. |
|
| 679 | - * |
|
| 680 | - * @param WPInv_Invoice $invoice |
|
| 681 | - * @param GetPaid_Form_Item[] $items |
|
| 682 | - * @return WPInv_Invoice |
|
| 683 | - */ |
|
| 684 | - public function process_addons( $invoice, $items ) { |
|
| 678 | + * Processes invoice addons. |
|
| 679 | + * |
|
| 680 | + * @param WPInv_Invoice $invoice |
|
| 681 | + * @param GetPaid_Form_Item[] $items |
|
| 682 | + * @return WPInv_Invoice |
|
| 683 | + */ |
|
| 684 | + public function process_addons( $invoice, $items ) { |
|
| 685 | 685 | |
| 686 | 686 | global $getpaid_authorize_addons; |
| 687 | 687 | |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | $invoice->recalculate_total(); |
| 702 | 702 | |
| 703 | 703 | $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
| 704 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
| 704 | + $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
| 705 | 705 | |
| 706 | 706 | add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
| 707 | 707 | $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
@@ -716,11 +716,11 @@ discard block |
||
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | /** |
| 719 | - * Processes invoice addons. |
|
| 720 | - * |
|
| 719 | + * Processes invoice addons. |
|
| 720 | + * |
|
| 721 | 721 | * @param array $args |
| 722 | - * @return array |
|
| 723 | - */ |
|
| 722 | + * @return array |
|
| 723 | + */ |
|
| 724 | 724 | public function filter_addons_request( $args ) { |
| 725 | 725 | |
| 726 | 726 | global $getpaid_authorize_addons; |
@@ -754,11 +754,11 @@ discard block |
||
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /** |
| 757 | - * Filters the gateway settings. |
|
| 758 | - * |
|
| 759 | - * @param array $admin_settings |
|
| 760 | - */ |
|
| 761 | - public function admin_settings( $admin_settings ) { |
|
| 757 | + * Filters the gateway settings. |
|
| 758 | + * |
|
| 759 | + * @param array $admin_settings |
|
| 760 | + */ |
|
| 761 | + public function admin_settings( $admin_settings ) { |
|
| 762 | 762 | |
| 763 | 763 | $currencies = sprintf( |
| 764 | 764 | __( 'Supported Currencies: %s', 'invoicing' ), |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | 'readonly' => true, |
| 799 | 799 | ); |
| 800 | 800 | |
| 801 | - return $admin_settings; |
|
| 802 | - } |
|
| 801 | + return $admin_settings; |
|
| 802 | + } |
|
| 803 | 803 | |
| 804 | 804 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Authorize.net Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons' ); |
|
| 27 | + protected $supports = array('subscription', 'sandbox', 'tokens', 'addons'); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Payment method order. |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @var array |
| 54 | 54 | */ |
| 55 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
| 55 | + public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD'); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * URL to view a transaction. |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function __construct() { |
| 68 | 68 | |
| 69 | - $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
|
| 70 | - $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
|
| 71 | - $this->notify_url = wpinv_get_ipn_url( $this->id ); |
|
| 69 | + $this->title = __('Credit Card / Debit Card', 'invoicing'); |
|
| 70 | + $this->method_title = __('Authorize.Net', 'invoicing'); |
|
| 71 | + $this->notify_url = wpinv_get_ipn_url($this->id); |
|
| 72 | 72 | |
| 73 | - add_filter( 'getpaid_daily_maintenance_should_expire_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 ); |
|
| 74 | - add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
| 73 | + add_filter('getpaid_daily_maintenance_should_expire_subscription', array($this, 'maybe_renew_subscription'), 10, 2); |
|
| 74 | + add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice')); |
|
| 75 | 75 | parent::__construct(); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | * @param int $invoice_id 0 or invoice id. |
| 82 | 82 | * @param GetPaid_Payment_Form $form Current payment form. |
| 83 | 83 | */ |
| 84 | - public function payment_fields( $invoice_id, $form ) { |
|
| 84 | + public function payment_fields($invoice_id, $form) { |
|
| 85 | 85 | |
| 86 | 86 | // Let the user select a payment method. |
| 87 | 87 | echo $this->saved_payment_methods(); |
| 88 | 88 | |
| 89 | 89 | // Show the credit card entry form. |
| 90 | - echo $this->new_payment_method_entry( $this->get_cc_form( true ) ); |
|
| 90 | + echo $this->new_payment_method_entry($this->get_cc_form(true)); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -100,64 +100,64 @@ discard block |
||
| 100 | 100 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
| 101 | 101 | * @return string|WP_Error Payment profile id. |
| 102 | 102 | */ |
| 103 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
| 103 | + public function create_customer_profile($invoice, $submission_data, $save = true) { |
|
| 104 | 104 | |
| 105 | 105 | // Remove non-digits from the number |
| 106 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
| 106 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
| 107 | 107 | |
| 108 | 108 | // Generate args. |
| 109 | 109 | $args = array( |
| 110 | 110 | 'createCustomerProfileRequest' => array( |
| 111 | 111 | 'merchantAuthentication' => $this->get_auth_params(), |
| 112 | 112 | 'profile' => array( |
| 113 | - 'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ), |
|
| 114 | - 'description' => getpaid_limit_length( $invoice->get_full_name(), 255 ), |
|
| 115 | - 'email' => getpaid_limit_length( $invoice->get_email(), 255 ), |
|
| 113 | + 'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20), |
|
| 114 | + 'description' => getpaid_limit_length($invoice->get_full_name(), 255), |
|
| 115 | + 'email' => getpaid_limit_length($invoice->get_email(), 255), |
|
| 116 | 116 | 'paymentProfiles' => array( |
| 117 | 117 | 'customerType' => 'individual', |
| 118 | 118 | |
| 119 | 119 | // Billing information. |
| 120 | 120 | 'billTo' => array( |
| 121 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
| 122 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
| 123 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
| 124 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
| 125 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
| 126 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
| 127 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
| 121 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
| 122 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
| 123 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
| 124 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
| 125 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
| 126 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
| 127 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
| 128 | 128 | ), |
| 129 | 129 | |
| 130 | 130 | // Payment information. |
| 131 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ), |
|
| 131 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']), |
|
| 132 | 132 | ) |
| 133 | 133 | ), |
| 134 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
| 134 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
| 135 | 135 | ) |
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice ); |
|
| 138 | + $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice); |
|
| 139 | 139 | |
| 140 | - if ( is_wp_error( $response ) ) { |
|
| 140 | + if (is_wp_error($response)) { |
|
| 141 | 141 | return $response; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId ); |
|
| 144 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId); |
|
| 145 | 145 | |
| 146 | 146 | // Save the payment token. |
| 147 | - if ( $save ) { |
|
| 147 | + if ($save) { |
|
| 148 | 148 | $this->save_token( |
| 149 | 149 | array( |
| 150 | 150 | 'id' => $response->customerPaymentProfileIdList[0], |
| 151 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
| 151 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
| 152 | 152 | 'default' => true, |
| 153 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
| 153 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
| 154 | 154 | ) |
| 155 | 155 | ); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Add a note about the validation response. |
| 159 | 159 | $invoice->add_note( |
| 160 | - sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ), |
|
| 160 | + sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]), |
|
| 161 | 161 | false, |
| 162 | 162 | false, |
| 163 | 163 | true |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * @return string|WP_Error Profile id. |
| 175 | 175 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
| 176 | 176 | */ |
| 177 | - public function get_customer_profile( $profile_id ) { |
|
| 177 | + public function get_customer_profile($profile_id) { |
|
| 178 | 178 | |
| 179 | 179 | // Generate args. |
| 180 | 180 | $args = array( |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | ) |
| 185 | 185 | ); |
| 186 | 186 | |
| 187 | - return $this->post( $args, false ); |
|
| 187 | + return $this->post($args, false); |
|
| 188 | 188 | |
| 189 | 189 | } |
| 190 | 190 | |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
| 200 | 200 | * @return string|WP_Error Profile id. |
| 201 | 201 | */ |
| 202 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
| 202 | + public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) { |
|
| 203 | 203 | |
| 204 | 204 | // Remove non-digits from the number |
| 205 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
| 205 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
| 206 | 206 | |
| 207 | 207 | // Generate args. |
| 208 | 208 | $args = array( |
@@ -213,34 +213,34 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | // Billing information. |
| 215 | 215 | 'billTo' => array( |
| 216 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
| 217 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
| 218 | - 'address' => getpaid_limit_length( $invoice->get_last_name(), 60 ), |
|
| 219 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
| 220 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
| 221 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
| 222 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
| 216 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
| 217 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
| 218 | + 'address' => getpaid_limit_length($invoice->get_last_name(), 60), |
|
| 219 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
| 220 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
| 221 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
| 222 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
| 223 | 223 | ), |
| 224 | 224 | |
| 225 | 225 | // Payment information. |
| 226 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ) |
|
| 226 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']) |
|
| 227 | 227 | ), |
| 228 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
| 228 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
| 229 | 229 | ) |
| 230 | 230 | ); |
| 231 | 231 | |
| 232 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
| 232 | + $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice); |
|
| 233 | 233 | |
| 234 | - if ( is_wp_error( $response ) ) { |
|
| 234 | + if (is_wp_error($response)) { |
|
| 235 | 235 | return $response; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // Save the payment token. |
| 239 | - if ( $save ) { |
|
| 239 | + if ($save) { |
|
| 240 | 240 | $this->save_token( |
| 241 | 241 | array( |
| 242 | 242 | 'id' => $response->customerPaymentProfileId, |
| 243 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
| 243 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
| 244 | 244 | 'default' => true |
| 245 | 245 | ) |
| 246 | 246 | ); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | // Add a note about the validation response. |
| 250 | 250 | $invoice->add_note( |
| 251 | - sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ), |
|
| 251 | + sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse), |
|
| 252 | 252 | false, |
| 253 | 253 | false, |
| 254 | 254 | true |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * @return string|WP_Error Profile id. |
| 268 | 268 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
| 269 | 269 | */ |
| 270 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
| 270 | + public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) { |
|
| 271 | 271 | |
| 272 | 272 | // Generate args. |
| 273 | 273 | $args = array( |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | ) |
| 279 | 279 | ); |
| 280 | 280 | |
| 281 | - return $this->post( $args, false ); |
|
| 281 | + return $this->post($args, false); |
|
| 282 | 282 | |
| 283 | 283 | } |
| 284 | 284 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
| 292 | 292 | * @return WP_Error|object |
| 293 | 293 | */ |
| 294 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
| 294 | + public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) { |
|
| 295 | 295 | |
| 296 | 296 | // Generate args. |
| 297 | 297 | $args = array( |
@@ -311,28 +311,28 @@ discard block |
||
| 311 | 311 | ) |
| 312 | 312 | ), |
| 313 | 313 | 'order' => array( |
| 314 | - 'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ), |
|
| 314 | + 'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20), |
|
| 315 | 315 | ), |
| 316 | - 'lineItems' => array( 'lineItem' => $this->get_line_items( $invoice ) ), |
|
| 316 | + 'lineItems' => array('lineItem' => $this->get_line_items($invoice)), |
|
| 317 | 317 | 'tax' => array( |
| 318 | 318 | 'amount' => $invoice->get_total_tax(), |
| 319 | - 'name' => __( 'TAX', 'invoicing' ), |
|
| 319 | + 'name' => __('TAX', 'invoicing'), |
|
| 320 | 320 | ), |
| 321 | - 'poNumber' => getpaid_limit_length( $invoice->get_number(), 25 ), |
|
| 321 | + 'poNumber' => getpaid_limit_length($invoice->get_number(), 25), |
|
| 322 | 322 | 'customer' => array( |
| 323 | - 'id' => getpaid_limit_length( $invoice->get_user_id(), 25 ), |
|
| 324 | - 'email' => getpaid_limit_length( $invoice->get_email(), 25 ), |
|
| 323 | + 'id' => getpaid_limit_length($invoice->get_user_id(), 25), |
|
| 324 | + 'email' => getpaid_limit_length($invoice->get_email(), 25), |
|
| 325 | 325 | ), |
| 326 | 326 | 'customerIP' => $invoice->get_ip(), |
| 327 | 327 | ) |
| 328 | 328 | ) |
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | - if ( 0 == $invoice->get_total_tax() ) { |
|
| 332 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
| 331 | + if (0 == $invoice->get_total_tax()) { |
|
| 332 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
| 335 | + return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice); |
|
| 336 | 336 | |
| 337 | 337 | } |
| 338 | 338 | |
@@ -342,29 +342,29 @@ discard block |
||
| 342 | 342 | * @param stdClass $result Api response. |
| 343 | 343 | * @param WPInv_Invoice $invoice Invoice. |
| 344 | 344 | */ |
| 345 | - public function process_charge_response( $result, $invoice ) { |
|
| 345 | + public function process_charge_response($result, $invoice) { |
|
| 346 | 346 | |
| 347 | 347 | wpinv_clear_errors(); |
| 348 | 348 | $response_code = (int) $result->transactionResponse->responseCode; |
| 349 | 349 | |
| 350 | 350 | // Succeeded. |
| 351 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
| 351 | + if (1 == $response_code || 4 == $response_code) { |
|
| 352 | 352 | |
| 353 | 353 | // Maybe set a transaction id. |
| 354 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
| 355 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
| 354 | + if (!empty($result->transactionResponse->transId)) { |
|
| 355 | + $invoice->set_transaction_id($result->transactionResponse->transId); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
| 358 | + $invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true); |
|
| 359 | 359 | |
| 360 | - if ( 1 == $response_code ) { |
|
| 360 | + if (1 == $response_code) { |
|
| 361 | 361 | return $invoice->mark_paid(); |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - $invoice->set_status( 'wpi-onhold' ); |
|
| 364 | + $invoice->set_status('wpi-onhold'); |
|
| 365 | 365 | $invoice->add_note( |
| 366 | 366 | sprintf( |
| 367 | - __( 'Held for review: %s', 'invoicing' ), |
|
| 367 | + __('Held for review: %s', 'invoicing'), |
|
| 368 | 368 | $result->transactionResponse->messages->message[0]->description |
| 369 | 369 | ) |
| 370 | 370 | ); |
@@ -373,11 +373,11 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) ); |
|
| 376 | + wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing')); |
|
| 377 | 377 | |
| 378 | - if ( ! empty( $result->transactionResponse->errors ) ) { |
|
| 378 | + if (!empty($result->transactionResponse->errors)) { |
|
| 379 | 379 | $errors = (object) $result->transactionResponse->errors; |
| 380 | - wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) ); |
|
| 380 | + wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText)); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | } |
@@ -389,10 +389,10 @@ discard block |
||
| 389 | 389 | * @param array $card Card details. |
| 390 | 390 | * @return array |
| 391 | 391 | */ |
| 392 | - public function get_payment_information( $card ) { |
|
| 392 | + public function get_payment_information($card) { |
|
| 393 | 393 | return array( |
| 394 | 394 | |
| 395 | - 'creditCard' => array ( |
|
| 395 | + 'creditCard' => array( |
|
| 396 | 396 | 'cardNumber' => $card['cc_number'], |
| 397 | 397 | 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'], |
| 398 | 398 | 'cardCode' => $card['cc_cvv2'], |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | * @param WPInv_Invoice $invoice Invoice. |
| 409 | 409 | * @return string |
| 410 | 410 | */ |
| 411 | - public function get_customer_profile_meta_name( $invoice ) { |
|
| 412 | - return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
| 411 | + public function get_customer_profile_meta_name($invoice) { |
|
| 412 | + return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
@@ -420,34 +420,34 @@ discard block |
||
| 420 | 420 | * @param WPInv_Invoice $invoice |
| 421 | 421 | * @return WP_Error|string The payment profile id |
| 422 | 422 | */ |
| 423 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
| 423 | + public function validate_submission_data($submission_data, $invoice) { |
|
| 424 | 424 | |
| 425 | 425 | // Validate authentication details. |
| 426 | 426 | $auth = $this->get_auth_params(); |
| 427 | 427 | |
| 428 | - if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) { |
|
| 429 | - return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing') ); |
|
| 428 | + if (empty($auth['name']) || empty($auth['transactionKey'])) { |
|
| 429 | + return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing')); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | // Validate the payment method. |
| 433 | - if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) { |
|
| 434 | - return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') ); |
|
| 433 | + if (empty($submission_data['getpaid-authorizenet-payment-method'])) { |
|
| 434 | + return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing')); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | // Are we adding a new payment method? |
| 438 | - if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) { |
|
| 438 | + if ('new' != $submission_data['getpaid-authorizenet-payment-method']) { |
|
| 439 | 439 | return $submission_data['getpaid-authorizenet-payment-method']; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | // Retrieve the customer profile id. |
| 443 | - $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
| 443 | + $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
| 444 | 444 | |
| 445 | 445 | // Create payment method. |
| 446 | - if ( empty( $profile_id ) ) { |
|
| 447 | - return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
| 446 | + if (empty($profile_id)) { |
|
| 447 | + return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
| 450 | + return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
| 451 | 451 | |
| 452 | 452 | } |
| 453 | 453 | |
@@ -458,16 +458,16 @@ discard block |
||
| 458 | 458 | * @param WPInv_Invoice $invoice Invoice. |
| 459 | 459 | * @return array |
| 460 | 460 | */ |
| 461 | - public function get_line_items( $invoice ) { |
|
| 461 | + public function get_line_items($invoice) { |
|
| 462 | 462 | $items = array(); |
| 463 | 463 | |
| 464 | - foreach ( $invoice->get_items() as $item ) { |
|
| 464 | + foreach ($invoice->get_items() as $item) { |
|
| 465 | 465 | |
| 466 | 466 | $amount = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
| 467 | 467 | $items[] = array( |
| 468 | - 'itemId' => getpaid_limit_length( $item->get_id(), 31 ), |
|
| 469 | - 'name' => getpaid_limit_length( $item->get_raw_name(), 31 ), |
|
| 470 | - 'description' => getpaid_limit_length( $item->get_description(), 255 ), |
|
| 468 | + 'itemId' => getpaid_limit_length($item->get_id(), 31), |
|
| 469 | + 'name' => getpaid_limit_length($item->get_raw_name(), 31), |
|
| 470 | + 'description' => getpaid_limit_length($item->get_description(), 255), |
|
| 471 | 471 | 'quantity' => (string) $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(), |
| 472 | 472 | 'unitPrice' => (float) $amount, |
| 473 | 473 | 'taxable' => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(), |
@@ -475,15 +475,15 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - foreach ( $invoice->get_fees() as $fee_name => $fee ) { |
|
| 478 | + foreach ($invoice->get_fees() as $fee_name => $fee) { |
|
| 479 | 479 | |
| 480 | - $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
| 480 | + $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
| 481 | 481 | |
| 482 | - if ( $amount > 0 ) { |
|
| 482 | + if ($amount > 0) { |
|
| 483 | 483 | $items[] = array( |
| 484 | - 'itemId' => getpaid_limit_length( $fee_name, 31 ), |
|
| 485 | - 'name' => getpaid_limit_length( $fee_name, 31 ), |
|
| 486 | - 'description' => getpaid_limit_length( $fee_name, 255 ), |
|
| 484 | + 'itemId' => getpaid_limit_length($fee_name, 31), |
|
| 485 | + 'name' => getpaid_limit_length($fee_name, 31), |
|
| 486 | + 'description' => getpaid_limit_length($fee_name, 255), |
|
| 487 | 487 | 'quantity' => '1', |
| 488 | 488 | 'unitPrice' => (float) $amount, |
| 489 | 489 | 'taxable' => false, |
@@ -504,36 +504,36 @@ discard block |
||
| 504 | 504 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 505 | 505 | * @return array |
| 506 | 506 | */ |
| 507 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 507 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 508 | 508 | |
| 509 | 509 | // Validate the submitted data. |
| 510 | - $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
|
| 510 | + $payment_profile_id = $this->validate_submission_data($submission_data, $invoice); |
|
| 511 | 511 | |
| 512 | 512 | // Do we have an error? |
| 513 | - if ( is_wp_error( $payment_profile_id ) ) { |
|
| 514 | - wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() ); |
|
| 515 | - wpinv_send_back_to_checkout( $invoice ); |
|
| 513 | + if (is_wp_error($payment_profile_id)) { |
|
| 514 | + wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message()); |
|
| 515 | + wpinv_send_back_to_checkout($invoice); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | // Save the payment method to the order. |
| 519 | - update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id ); |
|
| 519 | + update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id); |
|
| 520 | 520 | |
| 521 | 521 | // Check if this is a subscription or not. |
| 522 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 523 | - if ( ! empty( $subscription ) ) { |
|
| 524 | - $this->process_subscription( $invoice, $subscription ); |
|
| 522 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
| 523 | + if (!empty($subscription)) { |
|
| 524 | + $this->process_subscription($invoice, $subscription); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | // If it is free, send to the success page. |
| 528 | - if ( ! $invoice->needs_payment() ) { |
|
| 528 | + if (!$invoice->needs_payment()) { |
|
| 529 | 529 | $invoice->mark_paid(); |
| 530 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
| 530 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | // Charge the payment profile. |
| 534 | - $this->process_initial_payment( $invoice ); |
|
| 534 | + $this->process_initial_payment($invoice); |
|
| 535 | 535 | |
| 536 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
| 536 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
| 537 | 537 | |
| 538 | 538 | exit; |
| 539 | 539 | |
@@ -544,23 +544,23 @@ discard block |
||
| 544 | 544 | * |
| 545 | 545 | * @param WPInv_Invoice $invoice Invoice. |
| 546 | 546 | */ |
| 547 | - protected function process_initial_payment( $invoice ) { |
|
| 547 | + protected function process_initial_payment($invoice) { |
|
| 548 | 548 | |
| 549 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 550 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
| 551 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
| 549 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
| 550 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
| 551 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
| 552 | 552 | |
| 553 | 553 | // Do we have an error? |
| 554 | - if ( is_wp_error( $result ) ) { |
|
| 555 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
| 556 | - wpinv_send_back_to_checkout( $invoice ); |
|
| 554 | + if (is_wp_error($result)) { |
|
| 555 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
| 556 | + wpinv_send_back_to_checkout($invoice); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | // Process the response. |
| 560 | - $this->process_charge_response( $result, $invoice ); |
|
| 560 | + $this->process_charge_response($result, $invoice); |
|
| 561 | 561 | |
| 562 | - if ( wpinv_get_errors() ) { |
|
| 563 | - wpinv_send_back_to_checkout( $invoice ); |
|
| 562 | + if (wpinv_get_errors()) { |
|
| 563 | + wpinv_send_back_to_checkout($invoice); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | } |
@@ -571,24 +571,24 @@ discard block |
||
| 571 | 571 | * @param WPInv_Invoice $invoice Invoice. |
| 572 | 572 | * @param WPInv_Subscription $subscription Subscription. |
| 573 | 573 | */ |
| 574 | - public function process_subscription( $invoice, $subscription ) { |
|
| 574 | + public function process_subscription($invoice, $subscription) { |
|
| 575 | 575 | |
| 576 | 576 | // Check if there is an initial amount to charge. |
| 577 | - if ( (float) $invoice->get_total() > 0 ) { |
|
| 578 | - $this->process_initial_payment( $invoice ); |
|
| 577 | + if ((float) $invoice->get_total() > 0) { |
|
| 578 | + $this->process_initial_payment($invoice); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | // Activate the subscription. |
| 582 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
| 583 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
| 582 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
| 583 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
| 584 | 584 | |
| 585 | - $subscription->set_next_renewal_date( $expiry ); |
|
| 586 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 587 | - $subscription->set_profile_id( $invoice->generate_key() ); |
|
| 585 | + $subscription->set_next_renewal_date($expiry); |
|
| 586 | + $subscription->set_date_created(current_time('mysql')); |
|
| 587 | + $subscription->set_profile_id($invoice->generate_key()); |
|
| 588 | 588 | $subscription->activate(); |
| 589 | 589 | |
| 590 | 590 | // Redirect to the success page. |
| 591 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
| 591 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
| 592 | 592 | |
| 593 | 593 | } |
| 594 | 594 | |
@@ -599,20 +599,20 @@ discard block |
||
| 599 | 599 | * @param bool $should_expire |
| 600 | 600 | * @param WPInv_Subscription $subscription |
| 601 | 601 | */ |
| 602 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
| 602 | + public function maybe_renew_subscription($should_expire, $subscription) { |
|
| 603 | 603 | |
| 604 | 604 | // Ensure its our subscription && it's active. |
| 605 | - if ( $this->id != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
|
| 605 | + if ($this->id != $subscription->get_gateway() || !$subscription->has_status('active trialling')) { |
|
| 606 | 606 | return $should_expire; |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | // If this is the last renewal, complete the subscription. |
| 610 | - if ( $subscription->is_last_renewal() ) { |
|
| 610 | + if ($subscription->is_last_renewal()) { |
|
| 611 | 611 | $subscription->complete(); |
| 612 | 612 | return false; |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - $this->renew_subscription( $subscription ); |
|
| 615 | + $this->renew_subscription($subscription); |
|
| 616 | 616 | |
| 617 | 617 | return false; |
| 618 | 618 | |
@@ -623,28 +623,28 @@ discard block |
||
| 623 | 623 | * |
| 624 | 624 | * @param WPInv_Subscription $subscription |
| 625 | 625 | */ |
| 626 | - public function renew_subscription( $subscription ) { |
|
| 626 | + public function renew_subscription($subscription) { |
|
| 627 | 627 | |
| 628 | 628 | // Generate the renewal invoice. |
| 629 | 629 | $new_invoice = $subscription->create_payment(); |
| 630 | 630 | $old_invoice = $subscription->get_parent_payment(); |
| 631 | 631 | |
| 632 | - if ( empty( $new_invoice ) ) { |
|
| 633 | - $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
|
| 632 | + if (empty($new_invoice)) { |
|
| 633 | + $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false); |
|
| 634 | 634 | $subscription->failing(); |
| 635 | 635 | return; |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | // Charge the payment method. |
| 639 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 640 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
| 641 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
| 639 | + $payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
| 640 | + $customer_profile = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true); |
|
| 641 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice); |
|
| 642 | 642 | |
| 643 | 643 | // Do we have an error? |
| 644 | - if ( is_wp_error( $result ) ) { |
|
| 644 | + if (is_wp_error($result)) { |
|
| 645 | 645 | |
| 646 | 646 | $old_invoice->add_note( |
| 647 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
| 647 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()), |
|
| 648 | 648 | true, |
| 649 | 649 | false, |
| 650 | 650 | true |
@@ -655,12 +655,12 @@ discard block |
||
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | // Process the response. |
| 658 | - $this->process_charge_response( $result, $new_invoice ); |
|
| 658 | + $this->process_charge_response($result, $new_invoice); |
|
| 659 | 659 | |
| 660 | - if ( wpinv_get_errors() ) { |
|
| 660 | + if (wpinv_get_errors()) { |
|
| 661 | 661 | |
| 662 | 662 | $old_invoice->add_note( |
| 663 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
| 663 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()), |
|
| 664 | 664 | true, |
| 665 | 665 | false, |
| 666 | 666 | true |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - $subscription->add_payment( array(), $new_invoice ); |
|
| 673 | + $subscription->add_payment(array(), $new_invoice); |
|
| 674 | 674 | $subscription->renew(); |
| 675 | 675 | } |
| 676 | 676 | |
@@ -681,34 +681,34 @@ discard block |
||
| 681 | 681 | * @param GetPaid_Form_Item[] $items |
| 682 | 682 | * @return WPInv_Invoice |
| 683 | 683 | */ |
| 684 | - public function process_addons( $invoice, $items ) { |
|
| 684 | + public function process_addons($invoice, $items) { |
|
| 685 | 685 | |
| 686 | 686 | global $getpaid_authorize_addons; |
| 687 | 687 | |
| 688 | 688 | $getpaid_authorize_addons = array(); |
| 689 | - foreach ( $items as $item ) { |
|
| 689 | + foreach ($items as $item) { |
|
| 690 | 690 | |
| 691 | - if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) { |
|
| 691 | + if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) { |
|
| 692 | 692 | $getpaid_authorize_addons[] = $item; |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | - if ( empty( $getpaid_authorize_addons ) ) { |
|
| 697 | + if (empty($getpaid_authorize_addons)) { |
|
| 698 | 698 | return; |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | $invoice->recalculate_total(); |
| 702 | 702 | |
| 703 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 704 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
| 703 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
| 704 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
| 705 | 705 | |
| 706 | - add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
|
| 707 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
| 708 | - remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) ); |
|
| 706 | + add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2); |
|
| 707 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
| 708 | + remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request')); |
|
| 709 | 709 | |
| 710 | - if ( is_wp_error( $result ) ) { |
|
| 711 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
| 710 | + if (is_wp_error($result)) { |
|
| 711 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
| 712 | 712 | return; |
| 713 | 713 | } |
| 714 | 714 | |
@@ -721,19 +721,19 @@ discard block |
||
| 721 | 721 | * @param array $args |
| 722 | 722 | * @return array |
| 723 | 723 | */ |
| 724 | - public function filter_addons_request( $args ) { |
|
| 724 | + public function filter_addons_request($args) { |
|
| 725 | 725 | |
| 726 | 726 | global $getpaid_authorize_addons; |
| 727 | 727 | $total = 0; |
| 728 | 728 | |
| 729 | - foreach ( $getpaid_authorize_addons as $addon ) { |
|
| 729 | + foreach ($getpaid_authorize_addons as $addon) { |
|
| 730 | 730 | $total += $addon->get_sub_total(); |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | $args['createTransactionRequest']['transactionRequest']['amount'] = $total; |
| 734 | 734 | |
| 735 | - if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) { |
|
| 736 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
| 735 | + if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) { |
|
| 736 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | return $args; |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | public function sandbox_notice() { |
| 747 | 747 | |
| 748 | 748 | return sprintf( |
| 749 | - __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
| 749 | + __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
| 750 | 750 | '<a href="https://developer.authorize.net/hello_world/testing_guide.html">', |
| 751 | 751 | '</a>' |
| 752 | 752 | ); |
@@ -758,42 +758,42 @@ discard block |
||
| 758 | 758 | * |
| 759 | 759 | * @param array $admin_settings |
| 760 | 760 | */ |
| 761 | - public function admin_settings( $admin_settings ) { |
|
| 761 | + public function admin_settings($admin_settings) { |
|
| 762 | 762 | |
| 763 | 763 | $currencies = sprintf( |
| 764 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
| 765 | - implode( ', ', $this->currencies ) |
|
| 764 | + __('Supported Currencies: %s', 'invoicing'), |
|
| 765 | + implode(', ', $this->currencies) |
|
| 766 | 766 | ); |
| 767 | 767 | |
| 768 | 768 | $admin_settings['authorizenet_active']['desc'] .= " ($currencies)"; |
| 769 | - $admin_settings['authorizenet_desc']['std'] = __( 'Pay securely using your credit or debit card.', 'invoicing' ); |
|
| 769 | + $admin_settings['authorizenet_desc']['std'] = __('Pay securely using your credit or debit card.', 'invoicing'); |
|
| 770 | 770 | |
| 771 | 771 | $admin_settings['authorizenet_login_id'] = array( |
| 772 | 772 | 'type' => 'text', |
| 773 | 773 | 'id' => 'authorizenet_login_id', |
| 774 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
| 775 | - 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>', |
|
| 774 | + 'name' => __('API Login ID', 'invoicing'), |
|
| 775 | + 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>', |
|
| 776 | 776 | ); |
| 777 | 777 | |
| 778 | 778 | $admin_settings['authorizenet_transaction_key'] = array( |
| 779 | 779 | 'type' => 'text', |
| 780 | 780 | 'id' => 'authorizenet_transaction_key', |
| 781 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
| 781 | + 'name' => __('Transaction Key', 'invoicing'), |
|
| 782 | 782 | ); |
| 783 | 783 | |
| 784 | 784 | $admin_settings['authorizenet_signature_key'] = array( |
| 785 | 785 | 'type' => 'text', |
| 786 | 786 | 'id' => 'authorizenet_signature_key', |
| 787 | - 'name' => __( 'Signature Key', 'invoicing' ), |
|
| 788 | - 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
| 787 | + 'name' => __('Signature Key', 'invoicing'), |
|
| 788 | + 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
| 789 | 789 | ); |
| 790 | 790 | |
| 791 | 791 | $admin_settings['authorizenet_ipn_url'] = array( |
| 792 | 792 | 'type' => 'ipn_url', |
| 793 | 793 | 'id' => 'authorizenet_ipn_url', |
| 794 | - 'name' => __( 'Webhook URL', 'invoicing' ), |
|
| 794 | + 'name' => __('Webhook URL', 'invoicing'), |
|
| 795 | 795 | 'std' => $this->notify_url, |
| 796 | - 'desc' => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
| 796 | + 'desc' => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
| 797 | 797 | 'custom' => 'authorizenet', |
| 798 | 798 | 'readonly' => true, |
| 799 | 799 | ); |