function post() { if ($this->checkAuth()) { if (AvailablePaymentMethodsData::hasBitPay()) { $jsonObj = json_decode(file_get_contents("php://input")); if (json_last_error() == JSON_ERROR_NONE) { //file_put_contents('IPNData.txt', print_r($jsonObj, true)); $payment = new PaymentSystem(); $posDataObj = json_decode($jsonObj->posData); $invoiceArr = explode(',', $posDataObj->invoiceList); if (json_last_error() == JSON_ERROR_NONE) { //file_put_contents('IPNPosData.txt', print_r($invoiceArr, true)); // todo: maybe confirm posData for extra Security? if ($payment->confirmBitPayPaidComplete($jsonObj->id)) { // todo: compare amounts paid vs invoice amount //file_put_contents('here1.txt', $posDataObj->userID); $payment->updateInvoicesPaid($invoiceArr, $jsonObj->id, PaymentMethod::BitPay, $posDataObj->userID); } else { if ($payment->confirmBitPayPending($jsonObj->id)) { //file_put_contents('here2.txt', $posDataObj->userID); $payment->updateInvoicesPending($invoiceArr, $posDataObj->userID); } } } else { // todo: record error somewhere } echo json_encode(StatusReturn::S200()); } else { echo json_encode(StatusReturn::E400('Bad JSON!')); } } else { echo json_encode(StatusReturn::E404('404 Not Found!')); } } }
function get_xhr() { if ($this->checkAuth()) { $availableFactors = AvailableFactorsData::getAvailableFactors(); foreach ($availableFactors as $key => $value) { $availableFactors[$key]['available'] = $value['available'] == "1"; } $availableRoles = AuthUserRolesData::getAvailableRoles(); $availablePaymentMethods = AvailablePaymentMethodsData::getAvailablePaymentMethods(); $availablePackages = AvailablePackagesData::getAvailablePackages(); $newAvailablePackages = array(); foreach ($availablePackages as $package) { $newAvailablePackages[$package['packageGroup']][] = $package; } echo json_encode(StatusReturn::S200(array("availableFactors" => $availableFactors, "availableRoles" => $availableRoles, "availablePaymentMethods" => $availablePaymentMethods, "availablePackages" => $newAvailablePackages))); } }
public function addPaymentProfile($cardType, $cardEnding, $cardName, $legatoCode) { if (AvailablePaymentMethodsData::hasCreditCard()) { $beanStream = new Gateway(_PAYMENT_MERCHANT_NUMBER_, _PAYMENT_PROFILE_API_KEY_, 'www', 'v1'); $profile_create_token = array('token' => array('name' => $cardName, 'code' => $legatoCode)); if (_BEAN_STREAM_PRODUCTION_) { try { $beanStreamProfileID = $beanStream->profiles()->createProfile($profile_create_token); return AuthUserPaymentProfilesData::insertPaymentProfile($this->userID, $cardType, $cardEnding, $cardName, $beanStreamProfileID); } catch (Exception $e) { // todo: record failure somewhere file_put_contents('BeanStreamError.txt', print_r($e, true)); return false; } } else { return AuthUserPaymentProfilesData::insertPaymentProfile($this->userID, $cardType, $cardEnding, $cardName, uniqid()); } } else { return false; } }