give
/
src
/
PaymentGateways
/
Gateways
/
Stripe
/
Migrations
/
AddStatementDescriptorToStripeAccounts.php
AddMissingTransactionIdForUncompletedDonations.php
4 years ago
AddStatementDescriptorToStripeAccounts.php
4 years ago
AddStatementDescriptorToStripeAccounts.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\PaymentGateways\Gateways\Stripe\Migrations; |
| 4 | |
| 5 | use Exception; |
| 6 | use Give\Framework\Migrations\Contracts\Migration; |
| 7 | use Give\PaymentGateways\Stripe\Repositories\Settings; |
| 8 | use Give\PaymentGateways\Stripe\Traits\HasStripeStatementDescriptorText; |
| 9 | |
| 10 | /** |
| 11 | * @since 2.19.0 |
| 12 | */ |
| 13 | class AddStatementDescriptorToStripeAccounts extends Migration |
| 14 | { |
| 15 | use HasStripeStatementDescriptorText; |
| 16 | |
| 17 | /** |
| 18 | * @inerhitDoc |
| 19 | * @since 2.19.0 |
| 20 | * @since 2.19.1 Use old stripe statement descriptor requirements to filter text. |
| 21 | * https://github.com/impress-org/givewp/pull/6269 |
| 22 | */ |
| 23 | public function run() |
| 24 | { |
| 25 | $stripeSettings = give(Settings::class); |
| 26 | $allStripeAccount = $stripeSettings->getAllStripeAccounts(); |
| 27 | |
| 28 | if ($allStripeAccount) { |
| 29 | $statementDescriptor = give_get_option('stripe_statement_descriptor', get_bloginfo('name')); |
| 30 | foreach ($allStripeAccount as $index => $stripAccount) { |
| 31 | if (!isset($stripAccount['statement_descriptor'])) { |
| 32 | $allStripeAccount[$index]['statement_descriptor'] = $this->filterOldStatementDescriptor( |
| 33 | $statementDescriptor |
| 34 | ); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | give_update_option('_give_stripe_get_all_accounts', $allStripeAccount); |
| 39 | } |
| 40 | |
| 41 | give_delete_option('stripe_statement_descriptor'); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @inerhitDoc |
| 46 | * @since 2.19.0 |
| 47 | */ |
| 48 | public static function id() |
| 49 | { |
| 50 | return 'add-statement-descriptor-to-stripe-accounts'; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @inerhitDoc |
| 55 | * @since 2.19.0 |
| 56 | */ |
| 57 | public static function timestamp() |
| 58 | { |
| 59 | return strtotime('10-02-2022'); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * @inerhitDoc |
| 64 | * @since 2.19.0 |
| 65 | */ |
| 66 | public static function title() |
| 67 | { |
| 68 | return 'Add Statement Descriptor To Stripe Accounts'; |
| 69 | } |
| 70 | } |
| 71 |