【问题标题】:How to know when a customer charged for his subscription in Chargify如何知道客户何时在 Chargify 中为其订阅收费
【发布时间】:2014-05-01 08:55:17
【问题描述】:

我正在使用 Chargify API (https://github.com/jforrest/Chargify-PHP-Client/),我们有成千上万的客户每月订阅,所以他们在特定日期收费,我使用的是每天检查订阅的 cron

问题是我们错过了一个订阅,如果它不能在假设收费的日期收费。有时,由于帐户中没有资金或卡发生任何原因导致延迟几天,客户卡无法扣款。

我想知道客户卡何时在 chargify 中收费,以便那时我可以生成一个新订单,我使用了上面的 PHP 库,但找不到可以获取我信息的函数。

任何人都可以帮助解决此问题或解决此问题的任何其他解决方案吗?

谢谢

【问题讨论】:

  • 有没有人有机会解决上述问题...?

标签: php api chargify


【解决方案1】:

Chargify 有一个专门称为“Webhooks”的功能(就像 Paypal、Stripe 等)。只要客户的订阅有活动(如每月续订),Chargify 就会直接向您的服务器发送 POST 请求以提醒您。

具体文档在这里:https://docs.chargify.io/webhooks

无需 cron 作业!

【讨论】:

【解决方案2】:

您可以通过 webhook 设置并在客户收费后立即获取所有信息,为此您需要在您的服务器上设置 webhook url,然后将其添加到 chargify 帐户,登录后转到 Settings -> Webhooks -> Add url for示例:

http://www.domain.com/webhooks/

在“webhooks”目录下创建 index.php 文件,你会从 chargify 得到一个数组,如下所示:

Array
(
    [id] => 29660474
    [event] => renewal_success
    [payload] => Array
        (
            [subscription] => Array
                (
                    [activated_at] => 2014-12-12 06:11:51 -0500
                    [balance_in_cents] => 1900
                    [cancel_at_end_of_period] => false
                    [canceled_at] => 
                    [cancellation_message] => 
                    [created_at] => 2014-12-12 06:11:40 -0500
                    [current_period_ends_at] => 2015-02-12 06:11:40 -0500
                    [expires_at] => 
                    [id] => 7231335
                    [next_assessment_at] => 2015-02-12 06:11:40 -0500
                    [payment_collection_method] => automatic
                    [snap_day] => 
                    [state] => active
                    [trial_ended_at] => 
                    [trial_started_at] => 
                    [updated_at] => 2015-01-12 06:22:21 -0500
                    [current_period_started_at] => 2015-01-12 06:11:40 -0500
                    [previous_state] => active
                    [signup_payment_id] => 78110242
                    [signup_revenue] => 19.00
                    [delayed_cancel_at] => 
                    [coupon_code] => 
                    [total_revenue_in_cents] => 1900
                    [product_price_in_cents] => 1900
                    [product_version_number] => 6
                    [payment_type] => credit_card
                    [customer] => Array
                        (
                            [address] => xx xxxx place Success
                            [address_2] => 
                            [city] => Perth
                            [country] => AU
                            [created_at] => 2014-12-12 06:11:39 -0500
                            [email] => xxxxxxx@hotmail.com
                            [first_name] => Jay
                            [id] => 7093037
                            [last_name] => Gable
                            [organization] => Large
                            [phone] => xxxxxxxx
                            [portal_customer_created_at] => 2014-12-12 06:11:52 -0500
                            [portal_invite_last_accepted_at] => 
                            [portal_invite_last_sent_at] => 
                            [reference] => 548acd6a8ef3a
                            [state] => WA
                            [updated_at] => 2014-12-12 06:11:52 -0500
                            [verified] => false
                            [zip] => 6164
                        )
                    [product] => Array
                        (
                            [accounting_code] => 
                            [archived_at] => 
                            [created_at] => 2014-08-11 03:27:20 -0400
                            [description] => xxxx
                            [expiration_interval] => 
                            [expiration_interval_unit] => never
                            [handle] => monthly-subscription
                            [id] => 3493985
                            [initial_charge_in_cents] => 
                            [interval] => 1
                            [interval_unit] => month
                            [name] => 1 Pair Monthly
                            [price_in_cents] => 1900
                            [request_credit_card] => true
                            [require_credit_card] => true
                            [return_params] => 
                            [return_url] => 
                            [taxable] => false
                            [trial_interval] => 
                            [trial_interval_unit] => month
                            [trial_price_in_cents] => 
                            [update_return_url] => 
                            [updated_at] => 2014-12-11 17:09:41 -0500
                            [product_family] => Array
                                (
                                    [accounting_code] => 
                                    [description] => Standard Monthly Subscriptions
                                    [handle] => monthly-subscription
                                    [id] => 421701
                                    [name] => Australia
                                )
                            [public_signup_pages] => Array
                                (
                                    [id] => 100806
                                    [url] => xx
                                )
                        )
                    [credit_card] => Array
                        (
                            [billing_address] => xxxxx Success
                            [billing_address_2] => 
                            [billing_city] => Perth
                            [billing_country] => AU
                            [billing_state] => WA
                            [billing_zip] => 6164
                            [card_type] => master
                            [current_vault] => braintree_blue
                            [customer_id] => 7093037
                            [customer_vault_token] => 
                            [expiration_month] => 2
                            [expiration_year] => 2015
                            [first_name] => XXXX
                            [id] => 4693476
                            [last_name] => Gable
                            [masked_card_number] => XXXX-XXXX-XXXX-xxxx
                            [vault_token] => xxxxxx
                            [payment_type] => credit_card
                        )
                )
            [site] => Array
                (
                    [id] => xxxxx
                    [subdomain] => xxxxx
                )
        )
)

我希望这会有所帮助。

【讨论】:

    【解决方案3】:

    最简单的方法是将最后一次成功的交易日期存储在数据库中,并经常检查自上次使用 cron 或 mysql 事件调度程序更新以来是否已过去一个月,从未使用过 chargify,但 paypal api 可以与您的服务器通信并返回交易状态,您可以在您的网站上使用它来更新数据库

    【讨论】:

    • 我认为你没有完全阅读我的问题,我已经在数据库中保存交易日期。问题是通过 cron 了解 chargify 服务器上是否发生任何事务....?
    • 对不起,是的,你是对的,但关键是在收到 chargify api 的确认后保存一个成功交易的日期。据我所知,您不能使用您的 cron 扫描其他服务器!!!
    • 必须有一个触发器或通知或响应任何事情必须是了解交易。我想我应该向 Chargify 寻求支持
    • 那将是最好的方法,也许他们可以指导你完成整个过程,祝你好运。
    猜你喜欢
    • 2018-02-11
    • 2021-03-16
    • 2020-04-07
    • 2019-07-23
    • 2022-10-21
    • 1970-01-01
    • 2018-10-15
    • 2013-02-26
    • 1970-01-01
    相关资源
    最近更新 更多