【问题标题】:How to integration Stripe payment gateway in codeigniter如何在 codeigniter 中集成 Stripe 支付网关
【发布时间】:2020-02-23 07:37:18
【问题描述】:

我想在 codeigniter 中集成条带支付网关。我以前使用条纹的核心php库,它工作正常,但在codeigniter中我如何在codeigniter中对其进行整数化。

我的文件如下: 观点:

<?php //echo form_open('vendor/stripe_charge'); ?>
                                <input type="text" name="data-key" value="<?php echo "pk_test_lWC3x0aqak9UBnQy6JnRTGOL";//echo $config['publishable_key']; ?>"/>
                                <input type="text" name="data-amount" value="5000"/>
                                <input type="text" name="data-description" value="Paying your bill"/>
                                <input type="text" name="data-name" value="Yummylicious"/>
                                <input type="text" name="data-image" value="http://interiorlounge.com.pk/wp-content/uploads/2013/04/logo_huawei_128x128.jpg"/>
                                <input type="text" name="data-label" value="Pay Your Bill"/>
                                <input type="submit" value="Pay Your Bill"/>
                            <!--
                              // optional parameters in javascript
                             data-shipping-address="true"
                            data-billing-address="true"  -->
                            <?php echo form_close(); ?>
"/>

控制器:

public function stripe_charge(){
        echo "stripe function working"."<br>";
        echo $this->input->post('amount');
        Stripe::setApiKey("sk_test_yDE2WSUQ3wexrlhqO01PeANe");
}

并发生错误: 条纹功能工作 致命错误:第 578 行的 D:\xamp\htdocs\halal_lte\application\controllers\vendor.php 中未找到“Stripe”类

【问题讨论】:

  • 试试\Stripe\Stripe::setApiKey('sk_test_yDE2WSUQ3wexrlhqO01PeANe');
  • 我实际上想知道在哪里放置库文件以及如何将它包含在我的项目中,因为它说我没有找到条带类,在我看来我没有把它放在正确的目录或链接不正确。
  • 你的 Stripe 课程在哪里??
  • 你能帮我吗@abdullahshoaib

标签: php codeigniter stripe-payments


【解决方案1】:

然后将条带库放入系统/库中

$stripe = array( "secret_key" => STRIPE_SECRET_KEY, "publishable_key" => STRIPE_PUBLISHABLE_KEY ); try { \Stripe\Stripe::setApiKey($stripe['secret_key']); ---and do what you want to do--- } catch (\Stripe\Error\Card $e) { // Since it's a decline, \Stripe\Error\Card will be caught $body = $e->getJsonBody();`enter code here` $err = $body['error']; return $err['message']; } catch (\Stripe\Error\InvalidRequest $e) { // Invalid parameters were supplied to Stripe's API $body = $e->getJsonBody(); $err = $body['error']; return $err['message']; } catch (\Stripe\Error\Authentication $e) { // Authentication with Stripe's API failed // (maybe you changed API keys recently) $body = $e->getJsonBody(); $err = $body['error']; return $err['message']; } catch (\Stripe\Error\ApiConnection $e) { // Network communication with Stripe failed $body = $e->getJsonBody(); $err = $body['error']; return $err['message']; } catch (\Stripe\Error\Base $e) { // Display a very generic error to the user, and maybe send // yourself an email $body = $e->getJsonBody(); $err = $body['error']; return $err['message']; } catch (Exception $e) { // Something else happened, completely unrelated to Stripe $body = $e->getJsonBody(); $err = $body['error']; return $err['message']; }</pre>

【讨论】:

  • 我实际上想知道在哪里放置库文件以及如何将它包含在我的项目中,因为它说我没有找到条带类,在我看来我没有把它放在正确的目录或链接不正确。
  • 将条带库放入系统/库
  • 在system/libararies下创建一个文件夹Stripe,从github.com/stripe/stripe-php/archive/v3.0.0.zip这里下载stripe库并将内容解压到“Stripe”文件夹中
  • 你能帮我吗? @JasbirSinghSohanpal
【解决方案2】:

如果没有,请下载 stripe.php 并将其放入 app/protected/components。组件应该从main.php自动加载

'import'=>array(
        ..
        'application.components.*',
        ..
    ),

现在你可以使用

Stripe::setApiKey("sk_test_yDE2WSUQ3wexrlhqO01PeANe");

【讨论】:

    【解决方案3】:

    如果您已经准备好库,则需要将其放在应用程序/库文件夹中。

    我建议你解压缩计算机上的所有文件,也许你会有配置文件,你需要把它们放在配置文件夹中,你需要检查 readme.md 文件以获取所有需要的信息。

    你需要检查也许你需要 PHP(Composer) 的依赖管理

    运行该库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-07
      • 2016-01-04
      • 2017-02-28
      • 2020-10-26
      • 2018-12-17
      • 2020-09-24
      • 2019-05-04
      • 1970-01-01
      相关资源
      最近更新 更多