从根本上来说,情况是,magento正在发出工资单。 该系统已经支付的账单(发票号码)。 由此可以支付回购,表明发票号码是重复的。 因此,我在这里做的是试图发现这一信息反应,产生新的命令,并重新提出支付再处理的费用。
这里的行动始于向magento发送信息的整个链条。 位于Mage_Paypal_Controller_ Express_Abstract 。 我修改了“薪棕榈”反应产生的信号。 该标注将包含有关所发生错误的信息。
startAction(){
...
$token = $this->_checkout->start(Mage::getUrl( */*/return ), Mage::getUrl( */*/cancel ));
if ($token && $url = $this->_checkout->getRedirectUrl()) {
$this->_initToken($token);
...
}
}
to:
startAction(){
...
$token = $this->_checkout->start(Mage::getUrl( */*/return ), Mage::getUrl( */*/cancel ));
//while this token is invalid
while (isset($token[ error ])) {
//generate a new token
$token = $this->_checkout->start(Mage::getUrl( */*/return ),Mage::getUrl( */*/cancel ), TRUE);
}
if ($token[ token ] && $url = $this->_checkout->getRedirectUrl()) {
$this->_initToken($token[ token ]);
...
}
}
This token is generated by the start() method in Mage_Paypal_Model_Express_Checkout . start() also handles the entire process of object manipulation. Here, we will conditionally alter the productId.
the modified function will look like this:
public function start($returnUrl, $cancelUrl, $errorAgain = FALSE)
{
$this->_quote->collectTotals();
if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) {
Mage::throwException(Mage::helper( paypal )->__( PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process. ));
}
if ($errorAgain) {
Mage::log( why is this running? );
$this->_quote->setReservedOrderId($this->_quote->getReservedOrderId($this->_quote));
$this->_quote->reserveOrderId()->save();
}
//$this->_quote->setReservedOrderId($this->_quote->_getResource()->getReservedOrderId($this->_quote));
//$this->_quote->setReservedOrderId($this->_quote->getReservedOrderId($this->_quote));
$this->_quote->reserveOrderId()->save();
// prepare API
$this->_getApi();
$this->_api->setAmount($this->_quote->getBaseGrandTotal())
->setCurrencyCode($this->_quote->getBaseCurrencyCode())
->setInvNum($this->_quote->getReservedOrderId())
->setReturnUrl($returnUrl)
->setCancelUrl($cancelUrl)
->setSolutionType($this->_config->solutionType)
->setPaymentAction($this->_config->paymentAction)
;
if ($this->_giropayUrls) {
list($successUrl, $cancelUrl, $pendingUrl) = $this->_giropayUrls;
$this->_api->addData(array(
giropay_cancel_url => $cancelUrl,
giropay_success_url => $successUrl,
giropay_bank_txn_pending_url => $pendingUrl,
));
}
$this->_setBillingAgreementRequest();
if ($this->_config->requireBillingAddress == Mage_Paypal_Model_Config::REQUIRE_BILLING_ADDRESS_ALL) {
$this->_api->setRequireBillingAddress(1);
}
// supress or export shipping address
if ($this->_quote->getIsVirtual()) {
if ($this->_config->requireBillingAddress == Mage_Paypal_Model_Config::REQUIRE_BILLING_ADDRESS_VIRTUAL) {
$this->_api->setRequireBillingAddress(1);
}
$this->_api->setSuppressShipping(true);
} else {
$address = $this->_quote->getShippingAddress();
$isOverriden = 0;
if (true === $address->validate()) {
$isOverriden = 1;
$this->_api->setAddress($address);
}
$this->_quote->getPayment()->setAdditionalInformation(
self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN, $isOverriden
);
$this->_quote->getPayment()->save();
}
// add line items
$paypalCart = Mage::getModel( paypal/cart , array($this->_quote));
$this->_api->setPaypalCart($paypalCart)
->setIsLineItemsEnabled($this->_config->lineItemsEnabled)
;
// add shipping options if needed and line items are available
if ($this->_config->lineItemsEnabled && $this->_config->transferShippingOptions && $paypalCart->getItems()) {
if (!$this->_quote->getIsVirtual() && !$this->_quote->hasNominalItems()) {
if ($options = $this->_prepareShippingOptions($address, true)) {
$this->_api->setShippingOptionsCallbackUrl(
Mage::getUrl( */*/shippingOptionsCallback , array( quote_id => $this->_quote->getId()))
)->setShippingOptions($options);
}
}
}
// add recurring payment profiles information
if ($profiles = $this->_quote->prepareRecurringPaymentProfiles()) {
foreach ($profiles as $profile) {
$profile->setMethodCode(Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS);
if (!$profile->isValid()) {
Mage::throwException($profile->getValidationErrors(true, true));
}
}
$this->_api->addRecurringPaymentProfiles($profiles);
}
$this->_config->exportExpressCheckoutStyleSettings($this->_api);
// call API and redirect with token
$response = $this->_api->callSetExpressCheckout();
$token[ token ] = $this->_api->getToken();
$this->_redirectUrl = $this->_config->getExpressCheckoutStartUrl($token[ token ]);
if ($response == duplicate ) {
$token[ error ] = duplicate ;
return $token;
} elseif (isset($token[ error ])) {
unset($token[ error ]);
}
$this->_quote->getPayment()->unsAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
$this->_quote->getPayment()->save();
return $token;
}
现在,最后一部分处理实际工资要求和反应。 这样做是因为Mage_Paypal_Model_Api_Nvp。
After the response is generated we shall check for the error response and, instead of redirecting, we shall simply return it up the chain.
位于997线以下:
if ($response[ L_SHORTMESSAGE0 ] == Duplicate invoice ) {
return $response;
}
顺便提一下:
startaction()->start()->call()->start()->startaction()->redirect();
如果存在重复的录用错误,它将这样做。
startaction()->start()->call(error)->start()->call()->start()->staraction()->redirect();
让我知道,你是否有任何问题。