简体   繁体   English

PayPal:检查订阅者是否为订阅付费

[英]PayPal: After Check whether subscriber is paid for subscription

I'm creating website using reactjs for frontend and for backend I'm using c# asp .net mvc.我正在使用 reactjs 为前端和后端创建网站,我正在使用 c# asp .net mvc。 I have already integrated paypal subscription in whichevery month fixed amount deducted form his account(which I have already done) by following this link https://medium.com/analytics-vidhya/paypal-subscription-in-react-1121c39b26be .我已经通过点击此链接https://medium.com/analytics-vidhya/paypal-subscription-in-react-1121c39b26be ,将 paypal 订阅集成到每个月从他的帐户中扣除的固定金额(我已经完成)。 and here is my code.这是我的代码。

window.paypal.Buttons({
            style: {
                shape: 'rect',
                color: 'gold',
                layout: 'vertical',
                label: 'subscribe'
            },
            createSubscription: function(data, actions) {
              return actions.subscription.create({
                'plan_id': 'my-plan-id'
              });
            },
            onApprove: function(data, actions) {
              alert(data.subscriptionID);
              console.log(data)
            },
            onError: (err) => {
                console.log(err)
            }
        }).render(paypal.current)

but my requirement is when user login first time user must provide his paypal account details and after providing paypal account info check user has sufficient amount in his account proceed to dashboard.但我的要求是,当用户第一次登录时,用户必须提供他的 paypal 帐户详细信息,并在提供 paypal 帐户信息后检查用户帐户中是否有足够的金额进入仪表板。 But my problem is how to handle if user has no balance in his account or unpaid and in this case after login user redirected to specific page not dashboard.但我的问题是如何处理用户帐户中没有余额或未付款的情况,在这种情况下,登录用户重定向到特定页面而不是仪表板后。

In short: how to check user is paid or unpaid if paid proceed to dashboard else redirect to specific page.简而言之:如何检查用户是否已付费,如果付费继续到仪表板,否则重定向到特定页面。

how to check user is paid or unpaid if paid proceed to dashboard else redirect to specific page.如何检查用户是否已付费或未付费,如果已付费继续到仪表板,否则重定向到特定页面。

The answer to this is to consult your database, which should have this information stored (whether a payment has been made, or whether the subscription is current) and allow you to determine what to do based on the information you have.对此的答案是查阅您的数据库,该数据库应存储此信息(是否已付款,或订阅是否是最新的),并允许您根据您拥有的信息确定要做什么。

So your real question must be how to receive notifications from PayPal that a subscription payment has been made.因此,您真正的问题一定是如何接收来自 PayPal 的关于已支付订阅费用的通知。 For that, I will refer you to the answer in here: How do you know if a user has paid for a subscription为此,我将向您推荐此处的答案: 您如何知道用户是否已支付订阅费用

As for how to match subscription payments to users -- when a subscription is created, you can store its ID associated with your user, which is easiest to do if you activate the subscription from the server as discussed above.至于如何将订阅付款与用户匹配 - 创建订阅时,您可以存储与您的用户相关联的 ID,如果您如上所述从服务器激活订阅,这是最容易做到的。 You can also pass a custom_id field during subscription creation, which can contain your own user ID for reconciliation.您还可以在订阅创建期间传递custom_id字段,该字段可以包含您自己的用户 ID 以进行协调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM