2013-07-16 52 views
2

我目前正在爲網站構建場外付款解決方案。我正在使用CI-Merchant(我試圖使用Omnipay,但使用Composer不適合我)。Ci-Merchant - 使用PayPal Express進行Autorizing和後期捕獲付款

我目前正在這樣做(在我的控制器的方法)。另外請注意,我正在使用CI-Merchant的微調版本來允許向PayPal發送客戶的購物車。我只是做了這些變化:https://github.com/guillermofr/ci-merchant/commit/70ea1a2864971078b3b67e5ca1051be174f23fa0

在我的控制文件:

//The library and the settings are initialized before 
$this->merchant->initialize($this->APISettings); 

$order = array(
      array(
       'name' => 'Voyage 1', 
       'desc' => 'Relais du Plessis', 
       'amt' => 50.00, 
       'qty' => 1 
      ), 
      array(
       'name' => 'Voyage 2', 
       'desc' => 'Domaine St-Hilaire', 
       'amt' => 50.00, 
       'qty' => 1 
      ) 
); 

$this->session->set_userdata('order',$order); 

$params = array(
      'amount' => 100.00, 
      'currency' => 'EUR', 
      'items' => $order, 
      'return_url' => base_url().'api/reservation/validation_commande', 
      'cancel_url' => base_url().'api/reservation/annulation_commande' 
); 

$this->merchant->authorize($params); 

後來,在我的控制器(一個在付款的時候完成調用,return_url)的另一種方法:

$this->merchant->initialize($this->APISettings); 

$params = array(
     'amount' => 100.00, 
     'currency' => 'EUR', 
     'items' => $this->session->userdata('order'), 
     'return_url' => base_url().'api/reservation/validation_commande', 
     'cancel_url' => base_url().'api/reservation/annulation_commande' 
); 

$response = $this->merchant->authorize_return($params); 
var_dump($response); 

$gateway_reference = $response->reference(); 

我想要的只是保持卡的足跡,所以這就是爲什麼我得到的參考。

問題是,如果我想在稍後捕獲付款,我該怎麼辦?我知道調用的方法是$ this-> merchant-> capture();但我不知道在參數中傳遞什麼。

由於提前,

乾杯

回答

1

好吧,沒關係。我成功地安裝Omnipay(這是一個非常好的庫),而要做到這一點,我只是得到$ params數組,和我推到他transactionReference,通過

$response->getTransactionReference(); 

然後你只需要調用:

$response = $gateway->capture($params)->send(); 

和響應是好的!

+1

Yip是正確的。 CI商家的工作方式幾乎相同,您可以獲得$ response-> reference()並將其傳遞給$ gateway-> capture()。但是使用Omnipay是一個好主意,CI商家不再被支持。 –

+0

感謝這些令人敬畏的圖書館阿德里安,並感謝您的批准。 –