/** * pr * * Function to print anything in a convenient way * Will print any string/number/etc, array, or object. * * @param mixed $x Anything * @param string $descr Description to print above output, optional * @return void **/ function pr($x, $descr = '') { if (is_object($x)) { printobj($x, $descr); } elseif (is_array($x)) { printarr($x, $descr); } else { if (is_string($x) && substr($x, 0, 5) == '<?xml') { printxml($x, $descr); } else { printbr($x, $descr); } } }
// That will initialize a payment_schedule web object with frequency "once"; end_date "today"; // It will stub in all the fields with empty values making it very easy to inspect. // (Likely to be replaced with a $oaCon->createNewPaymentSchedule( $ext_acct_id, $pay_type_id, $amt, $frequency, $end_date, $currency ) call.) $paymentSchedule = $oaConn->getPaymentSchedule(''); $paymentSchedule->payment_schedule_external_account_id = $external_account_id; $paymentSchedule->payment_schedule_payment_type_id = $payment_type_id; $paymentSchedule->payment_schedule_amount = rand(10000, 99999) / 100; printObj($paymentSchedule, 1); print "Saving Payment Schedule..." . PHP_EOL; $paymentSchedule = $oaConn->savePaymentSchedule($paymentSchedule); if (isset($paymentSchedule->payment_schedule_id)) { // The reponse from savePaymentSchedule was actually the new Payment Schedule; // we retrieve it here separately just to demonstrate it worked. print "Retrieving payment schedule to confirm save..." . PHP_EOL; $response = $oaConn->getPaymentSchedule($paymentSchedule->payment_schedule_id); printObj($response, 1); print "Succesfully retrieved new Payment Schedule!" . PHP_EOL; } else { printobj($paymentSchedule, 1); } } catch (Exception $e) { //echo $response->error . PHP_EOL; echo $e->getMessage() . PHP_EOL; } function printObj($obj, $depth = 0) { foreach ($obj as $key => $value) { print str_repeat("\t", $depth) . "{$key} = {$value}" . PHP_EOL; } print PHP_EOL; }
$paymentSchedule = $oaConn->getPaymentSchedule(''); $paymentSchedule->payment_schedule_external_account_id = $externalAccount->external_account_id; $paymentSchedule->payment_schedule_payment_type_id = $payment_type_id; $paymentSchedule->payment_schedule_amount = rand(10000, 99999) / 100; printObj($paymentSchedule, 1); print "Saving Payment Schedule..." . PHP_EOL; $response = $oaConn->savePaymentSchedule($paymentSchedule); if (isset($response->payment_schedule_id)) { // The reponse from savePaymentSchedule was actually the new Payment Schedule; // we retrieve it here separately just to demonstrate it worked. print "Retrieving payment schedule to confirm save..." . PHP_EOL; $paymentSchedule = $oaConn->getPaymentSchedule($response->payment_schedule_id); printObj($paymentSchedule, 1); print "Succesfully retrieved Payment Schedule!" . PHP_EOL; } else { printobj($response, 1); } } catch (Exception $e) { echo $e->getMessage() . PHP_EOL; } if ($connected) { print "Disconnecting "; $res = $oaConn->disconnect(); printObj($res); } function printObj($obj, $depth = 0) { foreach ($obj as $key => $value) { print str_repeat("\t", $depth) . "{$key} = {$value}" . PHP_EOL; } print PHP_EOL;