【问题标题】:Ci-Merchant - Autorizing and later capturing a payment with PayPal ExpressCi-Merchant - 使用 PayPal Express 自动处理并随后捕获付款
【发布时间】:2013-07-16 12:02:17
【问题描述】:

我目前正在为网站构建一个异地支付解决方案。我正在使用 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();但我不知道该传递什么参数。

提前致谢,

干杯

【问题讨论】:

    标签: php codeigniter codeigniter-2 ci-merchant


    【解决方案1】:

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

    将 transactionReference 推送给他
    $response->getTransactionReference();
    

    那么你只需要调用:

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

    反应还好!

    【讨论】:

    • 没错,没错。 CI-merchant 的工作方式几乎相同,你得到 $response->reference() 并将其传递给 $gateway->capture()。但是使用 Omnipay 是一个更好的主意,CI-merchant 不再受支持。
    • 感谢 Adrian 提供这些很棒的库,并感谢您的批准。
    猜你喜欢
    • 2017-08-18
    • 2013-01-16
    • 2011-11-24
    • 2015-11-11
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 2014-12-21
    相关资源
    最近更新 更多