2

我目前正在为网站构建一个异地支付解决方案。我正在使用 CI-Merchant(我尝试使用 Omnipay,但使用 Composer 对我不起作用)。

我目前正在这样做(在我的控制器的方法中)。另请注意,我使用的是 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(); 但我不知道传递什么参数。

提前致谢,

干杯

4

1 回答 1

1

好的没关系。我成功安装了 Omnipay(这是一个非常好的库),为此我只需获取 $params 数组,然后通过

$response->getTransactionReference();

然后你只需要打电话:

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

反应还可以!

于 2013-07-18T09:25:20.333 回答