/** * Generates a URL for an existing subscriber to enter an additional credit card. Uses the given User's accountId to attach the paymentmethod to their account upon submission. * @param $accountName Name of the target account * @return Existing PaymentMethod URL */ public static function getExistingIframeSrc($accountName) { $zapi; try { $zapi = new zApi(); } catch (Exception $e) { throw new Exception('INVALID_ZLOGIN'); } //Get Account with this name $accId = NULL; $accResult = $zapi->zQuery("SELECT Id FROM Account WHERE Name='" . $accountName . "'"); //Get Account Information foreach ($accResult->result->records as $acc) { $accId = $acc->Id; } if ($accId == NULL) { throw new Exception('USER_DOESNT_EXIST'); } $conResult = $zapi->zQuery("SELECT AccountId,Country,Address1,Address2,City,State,PostalCode,WorkPhone FROM Contact WHERE AccountId='" . $accId . "'"); if ($conResult->result->size == 0) { return null; } $con; foreach ($conResult->result->records as $ccon) { $con = $ccon; } $URL = PaymentManager::generateUrl(); $URL = $URL . '&field_accountId=' . $con->AccountId; if (isset($con->Country)) { if (strtolower($con->Country) == 'united states') { $URL .= '&field_creditCardCountry=USA'; } else { if (strtolower($con->Country) == 'canada') { $URL .= '&field_creditCardCountry=CAN'; } } } $URL .= isset($con->State) ? '&field_creditCardState=' . $con->State : ''; $URL .= isset($con->City) ? '&field_creditCardCity=' . $con->City : ''; $URL .= isset($con->PostalCode) ? '&field_creditCardPostalCode=' . $con->PostalCode : ''; $URL .= $con->Address1 != null ? '&field_creditCardAddress1=' . $con->Address1 : ''; $URL .= isset($con->Address2) ? '&field_creditCardAddress2=' . $con->Address2 : ''; $URL .= isset($con->WorkPhone) ? '&field_phone=' . $con->WorkPhone : ''; $URL .= isset($con->WorkEmail) ? '&field_email=' . $con->WorkEmail : ''; return $URL; }
/** * Testing payment error * */ public function testPaymentSuccess() { $this->authorizenetMethod->expects($this->once())->method('getCreditCartNumber')->will($this->returnValue(self::CART_NUMBER)); $this->authorizenetMethod->expects($this->once())->method('getCreditCartExpirationMonth')->will($this->returnValue(self::CART_EXPIRE_MONTH)); $this->authorizenetMethod->expects($this->once())->method('getCreditCartExpirationYear')->will($this->returnValue(self::CART_EXPIRE_YEAR)); $this->paymentBridge->expects($this->once())->method('getOrder')->will($this->returnValue(1)); $this->authorizenetMethod->expects($this->any())->method('setTransactionId')->with($this->equalTo('123'))->will($this->returnValue($this->authorizenetMethod)); $this->authorizenetMethod->expects($this->any())->method('setTransactionStatus')->with($this->equalTo('paid'))->will($this->returnValue($this->authorizenetMethod)); $this->paymentBridge->expects($this->once())->method('getAmount')->will($this->returnValue(self::CART_AMOUNT)); $this->paymentBridge->expects($this->once())->method('getExtraData')->will($this->returnValue(array('order_description' => self::CART_DESCRIPTION))); $postValues = array("x_login" => self::LOGIN_ID, "x_tran_key" => self::TRAN_KEY, "x_version" => "3.1", "x_delim_data" => "TRUE", "x_delim_char" => "|", "x_relay_response" => "FALSE", "x_type" => "AUTH_CAPTURE", "x_method" => "CC", "x_card_num" => self::CART_NUMBER, "x_exp_date" => self::CART_EXPIRE_MONTH . self::CART_EXPIRE_YEAR, "x_amount" => (double) number_format(self::CART_AMOUNT / 100, 2, '.', ''), "x_description" => self::CART_DESCRIPTION); $postString = ""; foreach ($postValues as $key => $value) { $postString .= "{$key}=" . urlencode($value) . "&"; } $postString = rtrim($postString, "& "); $this->authorizenetTransactionWrapper->expects($this->once())->method('create')->with($postString)->will($this->returnValue(array('2' => '1', '37' => '123'))); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderLoad')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->authorizenetMethod)); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderCreated')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->authorizenetMethod)); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderDone')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->authorizenetMethod)); $this->paymentEventDispatcher->expects($this->any())->method('notifyPaymentOrderFail'); $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderSuccess')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->authorizenetMethod)); $this->authorizenetManager->processPayment($this->authorizenetMethod, self::CART_AMOUNT); }
/** * Determine whether the payment system is configured. * @return boolean true iff configured */ function isConfigured() { $journal =& $this->request->getJournal(); return parent::isConfigured() && $journal->getSetting('journalPaymentsEnabled'); }
/** * Determine whether the payment system is configured. * @return boolean true iff configured */ function isConfigured() { return parent::isConfigured() && $this->press && $this->press->getSetting('currency'); }
function getExistingIframeSrc() { global $messages; $iframeSrc = PaymentManager::getExistingIframeSrc($_SESSION['email']); $messages = $iframeSrc; }
function test_getExistingAccountUrl() { global $EXISTING_CUSTOMER_ACCOUNT_NAME; printResultStart(__FUNCTION__); $messages = array(); //Test try { $iframeSrc = PaymentManager::getExistingIframeSrc($EXISTING_CUSTOMER_ACCOUNT_NAME); echo "The iframe below should display a credit card and contact information entry form, " . "prepopulated with existing user, '" . $EXISTING_CUSTOMER_ACCOUNT_NAME . "'s contact information..<br>"; echo "<iframe src='" . $iframeSrc . "' width='400' height='180'></iframe><br>"; } catch (Exception $e) { array_push($messages, "Iframe URL threw an exception: " . $e->getMessage()); } printResultEnd($messages); }
public static function payWith($config) { $mgr = new PaymentManager(); return $mgr->getDriver($config); }
/** * Constructor * @param $request PKPRequest */ function OCSPaymentManager(&$request) { parent::PaymentManager($request); }