Odyssey
2019111200_updIPAYBPSTrustedMaster.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 /**
11  * Updates trusted master to include override options for IPAYBPS
12  */
13 class updIPAYBPSTrustedMaster extends AbstractMigration {
14 
15  /** @var string */
16  protected $trusted_table = "cutrustedmaster";
17  /** @var array - use in part for updates, completely for insert */
18  protected $trusted_default = [
19  'trustedid' => 'IPAYBPS',
20  'trustedvendor' => 'IPAY',
21  'trustedtype' => 'BillPay',
22  'hcuinterface' => '',
23  'trustedfields' => [
24  'validconsmprod' => [
25  'Type' => 'string',
26  'Default' => 'HomeCU',
27  'Message' => ''
28  ],
29  'validconsmname' => [
30  'Type' => 'string',
31  'Default' => 'DMS',
32  'Message' => ''
33  ],
34  'workflowcorrelid' => [
35  'Type' => 'string',
36  'Default' => '?',
37  'Message' => "do not leave empty, use question mark"
38  ],
39  'auditwsid' => [
40  'Type' => 'string',
41  'Default' => '?',
42  'Message' => "do not leave empty, use question mark"
43  ],
44  'auditusrid' => [
45  'Type' => 'string',
46  'Default' => 'homecukim',
47  'Message' => 'if this value is left blank, IPAYBPS.i will default the credit union code.'
48  ],
49  'institutionenvironment' => [
50  'Type' => 'string',
51  'Default' => 'PROD',
52  'Message' => ''
53  ],
54  'username' => [
55  'Type' => 'string',
56  'Default' => 'jxep-HOMECUiJXGateway@jhahosting.com',
57  'Message' => 'username for HOMECU'
58  ],
59  'consumerproduct' => [
60  'Type' => 'string',
61  'Default' => 'HomeCU',
62  'Message' => ''
63  ],
64  'consumername' => [
65  'Type' => 'string',
66  'Default' => 'DMS',
67  'Message' => ''
68  ],
69  'product' => [
70  'Type' => 'string',
71  'Default' => 'Bilpay',
72  'Message' => "Bilpay with one l."
73  ],
74  'InstitutionId' => [
75  'Type' => 'digits',
76  'Default' => ''
77  ],
78  'password' => [
79  'Type' => 'string',
80  'Default' => 'fH!57$iEhB#1!w3Au6S#$d2Y9#Nj!Fs8g4C$Xz#7!R5k3$cUpM',
81  'Message' => "password for HOMECU"
82  ],
83  'serviceurl' => [
84  'Type' => 'string',
85  'Default' => "https://jxappgtw.jhahosted.com/jxchange/2008/ServiceGateway/ServiceGateway.svc",
86  'Message' => ""
87  ],
88  'datemodel' => [
89  'Type' => 'string',
90  'Default' => "payeeprocess",
91  'Message' => "do not change"
92  ],
93  'moc' => [
94  'Type' => 'digits',
95  'Default' => "1",
96  'Message' => ""
97  ],
98  'mocservice' => [
99  'Type' => 'string',
100  'Default' => "https://KIMjxtest.jackhenry.com/jxchange/2008/ServiceGateway/ServiceGateway.svc",
101  'Message' => ""
102  ],
103  'mocpass' => [
104  'Type' => 'string',
105  'Default' => ""
106  ],
107  'ExtraOptions' => [
108  'Type' => 'string',
109  'Default' => "Transfer=1&Recur=0&PayeeMaint=0&AccountMaint=0&Enroll=0"
110  ],
111  'MoblPayName' => [
112  'Type' => 'string',
113  'Default' => "iPayBPS",
114  'Message' => ""
115  ],
116  'hcuLogging' => [
117  'Type' => 'string',
118  'Default' => "0",
119  'Message' => ""
120  ],
121  'xmlnamespace' => [
122  'Type' => 'string',
123  'Default' => "http://schemas.xmlsoap.org/soap/envelope/",
124  'Message' => ""
125  ],
126  'xmlnamespaceresp' => [
127  'Type' => 'string',
128  'Default' => "http://jackhenry.com/jxchange/TPG/2008",
129  'Message' => ""
130  ],
131  'version' => [
132  'Type' => 'string',
133  'Default' => "5",
134  'Message' => "JX App Version"
135  ],
136  'accountspecs' => [
137  'Type' => 'string',
138  'Default' => "member",
139  'Message' => "Format: fieldname1(start char, length) | fieldname2(start char, length) | fieldname3(start char, length) Fields to choose: Suffix, micraccount, accounttype, member Example: member(1,2) | suffix | micraccount(1,6)"
140  ],
141  'override' => [
142  'Type' => 'boolean',
143  'Default' => "N",
144  'Message' => "Check if overrides allowed at CU"
145  ],
146  'overridecodes' => [
147  'Type' => 'string',
148  'Default' => "8006",
149  'Message' => "cvs list, defaults to duplicate payment error code"
150  ]
151  ]
152  ];
153 
154  /**
155  * See if IPAYBPS exists, if so, update it to force the override entries and
156  * updated default values
157  *
158  * Since trustedid is unique key to table, counting on only one IPAYBPS entry
159  * @return void
160  */
161  public function up() {
162 
163  if ($this->hasTable($this->trusted_table)) {
164 
165  $def = $this->trusted_default;
166  $sql = "select * from {$this->trusted_table} where trustedid = '{$def['trustedid']}'";
167 
168  # note appears that fetchRow always returns count of 1, even if no row is found.
169  # using fetchAll even though I expect max 1 record (trustedid is unique key)
170 
171  $trusted_row = $this->fetchAll($sql);
172 
173  if (count($trusted_row) > 0) {
174  $sql = "update {$this->trusted_table} set trustedfields = E'"
175  . json_encode($def['trustedfields'])
176  . "' where trustedid = '{$def['trustedid']}'";
177 
178  echo " updating {$def['trustedid']} trusted master\n";
179  $this->query($sql);
180 
181  } else {
182 
183  $sql = "insert into {$this->trusted_table} (trustedid, trustedvendor, trustedtype, hcuinterface, trustedfields)"
184  . " values('{$def['trustedid']}', '{$def['trustedvendor']}', '{$def['trustedtype']}',"
185  . " E'{$def['hcuinterface']}', E'" . json_encode($def['trustedfields']) . "')";
186 
187  echo " inserting {$def['trustedid']} trusted master\n";
188  $this->query($sql);
189  }
190  }
191  }
192 
193  /**
194  * No Down
195  * @return void
196  */
197  public function down() {
198 
199  }
200 }
201 
202 ?>