1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This software may be modified and distributed under the terms |
7
|
|
|
* of the MIT license. See the LICENSE file for details. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Shapin\Stripe\Configuration; |
11
|
|
|
|
12
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
13
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
14
|
|
|
|
15
|
|
View Code Duplication |
class CustomerUpdate implements ConfigurationInterface |
|
|
|
|
16
|
|
|
{ |
17
|
|
|
public function getConfigTreeBuilder() |
18
|
|
|
{ |
19
|
|
|
$treeBuilder = new TreeBuilder('shapin_stripe_customer_update'); |
20
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
21
|
|
|
|
22
|
|
|
$rootNode |
23
|
|
|
->children() |
24
|
|
|
->integerNode('account_balance') |
25
|
|
|
->info('An integer amount in cents that represents the account balance for your customer. Account balances only affect invoices. A negative amount represents a credit that decreases the amount due on an invoice; a positive amount increases the amount due on an invoice.') |
26
|
|
|
->end() |
27
|
|
|
->scalarNode('coupon') |
28
|
|
|
->info('If you provide a coupon code, the customer will have a discount applied on all recurring charges. Charges you create through the API will not have the discount. This will be unset if you POST an empty value.') |
29
|
|
|
->end() |
30
|
|
|
->scalarNode('default_source') |
31
|
|
|
->info('ID of the default payment source for the customer.') |
32
|
|
|
->end() |
33
|
|
|
->scalarNode('description') |
34
|
|
|
->info('An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard. This will be unset if you POST an empty value.') |
35
|
|
|
->end() |
36
|
|
|
->scalarNode('email') |
37
|
|
|
->info('Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters. This will be unset if you POST an empty value.') |
38
|
|
|
->end() |
39
|
|
|
->scalarNode('invoice_prefix') |
40
|
|
|
->info('The prefix for the customer used to generate unique invoice numbers. Must be 3–12 uppercase letters or numbers.') |
41
|
|
|
->end() |
42
|
|
|
->arrayNode('invoice_settings') |
43
|
|
|
->children() |
44
|
|
|
->arrayNode('custom_fields') |
45
|
|
|
->arrayPrototype() |
46
|
|
|
->children() |
47
|
|
|
->scalarNode('name') |
48
|
|
|
->isRequired() |
49
|
|
|
->info('The name of the custom field. This may be up to 30 characters.') |
50
|
|
|
->end() |
51
|
|
|
->scalarNode('value') |
52
|
|
|
->isRequired() |
53
|
|
|
->info('The value of the custom field. This may be up to 30 characters.') |
54
|
|
|
->end() |
55
|
|
|
->end() |
56
|
|
|
->end() |
57
|
|
|
->info('Default custom fields to be displayed on invoices for this customer.') |
58
|
|
|
->end() |
59
|
|
|
->scalarNode('footer') |
60
|
|
|
->info('Default footer to be displayed on invoices for this customer. This will be unset if you POST an empty value.') |
61
|
|
|
->end() |
62
|
|
|
->end() |
63
|
|
|
->info('Default invoice settings for this customer.') |
64
|
|
|
->end() |
65
|
|
|
->arrayNode('metadata') |
66
|
|
|
->scalarPrototype()->end() |
67
|
|
|
->info('A set of key-value pairs that you can attach to a customer object. It can be useful for storing additional information about the customer in a structured format.') |
68
|
|
|
->end() |
69
|
|
|
->arrayNode('shipping') |
70
|
|
|
->children() |
71
|
|
|
->arrayNode('address') |
72
|
|
|
->isRequired() |
73
|
|
|
->children() |
74
|
|
|
->scalarNode('line1') |
75
|
|
|
->isRequired() |
76
|
|
|
->cannotBeEmpty() |
77
|
|
|
->end() |
78
|
|
|
->scalarNode('city')->end() |
79
|
|
|
->scalarNode('country')->end() |
80
|
|
|
->scalarNode('line2')->end() |
81
|
|
|
->scalarNode('postal_code')->end() |
82
|
|
|
->scalarNode('state')->end() |
83
|
|
|
->end() |
84
|
|
|
->info('Customer shipping address.') |
85
|
|
|
->end() |
86
|
|
|
->scalarNode('name') |
87
|
|
|
->isRequired() |
88
|
|
|
->cannotBeEmpty() |
89
|
|
|
->info('Customer name. This can be unset by updating the value to null and then saving.') |
90
|
|
|
->end() |
91
|
|
|
->scalarNode('phone') |
92
|
|
|
->info('Customer phone (including extension). This can be unset by updating the value to null and then saving.') |
93
|
|
|
->end() |
94
|
|
|
->end() |
95
|
|
|
->info('The customer’s shipping information. Appears on invoices emailed to this customer.') |
96
|
|
|
->end() |
97
|
|
|
->scalarNode('source') |
98
|
|
|
->info('A Token’s or a Source’s ID, as returned by Elements. Passing source will create a new source object, make it the new customer default source, and delete the old customer default if one exists. If you want to add additional sources instead of replacing the existing default, use the card creation API. Whenever you attach a card to a customer, Stripe will automatically validate the card.') |
99
|
|
|
->end() |
100
|
|
|
->arrayNode('tax_info') |
101
|
|
|
->children() |
102
|
|
|
->scalarNode('tax_id') |
103
|
|
|
->isRequired(true) |
104
|
|
|
->info('The customer’s tax ID number. This can be unset by updating the value to null and then saving.') |
105
|
|
|
->end() |
106
|
|
|
->scalarNode('type') |
107
|
|
|
->isRequired(true) |
108
|
|
|
->info('The type of ID number. The only possible value is vat') |
109
|
|
|
->end() |
110
|
|
|
->end() |
111
|
|
|
->info('The customer’s tax information. Appears on invoices emailed to this customer.') |
112
|
|
|
->end() |
113
|
|
|
->end() |
114
|
|
|
; |
115
|
|
|
|
116
|
|
|
return $treeBuilder; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.