2013-05-27 92 views
0

早上好!Magento如何使用Paypal管理訂購產品的付款?

我正在爲Magento商店(適用於Android)開發移動應用程序。我正在使用SOAP v1,並使用一些自定義方法創建了自定義模塊。該應用程序專注於最終客戶,因此,基本上,我正在開發一款應用程序,讓消費者從商店購買產品。 我知道如何使用Magento API將產品添加到購物車以及如何訂購,但是...

當我創建訂單時會發生什麼?

call($sessionId,"cart.order",array($shoppingCartId, null, $licenseForOrderCreation)); 

它假定負荷消費必須支付他訂購的產品,所以我不知道我怎樣才能得到貝寶URL,並在瀏覽器中打開它。 貝寶通知Magento商店,客戶支付產品?

我在這方面有點迷茫。
API文檔沒有解釋這部分,我認爲。

謝謝!

+1

我試圖做同樣的。我正在考慮使用當前的Paypal SDK來完成整個付款,並通過SOAP將付款ID發送到服務器以完成訂單,但我不知道這是否會起作用。考慮到你問這個問題以來的時間,也許你找到了解決辦法,是嗎? –

+0

我還沒有找到任何解決方案,對不起。 Magento文檔真的很糟糕。我被困在那個項目中,所以現在我沒有在這個項目上工作。無論如何,如果你找到任何方法使其發揮作用,如果你能與我聯繫,我會非常感激。祝你好運! – devrique

+1

好的,謝謝你的回答,如果我找到一種方法來做到這一點,我會在這裏與你分享;-) –

回答

0

如果您使用paypal_standard作爲付款方式。然後按照這些步驟。

  1. 使用付款方式下單作爲paypal_standard。

  2. 之後,通過貝寶標準sdk開始支付。

  3. 付款成功後,您可以創建自己的api,並通過它可以使用下面的代碼編輯以前創建的訂單。

    $appEmulation = Mage::getSingleton("core/app_emulation"); 
    $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); 
    $order = Mage::getModel("sales/order")->loadByIncrementId($incrementId); 
    $payment = $order->getPayment(); 
    $payment->setTransactionId($confirm->response->id) 
          ->setPreparedMessage("status : ".$confirm->response->state) 
          ->setShouldCloseParentTransaction(true) 
          ->setIsTransactionClosed(0) 
          ->registerCaptureNotification($order->getGrandTotal()); 
    $order->save(); 
    if($status == 0){ 
        $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING) 
         ->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING) 
         ->save(); 
    } 
    else{ 
        $order->setState(Mage_Sales_Model_Order::STATE_CANCELED) 
         ->setStatus(Mage_Sales_Model_Order::STATE_CANCELED) 
         ->save(); 
    } 
    if($order->canInvoice()){ 
        $invoice = Mage::getModel("sales/service_order", $order)->prepareInvoice(); 
        $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE); 
        $invoice->register(); 
        $transactionSave = Mage::getModel("core/resource_transaction") 
         ->addObject($invoice) 
         ->addObject($invoice->getOrder()); 
        $transactionSave->save(); 
    } 
    $comment = "status :".$confirm->response->state."<br>"; 
    $comment .= "transaction id :".$confirm->response->id."<br>"; 
    $comment .= "date :".$confirm->response->create_time."<br>"; 
    $comment .= "from :".$confirm->client->product_name."<br>"; 
    $order->setIsCustomerNotified(false); 
    $order->addStatusHistoryComment($comment); 
    $order->save(); 
    $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);