2015-04-07 66 views
0

我正在使用Angelleye Paypal類來設置快速結賬。 使用演示我可以接受一個付款給我自己的多個項目。 我有一個代表人們做廣告的網站,並且建立購物車並將價值分解爲每個賣家的數組。使用Angelleye Paypal Express並行付款的結帳類

如何使用SetExpressCheckout.php爲接收器創建數組。

這是陣列的演示中,我從車中

Array 
(
[102340] => Array 
    (
     [name] => Mandy 
     [paypal] => [email protected] 
     [artwork] => Array 
      (
       [data_id] => Array 
        (
         [0] => 1034 
         [1] => 1038 
        ) 

       [name] => Array 
        (
         [0] => Pink Foxgloves 
         [1] => Big Red Poppies 
        ) 

       [qty] => Array 
        (
         [0] => 1 
         [1] => 1 
        ) 

       [price] => Array 
        (
         [0] => 260 
         [1] => 288 
        ) 

      ) 

     [amount] => 548 
    ) 

[102341] => Array 
    (
     [name] => John C 
     [paypal] => [email protected] 
     [artwork] => Array 
      (
       [data_id] => Array 
        (
         [0] => 1052 
        ) 

       [name] => Array 
        (
         [0] => Success 
        ) 

       [qty] => Array 
        (
         [0] => 1 
        ) 

       [price] => Array 
        (
         [0] => 46.75 
        ) 

      ) 

     [amount] => 46.75 
    ) 

) 

所以baiscally小敏已經售出的2項:

編號:1034姓名:粉色毛地黃數量:1小計:260.00

編號:1038姓名:大紅色的罌粟數量:1只小計:288.00

約翰已經售出

編號:1052姓名:成功數量:1只小計:46.75

我也有總:594.75

如果我能在快速結賬接收機這將是很好,如果我也能獲得他們的物品以及這將是非常好的。

在此先感謝。

回答

0

因此,經過研究,並沒有太大的幫助,我通過試錯找到了答案。

在setexpresscheckout腳本中,我不得不圍繞付費數組區域執行foreach循環。

此區域將具有配方電子郵件/ paypal id貨幣金額和唯一付款申請ID。

在這個循環中我然後圍繞物品運行另一個循環並生成從該賣家購買的物品列表。

然後,我將這一切都設置爲一個數組,這是通常發送給單個賣家的數組。

繼承人我的代碼,但顯然這是非常具體到我的任務。

// setup the holding array for all the details 
$Payments = array(); 
foreach ($seller as $key => $value) { 
     // reset the items array for each recipient 
     $PaymentOrderItems = array(); 
     // setup each recipient details 
     $Payment = array(
      'currencycode'   => 'GBP', 
      'amt'     => $value['amount'], 
      'sellerpaypalaccountid' => $value['paypal'],  
      'paymentrequestid'  => 'Payment'.$key 
     ); 

     // loop through the products for each seller 
     foreach ($value['artwork'] as $akey) { 
      $Item = array(
       'number' => $akey['data_id'], 
       'desc'  => $akey['name'], 
       'qty'  => $akey['qty'], 
       'amt'  => round($akey['price'],2) 
      ); 
      // push this item into the item array for this recipient 
      array_push($PaymentOrderItems, $Item); 
     } 

     // add the item array to the payment array 
     $Payment['order_items'] = $PaymentOrderItems; 

     // push the payment array to the main payments array 
     array_push($Payments, $Payment); 
    } 

我希望這可以幫助那些想要使用快速結帳而不是適應性付款的班級的其他人。