-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Payment Gateways Settings migration (#6928)
- Loading branch information
1 parent
6661704
commit 18bdfe6
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/PaymentGateways/Migrations/CopyV2GatewaysSettingsToV3.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Give\PaymentGateways\Migrations; | ||
|
||
use Give\Framework\Migrations\Contracts\Migration; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
class CopyV2GatewaysSettingsToV3 extends Migration | ||
{ | ||
|
||
/** | ||
* @inerhitDoc | ||
*/ | ||
public static function id() | ||
{ | ||
return 'copy-v2-gateways-settings-to-v3'; | ||
} | ||
|
||
/** | ||
* @inerhitDoc | ||
*/ | ||
public static function timestamp() | ||
{ | ||
return strtotime('2023-09-11'); | ||
} | ||
|
||
/** | ||
* @inerhitDoc | ||
*/ | ||
public function run() | ||
{ | ||
$v2Gateways = give_get_option('gateways', []); | ||
$v3Gateways = array_intersect_key($v2Gateways, give()->gateways->getPaymentGateways(3)); | ||
give_update_option('gateways_v3', $v3Gateways); | ||
|
||
$v2GatewaysLabels = give_get_option('gateways_label', []); | ||
$v3GatewaysLabels = array_intersect_key($v2GatewaysLabels, $v3Gateways); | ||
give_update_option('gateways_label_v3', $v3GatewaysLabels); | ||
|
||
$v2DefaultGateway = give_get_option('default_gateway', ''); | ||
$v3DefaultGateway = array_key_exists($v2DefaultGateway, $v3Gateways) ? $v2DefaultGateway : current( | ||
array_keys($v3Gateways) | ||
); | ||
give_update_option('default_gateway_v3', $v3DefaultGateway); | ||
} | ||
|
||
/** | ||
* @inerhitDoc | ||
*/ | ||
public static function title() | ||
{ | ||
return 'Copy v2 Gateways Settings to v3'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters