- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我最近在 CodeIgniter2 中实现了一个 PayPal IPN,使用 PayPal Lib .我正在使用该系统进行订阅。
我的数据库中有一张表,记录了数据库中所有的IPN请求。
出于某种原因,每次注册后,IPN 请求都无法正常通过。我倾向于获得一个 subscr_payment 和多个 subscr_signups,它们都具有相同的 subscr_id。由于显而易见的原因,它在系统内造成了数不清的麻烦。除此之外,IPN 请求的顺序不正确,有时我会在 subscr_signup 之前收到 subscr_payment - 这使得无法跟踪,因为注册中没有 subscr_id 以将其链接到用户。
我有谷歌,但在这方面找不到太多,我似乎有点反常。我想知道这是否与我正在使用的 PayPal Lib 有关,但我真的不想在 CodeIgniter 之外进行,因为我正在进行大量处理。下面是完整的 IPN 脚本。
class Paypal extends CI_Controller {
function _<em>construct()
{
parent::</em>_construct();
$this->load->library('paypal_lib');
}
<pre><code>function ipn()
{
$this->output->enable_profiler(TRUE);
$this->load->model('payments_model');
$this->load->model('paypal_model');
$this->load->model('users_model');
ob_start();
if ($this->paypal_lib->validate_ipn())
{
$paypal_id = $this->paypal_model->add_paypal_ipn($this->paypal_lib->ipn_data);
// Split the 'custom' field up, containing ID of temp user, ID of package and coupon
$custom = explode(';', $this->paypal_lib->ipn_data['custom']);
###
# subscription sign up
###
if($this->paypal_lib->ipn_data['txn_type'] == 'subscr_signup') {
// Activate user/move from temp > live
$this->users_model->move_temp($custom[0], $this->paypal_lib->ipn_data['subscr_id']);
} # end subscr_signup
###
# subscription payment
###
if($this->paypal_lib->ipn_data['txn_type'] == 'subscr_payment') {
// Grab the coupon info, if we have one
$discount = 1;
if(!empty($custom[2])){
$this->load->model('coupons_model');
$couponinfo = $this->coupons_model->get_coupon($custom[2]);
$discount = $couponinfo->discount;
}
// Grab the package info
$package = $this->packages_model->get_package($custom[1]);
$price = $package->monthly * $discount; // Calculate discount, 0.8 = 20% off
// Does the price calculated match the gross price? If not something fishy is going on, block it
if($price != $this->paypal_lib->ipn_data['mc_gross']){
mail(CONTACT_EMAIL, SITE_NAME.' failed payment attempt, possible hack', 'Price paid doesnt match price computed... paid: '.$this->paypal_lib->ipn_data['mc_gross'].' - price worked out: '.$price."\n\n".print_r($this->paypal_lib->ipn_data, true));
exit;
}
// Grab the user's details based on the subscr_id
$user = $this->users_model->get_user_by_subscr_id($this->paypal_lib->ipn_data['subscr_id']);
// Add payment to the payments table
$data = array(
'user_id' => $user->user_id,
'subscr_id' => $user->subscr_id,
'txn_id' => $this->paypal_lib->ipn_data['txn_id'],
'amount' => $this->paypal_lib->ipn_data['mc_gross'],
'package_id' => $custom[1],
'coupon' => (empty($custom[2]) ? '' : $custom[2])
);
$this->payments_model->add_payment($data);
// Set (forced) user as active, and update their current active package
$data1 = array(
'package_id' => $custom[1],
'active' => 1
);
$this->users_model->update_user($data1, $user->user_id);
} # end subscr_payment
###
# subscription failed/cancelled
###
if($this->paypal_lib->ipn_data['txn_type'] == 'subscr_cancel' || $this->paypal_lib->ipn_data['txn_type'] == 'subscr_failed') {
// Grab user
$user = $this->users_model->get_user_by_subscr_id($this->paypal_lib->ipn_data['subscr_id']);
// Make user inactive
$data = array('active' => 0);
$this->users_model->update_user($data, $user->user_id);
} # end subscr_cancel|subscr_failed
###
# subscription modified/payment changed
###
if($this->paypal_lib->ipn_data['txn_type'] == 'subscr_modify') {
// Grab the coupon info, if we have one
$discount = 1;
if(!empty($custom[2])){
$this->load->model('coupons_model');
$couponinfo = $this->coupons_model->get_coupon($custom[2]);
$discount = $couponinfo->discount;
}
// Grab the package info
$package = $this->packages_model->get_package($custom[1]);
$price = $package->monthly * $discount; // Calculate discount, 0.8 = 20% off
// Does the price calculated match the gross price? If not something fishy is going on, block it
if($price != $this->paypal_lib->ipn_data['mc_gross']){
mail(CONTACT_EMAIL, SITE_NAME.' failed payment attempt, possible hack', 'Price paid doesnt match price computed... paid: '.$this->paypal_lib->ipn_data['mc_gross'].' - price worked out: '.$price."\n\n".print_r($this->paypal_lib->ipn_data, true));
exit;
}
// Grab the user's details based on the subscr_id
$user = $this->users_model->get_user_by_subscr_id($this->paypal_lib->ipn_data['subscr_id']);
// Add payment to the payments table
$data = array(
'user_id' => $user->user_id,
'subscr_id' => $user->subscr_id,
'txn_id' => $this->paypal_lib->ipn_data['txn_id'],
'amount' => $this->paypal_lib->ipn_data['mc_gross'],
'package_id' => $custom[1],
'coupon' => (empty($custom[2]) ? '' : $custom[2])
);
$this->payments_model->add_payment($data);
// Set (forced) user as active, and update their current active package
$data1 = array(
'package_id' => $custom[1],
'active' => 1
);
$this->users_model->update_user($data1, $user->user_id);
} # end subscr_modify
}
}
</code></pre>
以下是针对每笔交易 (CSV) 对我的 IPN 进行调用的示例。
paypal_id,txn_id,subscr_id,txn_type,created
1,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:19:43
2,9XM95194MM564230E,I-FMUK0B5KJWKA,subscr_payment,2011-02-03 16:19:45
3,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:19:57
4,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:20:19
6,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:21:03
7,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:22:25
8,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:25:08
10,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:30:33
12,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 16:41:16
14,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 17:02:42
16,NULL,I-FMUK0B5KJWKA,subscr_signup,2011-02-03 17:45:26
最佳答案
考虑一下 - Paypal 是插入亵渎。现在重新审视这个问题。
这很可能不是您的错,也不是 CodeIgniter 或图书馆的错。 PayPal 非常不擅长以统一和及时的方式提供数据,它也很慢并且不能很好地将数据链接在一起。
我对您的建议是在进行回叫时将所有内容保存到 IPN 表中,甚至在进行 IPN 调用时给自己发送电子邮件。然后努力弄清楚 PayPal 实际发送给您的是什么,您想要什么,然后扔掉其余的。
我认为即使交易与您的网站无关,也会进行 IPN 调用。因此,如果您的祖母通过 PayPal 向您发送圣诞钱,它会出现在 IPN 回调中。
希望对您有所帮助。
关于php - PayPal IPN,很多注册,一次付款,都按错误的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4888436/
如果我的交易中的次要收款人没有 Paypal 帐户,会发生什么情况。他会收到要求他创建 Paypal 帐户的通知,还是 API 调用不会成功? 我几乎无法知道销售服务的用户在注册我的平台时是否有Pay
我们知道有这么多的支付网关服务提供商,即 Paypal ,moneybrookers,authorize.net以及许多国内和国际的支付网关提供商。现在,我的问题是,开发我们自己的支付网关服务以处理世
我们正在寻求替代我们对 Authorize.net 的使用。我花了很多时间查看 PayPal 文档,但找不到我的问题的明确答案: 使用 thousand 数十种不同的 PayPal API 可以在我们
我实际上是在为客户工作。我已经在网站上成功实现了 paypal pro,并且一切正常,我相信我遵循了他们的流程和指南,使它按照他们的意思工作。 因此,我一直在阅读 this webpage将网站投入生
我有2件商品要出售。我的运输底价为7.50美元,每增加一个项目,则为2.00美元 我已经设置了高级代码 运费= $ 7.50 运费2 = $ 2.00 一切正常,除非在购物车中添加了其他商品后,购物车
我想在不使用购物车的情况下实现一个不太复杂的解决方案。 我在自己对这个问题的回答中详细说明了解决方案,但如果有人能提出更好的方法,我会很高兴。 谢谢 最佳答案 实际上我最近不得不这样做。毫无疑问,我的
我创建了一个带有默认支付网关的shopify 小商店,即paypal express checkout。 当客户点击 Paypal 结帐按钮时,他们被要求输入他们的信用卡号并输入电子邮件并选择密码以注
一段时间以来,我一直在运行一个网站,该网站通过向 Paypal 网站发送一个 notify_url 来记录 Paypal 交易,并监听该 notify_url。我的监听页面解析从 paypal 发送的
我在网络应用程序中使用 PayPal Subscribe 按钮。我想将订阅开始日期传递给 PayPal,这不会总是今天的日期。 通常情况下,如果没有有效订阅,PayPal 会创建一个从今天开始的订阅。
大家好,我遇到了“立即购买”paypal 按钮这个令人沮丧的问题。 我希望我的客户能够通过 paypal 使用借记卡/信用卡付款,而无需创建 paypal 帐户,同时我希望能够根据产品类型将不同的定价
我想实现 paypal 授权并自动获取付款。我用过 Paypal 标准账户。我已发送带有授权参数的付款请求。
我想在我的 Paypal 沙盒账户中测试批量支付。根据 paypal 文档,它描述了将资金转移到 paypal 帐户的步骤。但我想转账到我客户的银行账户。我该怎么做? 仅供引用:PayPal 文档内容
我正在尝试登录我的沙盒帐户(使用 chrome),但由于 paypal 的新变化我不能。 Paypal 现在要求我登录开发者网站。我愿意。 然后我转到应用程序->沙盒帐户,然后按“sanbox 站点”
我有一个支持 Paypal 付款的 opencart 系统。是否有允许用户(信用卡)付款而无需强制注册 Paypal 帐户的选项。到目前为止,我使用的是 paypal 标准模块。 最佳答案 使用 Pa
我可以使用 Paypal ID 和密码使用 Paypal 详细信息进行付款而无需重定向到 Paypal 网站吗?我想在不离开我的网站的情况下完成所有付款流程。谢谢 最佳答案 您可以使用 PayFlow
当我尝试 https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamicimage 时,图像损坏了. 这是返回的错误信息: “尝试为应用程序构建 prote
我想向我的客户付款,为此我收到了他们的电子邮件,我想验证电子邮件地址是否存在于 paypal 中! 我搜索并找到了我尝试过的支付身份 API,但它只提供了我的我的数据!这是 LINK那个 API。 我
当从用户的 PayPal 账户中扣款时,PayPal 服务器在一定时间内没有响应(超时)。我们决定假设钱确实已经被拿走了,所以我们会退款。但是,如果钱没有从用户账户中扣除会怎样? PayPal返回什么
我有一个网站可以定期(比如每周一次)从客户那里收到钱。我将我的客户详细信息存储在我的数据库中,我想从我的客户帐户中提取资金,而不是每次都提示他们进行身份验证。金额会因客户而异。我怎样才能用 pay p
我有一个表格,其中一个团队签下他们的球员,然后被运送到 Paypal 进行注册付款,然后当一切都完成后我会收到一个 IPN。我正在做一个类似的表格,发现自从我创建该表格以来,Paypal 发生了很大变
我是一名优秀的程序员,十分优秀!