2016-03-03 113 views
2

如何查看eway進行的當前交易以及如果支付成功,我如何更新過期日期和時間。eWay支付網關定期支付

是否有任何函數來檢查eway所做的最近交易。

$requestbody = array(
      'RebillCustomerID' => $rebillCustomerID, 
      'RebillID' => $rebillID 
     ); 
     $client = $this->createObjet(); 
     return $result = $client->QueryTransactions($requestbody); 

我使用這個,但在返回所有交易細節。 如果還有其他選擇,請幫助我。

回答

1

沒有一個API只返回eWAY經常性的最新事務。您可以通過查找任何非「待定」或「未來」交易的最近交易時間來查找當前交易。

這樣做會去爲一個簡單的例子如下:

$requestbody = array(
    'RebillCustomerID' => $rebillCustomerID, 
    'RebillID' => $rebillID 
); 

$result = $client->QueryTransactions($requestbody); 

$current = mostRecent($result); 

function mostRecent ($result){ 
    $return = ''; 
    foreach ($result->QueryTransactionsResult->rebillTransaction as $r) { 
     $mostRecent = 0; 
     if ($r->Status != 'Pending' && $r->Status != 'Future') { 
      $curDate = strtotime($r->TransactionDate); 
      if ($curDate > $mostRecent) { 
       $mostRecent = $curDate; 
       $return = $r; 
      } 
     } 
    } 
    return $return; 
}