碎时UP
碎时UP
  • 发布:2023-02-03 15:44
  • 更新:2023-02-08 18:26
  • 阅读:1070

【报Bug】uniapp 支付 苹果内购 补单方法restoreCompletedTransactions 无法获取之前传的userName 导致无法成功补单

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10

HBuilderX类型: 正式

HBuilderX版本号: 3.6.18

手机系统: iOS

手机系统版本号: iOS 15

手机厂商: 苹果

手机机型: 13pro max

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

restoreCompletedTransactions
调用补单方法即可

预期结果:

携带userName

实际结果:

未携带之前传的userName

bug描述:

补单方法无法获得之前传递的userName

2023-02-03 15:44 负责人:DCloud_iOS_WZT 分享
已邀请:
碎时UP

碎时UP (作者)

没有官方回答么?

碎时UP

碎时UP (作者)

1111

DCloud_iOS_WZT

DCloud_iOS_WZT

支付的时候如果带了username 那么restore也需要携带 需要你传入username 没有从接口里获取username这一说 文档里也没这么写过

  • 碎时UP (作者)

    没理解你的意思,首先我首次下单支付,传了我们的订单Id到UserName里面,此时发生了丢单,那么我从restore里面查询出来丢单的订单是不是也应该携带我首次下单传进去的订单Id呢?否则我怎么在补单的时候找到我们的业务订单更新支付状态呢?

    2023-02-03 22:03

  • DCloud_iOS_WZT

    回复 碎时UP: 你理解错了 要告诉苹果去查哪个username的丢单数据 username是你当前的用户信息 你哪个用户登录的你自己不知道么

    2023-02-06 11:33

  • DCloud_iOS_WZT

    回复 碎时UP: 丢单应该是下次启动app 或者下次购买时去查 立即查不一定能查到

    2023-02-06 11:40

  • 碎时UP (作者)

    回复 DCloud_iOS_WZT: 我能知道哪个用户 但是如果同时发生了两笔丢单我该怎么区分这两笔订单对应我的哪两笔业务订单呢?

    2023-02-06 17:31

  • DCloud_iOS_WZT

    回复 碎时UP: 根据苹果的支付凭据

    2023-02-06 19:17

  • 碎时UP (作者)

    回复 DCloud_iOS_WZT: 因为用户中途退出了前端的支付方法还没有获得回调所以我的服务端也不可能记录下苹果的支付凭证不是么

    2023-02-06 20:00

  • DCloud_iOS_WZT

    回复 碎时UP: username是苹果用来防止作弊的 其实不是用来传输你的业务数据的 首先一定要设置为手动关单 没有关闭的订单 如果支付成功没收到回调那么一定会在restore里查到 每次启动去restore 传入username检查该用户的购买记录 如果验证成功凭据再去关联或者生成你的业务订单号

    2023-02-06 20:26

  • 碎时UP (作者)

    回复 DCloud_iOS_WZT: 那我明白了,感谢回复。吐槽一下 苹果除了硬件其他都太难用了

    2023-02-07 11:16

  • DCloud_iOS_WZT

    回复 碎时UP: 苹果内购流程确实与其他支付差别比较大 可以先了解一下内购流程 https://tech.gotokeep.com/post/2018/12/in-app-purchase/

    2023-02-07 11:31

  • 碎时UP (作者)

    回复 DCloud_iOS_WZT: {

    "payment": {

    "productid": "vip_1d",

    "quantity": "1"

    },

    "transactionDate": "2023-02-08 08:13:14",

    "transactionIdentifier": "2000000270070422",

    "transactionReceipt": "MIITtgYJKoZIhvcNAQcCoIITpzCCE6MCAQExCzAJBgUrDgMCGgUAMIIDVwYJKoZIhvcNAQcBoIIDSASCA0QxggNAMAoCAQgCAQEEAhYAMAoCARQCAQEEAgwAMAsCAQECAQEEAwIBADALAgELAgEBBAMCAQAwCwIBDwIBAQQDAgEAMAsCARACAQEEAwIBADALAgEZAgEBBAMCAQMwDAIBCgIBAQQEFgI0KzAMAgEOAgEBBAQCAgEAMA0CAQMCAQEEBQwDMzEwMA0CAQ0CAQEEBQIDAnIsMA0CARMCAQEEBQwDMS4wMA4CAQkCAQEEBgIEUDI1NjAWAgECAgEBBA4MDGNuLnNob3VxaWxhaTAYAgEEAgECBBCrbc4mbsZSWAKwEwdIivIeMBsCAQACAQEEEwwRUHJvZHVjdGlvblNhbmRib3gwHAIBBQIBAQQU5eDXRHiM3Xq3z8/tNO8oaDgwcdQwHgIBDAIBAQQWFhQyMDIzLTAyLTA4VDAwOjU3OjQwWjAeAgESAgEBBBYWFDIwMTMtMDgtMDFUMDc6MDA6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BdAVhEedNO3iyM7R6PVbyTi69G3cN8PReEnyvFteO3ntRcXqNx+IjXKJdXZD9Zr1KIkIxH3oayPc4FgxhtbCS+SsvhESPBgOJ4V9T0mZyCKM2r3DYLP3uujL/lTaltkwGMzd/c6ByxW69oPIQ7aunMZT7XZNn/Bh1XZp5m5MkL72NVxnn6hUrcbvZNCJBIqxw8dtk2cXmPIS4AXUKqK1drk/NAJBzewdXUhMYIByzCCAccCAQEwgaMwgZYxCzAJBgNVBAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkCCA7rV4fnngmNMAkGBSsOAwIaBQAwDQYJKoZIhvcNAQEBBQAEggEACJfYaD6nrE8gj8ePU7RVBtsXUlP6Q1VZD+JhxE5XxN6JQE/tiN0ehJ7Q0LQZCCORIzslh/CnJe34IaDOwI5wRAY+t8QJDAxXqh7OPNkh9PKwyxXsPQsk/987eJqPdIgkGhhdbz6aOcYoePoY3OgXPAhbpfkVp3bjSaoePcdB1Z6Awa24dNK8PSHYQ35+YdhUrUqzyrwM35m7Vy1bW1QmpyIy9deU4gQgv7Azc7Di0z0pgJZ+WKwQXIGvfCEYMOMQkBEp176ys4bLe0XwnysNr1wJfEqZ7CY67/CB5REENWd+hGoktdCnJHkCZi0HFTD4OpS7R5L7zVGXKh6ACqEsyA==",

    "transactionState": "1"

    }

    2023-02-08 09:13

  • 碎时UP (作者)

    回复 DCloud_iOS_WZT: 帮忙看下我二次验证票据一直21002 不管是我直接使用postman还是后台请求都是21002,上面是支付成功回调的原始报文你看看

    2023-02-08 09:14

  • 碎时UP (作者)

    这个代发没有动不知什么原因引起的

    2023-02-08 09:36

  • DCloud_iOS_WZT

    回复 碎时UP: 21002是收据格式不对

    2023-02-08 10:59

  • DCloud_iOS_WZT

    回复 碎时UP: 你购买的是什么类型的商品? 如果是自动续期订阅 需要传password 是不是没传password

    2023-02-08 11:06

  • 碎时UP (作者)

    回复 DCloud_iOS_WZT: 能给个联系方式么?问题头疼好久了,这块代码完全没改突然就都21002了 不是订阅支付 我用我之前返回的报文进行验证就可以 用现在生成的报文就不行

    2023-02-08 11:16

  • 碎时UP (作者)

    回复 DCloud_iOS_WZT: 临近上线了 求帮忙

    2023-02-08 11:17

  • DCloud_iOS_WZT

    回复 碎时UP: 沙箱环境 同一个商品只能购买一次 你换个没买过的测试

    2023-02-08 11:46

  • DCloud_iOS_WZT

    回复 碎时UP: https://uniapp.dcloud.net.cn/api/plugins/payment.html#iap 看下注意事项

    2023-02-08 11:46

  • 碎时UP (作者)

    回复 DCloud_iOS_WZT: 是的我换了不同的沙箱账号都是不可以的

    2023-02-08 14:32

  • 聪大帅

    这个问题有修好吗,3.7.8的版本还不行

    2023-05-29 15:44

碎时UP

碎时UP (作者)

@DCloud_iOS_WZT

碎时UP

碎时UP (作者)

这个是获取补单票据的代码

碎时UP

碎时UP (作者)

我直接postman调用苹果的接口都是21002

  • 格物致知code

    你好 我约遇到和你同样的问题。,。。。

    2023-02-08 12:05

格物致知code

格物致知code

请问解决了没有,我也与你遇到同样的问题

  • 碎时UP (作者)

    解决不了,这代码都没有动过突然就无法正常回调了

    2023-02-08 14:31

碎时UP

碎时UP (作者)

问题解决,

https://developer.apple.com/system-status/

苹果服务挂了 问候下他们

感谢 @DCloud_iOS_WZT 官方给大哥办个奖状吧

  • vonfly

    你这个username是一个固定值吗?还是username+orderid 的方式,最终调用 restoreCompletedTransactions时是不是只传username就行了?

    2024-01-26 15:44

要回复问题请先登录注册