[英]How to integration Stripe payment gateway in codeigniter
我想在 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 中未找到 Class 'Stripe'
将条带库放入系统/库中,然后
$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>
如果没有,请下载stripe.php并将其放入app/protected/components
。 组件应该从main.php
自动加载
'import'=>array(
..
'application.components.*',
..
),
现在你可以使用
Stripe::setApiKey("sk_test_yDE2WSUQ3wexrlhqO01PeANe");
如果你已经准备好了库,那么你需要把它放在应用程序/库文件夹中。
我建议你解压缩你电脑上的所有文件,也许你会有配置文件,你需要把它们放在 config 文件夹中,你需要查看 readme.md 文件来获取所有需要的信息。
你需要检查一下,也许你需要 PHP 的依赖管理(作曲家)
运行该库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.