Odyssey
2019093000_addPayzurTrustedMaster.php
1 <?php
2 /**
3  * Notes:
4  * 1. Anything complicated needs to be done with SQL.
5  * 2. Always have a check to know if the migration needs to occur (up or down).
6  * 3. Use up() and down(), not change(), because of the SQL
7  */
8 use Phinx\Migration\AbstractMigration;
9 
10 class AddPayzurTrustedMaster extends AbstractMigration {
11  public function up() {
12 
13  // check if we already made the change
14  $tableName = "cutrustedmaster";
15 
16  if ($this->hasTable($tableName)) { // This table should exist but make sure.
17  $unpreppedDetailString = '{"testMode":{"Type":"digits","Default":"1","Message":"1=testing 0=production"},"testapiKey":{"Type":"string","Default":"u3daL09q","Message":"From Vendor. API key for vendor test environment"},"testapiHMAC":{"Type":"string","Default":"","Message":"From Vendor. Optional HMAC for signature hash in vendor test environment. Only used if useHMAC=1"},"prodapiKey":{"Type":"string","Default":"","Message":"From Vendor. API key for vendor production environment"},"prodapiHMAC":{"Type":"string","Default":"","Message":"From Vendor. Optional HMAC for signature hash in vendor production environment. Only used if useHMAC=1"},"useHMAC":{"Type":"digits","Default":"0","Message":"1=use optional signature hash for added security 0=no hash"},"testURL":{"Type":"string","Default":"https:\/\/cert.payzur.com\/payzurservices.svc\/user","Message":"From Vendor. URL for vendor test environment"},"prodURL":{"Type":"string","Default":"","Message":"From Vendor. URL for vendor production environment"},"useMIR":{"Type":"digits","Default":"1","Message":"1=require extended member info 0=no MIR required"},"hcuLogging":{"Type":"string","Default":"","Message":"0\/blank = no logging -1 = log everyone, csv list=log listed accounts"}}';
18 
19  $detailsString = pg_escape_string($unpreppedDetailString);
20 
21  $this->query("insert into $tableName values ('PAYZUR_SSO','Payzur','O',NULL, '$detailsString')");
22  print "Inserted 'PAYZUR_SSO' into $tableName.\n";
23  } else {
24  print "Oh No! cutrustedmaster has gone missing.\n";
25  }
26  } // End "up" function.
27 
28  public function down() {
29 
30  // check if we already made the change
31  $tableName = "cutrustedmaster";
32 
33  if ($this->hasTable($tableName)) { // This table should exist but make sure.
34 
35  $this->query("delete from $tableName where trustedid = 'PAYZUR_SSO'");
36  print "Removed 'PAYZUR_SSO' from $tableName.\n";
37  } else {
38  print "Oh No! cutrustedmaster has gone missing.\n";
39  }
40  } // End "down" function
41 }