喜大普奔,苹果可以推送退款通知了

背景

 最新的WWDC2020苹果爸爸终于添加一个功能,就是可以实时的推送退款订单号给开发者,以便开发即使针对玩家退款做处理,减少损失,这个功能一出,我也第一时间研究了一番,这里也跟大家分享下

如何配置

苹果爸爸给出推送退款的功能,是 server to server,所以我们需要将接收退款通知推送的接口填入苹果后台

位置如下

 

只要这个接口请求的时候不会报404,503,500这一类的错误,正常返回200就行

数据结构

我这边已经抓到了苹果退款的数据,数据格式如下,供大家参考,具体字段意思可以查看苹果文档:https://developer.apple.com/documentation/appstoreservernotifications

{
    "notification_type": "REFUND",
    "password": "",
    "environment": "PROD",
    "latest_receipt": "",
    "latest_receipt_info": {
        "cancellation_reason": "0",
        "is_trial_period": "false",
        "is_in_intro_offer_period": "false",
        "unique_identifier": "",
        "unique_vendor_identifier": "",
        "cancellation_date": "2020-06-29 14:53:14 Etc/GMT",
        "cancellation_date_ms": "1593442394000",
        "cancellation_date_pst": "2020-06-29 07:53:14 America/Los_Angeles",
        "purchase_date": "2020-05-15 09:28:35 Etc/GMT",
        "purchase_date_ms": "1589534915000",
        "purchase_date_pst": "2020-05-15 02:28:35 America/Los_Angeles",
        "original_purchase_date": "2020-05-15 09:28:35 Etc/GMT",
        "original_purchase_date_ms": "1589534915000",
        "original_purchase_date_pst": "2020-05-15 02:28:35 America/Los_Angeles",
        "item_id": "",
        "app_item_id": "",
        "version_external_identifier": "",
        "bid": "",
        "product_id": "",
        "transaction_id": "",
        "original_transaction_id": "",
        "quantity": "1",
        "bvrs": ""
    },
    "unified_receipt": {
        "status": 0,
        "environment": "Production",
        "latest_receipt_info": [
            {
                "quantity": "1",
                "product_id": "",
                "transaction_id": "",
                "purchase_date": "2020-05-15 09:30:02 Etc/GMT",
                "purchase_date_ms": "1589535002000",
                "purchase_date_pst": "2020-05-15 02:30:02 America/Los_Angeles",
                "original_purchase_date": "2020-05-15 09:30:02 Etc/GMT",
                "original_purchase_date_ms": "1589535002000",
                "original_purchase_date_pst": "2020-05-15 02:30:02 America/Los_Angeles",
                "is_trial_period": "false",
                "original_transaction_id": "",
                "cancellation_date": "2020-06-29 14:53:14 Etc/GMT",
                "cancellation_date_ms": "1593442394000",
                "cancellation_date_pst": "2020-06-29 07:53:14 America/Los_Angeles",
                "cancellation_reason": "0"
            }
        ],
        "latest_receipt": ""
    },
    "bid": "",
    "bvrs": ""
}

主要是先判断notification_type是否为REFUND,然后拿外层的 latest_receipt_info里的original_transaction_id字段来去自己订单库里找对应的苹果订单,这样就能知道是哪个用户退款,并对其做相应的资源追回,减少损失,甚至于可以针对有恶意刷退的黑产进行风控,终于可以狠狠的打击这些黑产刷退薅羊毛的工作室了

附上苹果相关文档

新发布的功能文档:https://developer.apple.com/news/

如何配置接收通知文档:https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/enabling_server-to-server_notifications

这里其实和订阅是一样操作的,接收推送的地址和接收订阅通知的填写地址也是一样的,所以这个接收通知的接口要对notification_type 这个字段进行判断并区分是哪种回调,然后用不同方式处理数据

如何处理通知:https://developer.apple.com/documentation/storekit/in-app_purchase/handling_refund_notifications

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页