本文整理汇总了PHP中Mage_Payment_Model_Info类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Payment_Model_Info类的具体用法?PHP Mage_Payment_Model_Info怎么用?PHP Mage_Payment_Model_Info使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Payment_Model_Info类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetTokenInfo
public function testGetTokenInfo()
{
$payment = new Varien_Object();
$payment->setCcCid('789');
$vaultCard = new Varien_Object();
$vaultCard->setCcType('VI');
$vaultCard->setLast4('1234');
$vaultCard->setType('VI');
$vaultCard->setExpirationMonth('12');
$vaultCard->setExpirationYear('2050');
$vaultCard->setToken('1111222233331234');
$litle = new Litle_CreditCard_Model_PaymentLogic();
$modelPalorusVault = $this->getMock('Litle_Palorus_Model_Vault');
$modelPalorusVault->expects($this->any())->method('load')->with($this->equalTo(50))->will($this->returnValue($vaultCard));
$litle->setModelPalorusVault($modelPalorusVault);
$info = new Mage_Payment_Model_Info();
$info->setAdditionalInformation('cc_vaulted', 50);
$arr = array('info_instance' => $info);
$litle->addData($arr);
$tokenInfo = $litle->getTokenInfo($payment);
$this->assertEquals('1234', $payment->getCcLast4());
$this->assertEquals('VI', $payment->getCcType());
$this->assertEquals('789', $tokenInfo['cardValidationNum']);
$this->assertEquals('VI', $tokenInfo['type']);
$this->assertEquals('1111222233331234', $tokenInfo['litleToken']);
$this->assertEquals('1250', $tokenInfo['expDate']);
}
示例2: _getAccountUniqueId
/**
* Get the encrypted card number or the ROM PAN
* @param Mage_Payment_Model_Info $payment
* @return string
*/
protected function _getAccountUniqueId(Mage_Payment_Model_Info $payment)
{
$encCardNumber = $payment->getCcNumberEnc();
if ($encCardNumber) {
return $payment->decrypt($encCardNumber);
}
return $payment->getAdditionalInformation('pan');
}
示例3: testGetInfoBlock
public function testGetInfoBlock()
{
$block = new Mage_Payment_Helper_Data();
$paymentInfo = new Mage_Payment_Model_Info();
$paymentInfo->setMethod('checkmo');
$result = $block->getInfoBlock($paymentInfo);
$this->assertInstanceOf('Mage_Payment_Block_Info_Checkmo', $result);
}
示例4: isPaymentCancelRegistered
/**
*
* @param Mage_Payment_Model_Info $payment
* @return bool
*/
public function isPaymentCancelRegistered(Mage_Payment_Model_Info $payment)
{
$value = $this->registry(self::KEY_PAYMENT_CANCEL . $payment->getId());
if (empty($value) or !$value) {
return false;
} else {
return true;
}
}
示例5: _place
/**
* Send request with new payment to gateway
*
* @param Mage_Payment_Model_Info $payment
* @param decimal $amount
* @param string $requestType
* @return Mage_Paygate_Model_Authorizenet
* @throws Mage_Core_Exception
*/
protected function _place($payment, $amount, $requestType)
{
$payment->setAnetTransType($requestType);
$payment->setAmount($amount);
$request = $this->_buildRequest($payment);
$result = $this->_postRequest($request);
switch ($requestType) {
case self::REQUEST_TYPE_AUTH_ONLY:
$newTransactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH;
$defaultExceptionMessage = Mage::helper('paygate')->__('Payment authorization error.');
break;
case self::REQUEST_TYPE_AUTH_CAPTURE:
$newTransactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE;
$defaultExceptionMessage = Mage::helper('paygate')->__('Payment capturing error.');
break;
}
switch ($result->getResponseCode()) {
case self::RESPONSE_CODE_APPROVED:
$this->getCardsStorage($payment)->flushCards();
$card = $this->_registerCard($result, $payment);
$this->_addTransaction($payment, $card->getLastTransId(), $newTransactionType, array('is_transaction_closed' => 0), array($this->_realTransactionIdKey => $card->getLastTransId()), Mage::helper('paygate')->getTransactionMessage($payment, $requestType, $card->getLastTransId(), $card, $amount));
if ($requestType == self::REQUEST_TYPE_AUTH_CAPTURE) {
$card->setCapturedAmount($card->getProcessedAmount());
$this->getCardsStorage($payment)->updateCard($card);
}
return $this;
case self::RESPONSE_CODE_HELD:
if ($result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_PENDING_REVIEW_AUTHORIZED || $result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_PENDING_REVIEW) {
$card = $this->_registerCard($result, $payment);
$this->_addTransaction($payment, $card->getLastTransId(), $newTransactionType, array('is_transaction_closed' => 0), array($this->_realTransactionIdKey => $card->getLastTransId(), $this->_isTransactionFraud => true), Mage::helper('paygate')->getTransactionMessage($payment, $requestType, $card->getLastTransId(), $card, $amount));
if ($requestType == self::REQUEST_TYPE_AUTH_CAPTURE) {
$card->setCapturedAmount($card->getProcessedAmount());
$this->getCardsStorage()->updateCard($card);
}
$payment->setIsTransactionPending(true)->setIsFraudDetected(true);
return $this;
}
if ($result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_PARTIAL_APPROVE) {
$checksum = $this->_generateChecksum($request, $this->_partialAuthorizationChecksumDataKeys);
$this->_getSession()->setData($this->_partialAuthorizationChecksumSessionKey, $checksum);
if ($this->_processPartialAuthorizationResponse($result, $payment)) {
return $this;
}
}
Mage::throwException($defaultExceptionMessage);
case self::RESPONSE_CODE_DECLINED:
case self::RESPONSE_CODE_ERROR:
Mage::throwException($this->_wrapGatewayError($result->getResponseReasonText()));
default:
Mage::throwException($defaultExceptionMessage);
}
return $this;
}
示例6: testSetInfoTemplate
public function testSetInfoTemplate()
{
$block = $this->getMock('Mage_Payment_Block_Info_ContainerAbstract', array('getChildBlock', 'getPaymentInfo'));
$paymentInfo = new Mage_Payment_Model_Info();
$methodInstance = new Mage_Payment_Model_Method_Checkmo();
$paymentInfo->setMethodInstance($methodInstance);
$block->expects($this->atLeastOnce())->method('getPaymentInfo')->will($this->returnValue($paymentInfo));
$childBlock = new Mage_Core_Block_Template();
$block->expects($this->atLeastOnce())->method('getChildBlock')->with('payment.info.checkmo')->will($this->returnValue($childBlock));
$template = 'any_template.phtml';
$this->assertNotEquals($template, $childBlock->getTemplate());
$block->setInfoTemplate('checkmo', $template);
$this->assertEquals($template, $childBlock->getTemplate());
}
示例7: testGetChildPdfAsArray
/**
* @magentoConfigFixture current_store payment/banktransfer/title Bank Method Title
* @magentoConfigFixture current_store payment/checkmo/title Checkmo Title Of The Method
*/
public function testGetChildPdfAsArray()
{
$block = new Mage_Payment_Block_Info();
$layout = new Mage_Core_Model_Layout();
$layout->addBlock($block, 'block');
$paymentInfoBank = new Mage_Payment_Model_Info();
$paymentInfoBank->setMethodInstance(new Mage_Payment_Model_Method_Banktransfer());
$childBank = $layout->addBlock('Mage_Payment_Block_Info_Instructions', 'child.one', 'block');
$childBank->setInfo($paymentInfoBank)->setArea('adminhtml');
$nonExpectedHtml = 'non-expected html';
$childHtml = $layout->addBlock('Mage_Core_Block_Text', 'child.html', 'block');
$childHtml->setText($nonExpectedHtml);
$paymentInfoCheckmo = new Mage_Payment_Model_Info();
$paymentInfoCheckmo->setMethodInstance(new Mage_Payment_Model_Method_Checkmo());
$childCheckmo = $layout->addBlock('Mage_Payment_Block_Info_Checkmo', 'child.just.another', 'block');
$childCheckmo->setInfo($paymentInfoCheckmo)->setArea('adminhtml');
$pdfArray = $block->getChildPdfAsArray();
$this->assertInternalType('array', $pdfArray);
$this->assertCount(2, $pdfArray);
$text = implode('', $pdfArray);
$this->assertContains('Bank Method Title', $text);
$this->assertContains('Checkmo Title Of The Method', $text);
$this->assertNotContains($nonExpectedHtml, $text);
}
示例8: _formatPrice
/**
* Format price with currency sign
* @param Mage_Payment_Model_Info $payment
* @param float $amount
* @return string
*/
protected function _formatPrice($payment, $amount)
{
return $payment->getOrder()->getBaseCurrency()->formatTxt($amount);
}
示例9: collectPayment
public function collectPayment(\Mage_Payment_Model_Info $payment, $amount, $capture = true)
{
$Currency = Mage::app()->getStore()->getBaseCurrencyCode();
require_once MAGENTO_ROOT . '/lib/Start/autoload.php';
# At the top of your PHP file
$token = isset($_POST['payfortToken']) ? $_POST['payfortToken'] : false;
$email = isset($_POST['payfortEmail']) ? $_POST['payfortEmail'] : false;
if (!$token || !$email) {
//this block will be executed if the order was authorized earlier and now trying to capture amount
$token_array = $payment->getAdditionalInformation('token');
$token = $token_array['token'];
$email = $token_array['email'];
}
if (!$token || !$email) {
Mage::throwException('Invalid Token');
}
$currency = !isset($Currency) ? 'AED' : $Currency;
if (file_exists(MAGENTO_ROOT . '/data/currencies.json')) {
$currency_json_data = json_decode(file_get_contents(MAGENTO_ROOT . '/data/currencies.json'), 1);
$currency_multiplier = $currency_json_data[$currency];
} else {
$currency_multiplier = 100;
}
$amount_in_cents = $amount * $currency_multiplier;
$order = $payment->getOrder();
$order_items_array_full = array();
foreach ($order->getAllVisibleItems() as $value) {
$order_items_array['title'] = $value->getName();
$order_items_array['amount'] = round($value->getPrice(), 2) * $currency_multiplier;
$order_items_array['quantity'] = $value->getQtyOrdered();
array_push($order_items_array_full, $order_items_array);
}
$shipping_amount = $order->getShippingAmount();
$shipping_amount = $shipping_amount * $currency_multiplier;
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
$customer = Mage::getSingleton('customer/session')->getCustomer();
$username = $customer->getName();
$registered_at = date(DATE_ISO8601, strtotime($customer->getCreatedAt()));
} else {
$username = "Guest";
$registered_at = date(DATE_ISO8601, strtotime(date("Y-m-d H:i:s")));
}
$billing_data = $order->getBillingAddress()->getData();
if (is_object($order->getShippingAddress())) {
$shipping_data = $order->getShippingAddress()->getData();
$shipping_address = array("first_name" => $shipping_data['firstname'], "last_name" => $shipping_data['lastname'], "country" => $shipping_data['country_id'], "city" => $shipping_data['city'], "address" => $shipping_data['customer_address'], "phone" => $shipping_data['telephone'], "postcode" => $shipping_data['postcode']);
} else {
$shipping_address = array();
}
$billing_address = array("first_name" => $billing_data['firstname'], "last_name" => $billing_data['lastname'], "country" => $billing_data['country_id'], "city" => $billing_data['city'], "address" => $billing_data['customer_address'], "phone" => $billing_data['telephone'], "postcode" => $billing_data['postcode']);
$shopping_cart_array = array('user_name' => $username, 'registered_at' => $registered_at, 'items' => $order_items_array_full, 'billing_address' => $billing_address, 'shipping_address' => $shipping_address);
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$charge_args = array('description' => "Magento charge for " . $email, 'card' => $token, 'currency' => $currency, 'email' => $email, 'ip' => $_SERVER['REMOTE_ADDR'], 'amount' => $amount_in_cents, 'capture' => $capture, 'shipping_amount' => $shipping_amount, 'shopping_cart' => $shopping_cart_array, 'metadata' => array('reference_id' => $orderId));
$ver = new Mage();
$version = $ver->getVersion();
$userAgent = 'Magento ' . $version . ' / Start Plugin ' . self::PLUGIN_VERSION;
Start::setUserAgent($userAgent);
$method = $payment->getMethodInstance();
if ($method->getConfigData('test_mode') == 1) {
Start::setApiKey($method->getConfigData('test_secret_key'));
} else {
Start::setApiKey($method->getConfigData('live_secret_key'));
}
try {
// Charge the token
$charge = Start_Charge::create($charge_args);
//need to process charge as success or failed
$payment->setTransactionId($charge["id"]);
if ($capture) {
$payment->setIsTransactionClosed(1);
} else {
$payment->setIsTransactionClosed(0);
}
} catch (Start_Error $e) {
$error_code = $e->getErrorCode();
if ($error_code === "card_declined") {
$errorMsg = 'Charge was declined. Please, contact you bank for more information or use a different card.';
} else {
$errorMsg = $e->getMessage();
}
throw new Mage_Payment_Model_Info_Exception($errorMsg);
}
//need to process charge as success or failed
}
示例10: denyPayment
/**
* Enable payment deny when __VENDOR status == 0
*
* @param Mage_Payment_Model_Info $payment
* @return bool
*/
public function denyPayment(Mage_Payment_Model_Info $payment)
{
if ($payment->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID) {
// returning true will automatically invoke the payment cancellation process
return true;
}
return false;
}
示例11: _buildFormUrlRequest
/**
* Returns request object with needed data for API request to PayPal to get form URL.
*
* @param Mage_Payment_Model_Info $payment
* @return Mage_Paypal_Model_Hostedpro_Request
*/
protected function _buildFormUrlRequest(Mage_Payment_Model_Info $payment)
{
$request = $this->_buildBasicRequest()->setOrder($payment->getOrder())->setPaymentMethod($this);
return $request;
}
示例12: _validateExpirationDate
/**
* Validate the card expiration date.
* @param Mage_Payment_Model_Info $info
* @return self
*/
protected function _validateExpirationDate(Mage_Payment_Model_Info $info)
{
if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
throw Mage::exception('EbayEnterprise_CreditCard', $this->_helper->__(self::INVALID_EXPIRATION_DATE));
}
return $this;
}
示例13: importPaymentInfo
/**
* Get transaction status from gateway response array and change payment status to appropriate
*
* @param Varien_Object $from
* @param Mage_Payment_Model_Info $to
* @return Enterprise_Pbridge_Model_Payment_Method_Authorizenet
*/
public function importPaymentInfo(Varien_Object $from, Mage_Payment_Model_Info $to)
{
$approvedTransactionStatuses = array(self::TRANSACTION_STATUS_AUTHORIZED_PENDING_PAYMENT, self::TRANSACTION_STATUS_CAPTURED_PENDING_SETTLEMENT);
$transactionStatus = $from->getTransactionStatus();
if (in_array($transactionStatus, $approvedTransactionStatuses)) {
$to->setIsTransactionApproved(true);
} elseif (in_array($transactionStatus, array(self::TRANSACTION_STATUS_VOIDED, self::TRANSACTION_STATUS_DECLINED))) {
$to->setIsTransactionDenied(true);
}
return $this;
}
示例14: denyPayment
/**
* Deny payment
* @param Mage_Payment_Model_Info $payment
* @return mixed
*/
public function denyPayment(Mage_Payment_Model_Info $payment)
{
$transactionId = $payment->getLastTransId();
if (!$transactionId) {
return false;
}
$request = $this->_getApiRequest();
$this->_setAdditionalRequestParameters($request, $payment);
$request->setData('transaction_id', $transactionId)->setData('order_id', $payment->getOrder()->getIncrementId());
$api = $this->_getApi()->doDeny($request);
$this->_importResultToPayment($payment, $api->getResponse());
$apiResponse = $api->getResponse();
return $apiResponse;
}
示例15: submitRecurringProfile
/**
* Submit RP to the gateway
*
* @param Mage_Payment_Model_Recurring_Profile $profile
* @param Mage_Payment_Model_Info $paymentInfo
*/
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo)
{
$token = $paymentInfo->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
$profile->setToken($token);
$this->_pro->submitRecurringProfile($profile, $paymentInfo);
}