apple / app-store-server-library-node

MIT License
159 stars 31 forks source link

TypeError Occurs When Using verifyAndDecodeNotification Method in Sandbox Environment #178

Closed LoisFromNeo closed 1 month ago

LoisFromNeo commented 1 month ago

Hello, I hope this message finds you well.

I am currently using version 1.4.0 of your app-store-server-library-node. However, I encountered the following error when attempting to decode a signedPayload after receiving server notifications for auto-renewable subscriptions.

스크린샷 2024-07-24 오전 10 21 22

Here are the detailed steps:

  1. Initial purchase on the client side => Success
  2. Processing of the initial purchase data on our own API server => Success (using the getTransactionInfo function from the same library, no errors)
  3. Receive server notification for renewal payment immediately after the initial purchase => Success
  4. Attempt to decode the received signedPayload by passing it to the verifyAndDecodeNotification function => Failure

As shown in the attached screenshot, the error stack trace indicates that the error originates from within the library’s internal logic, prompting me to raise this issue.

I would appreciate it if you could review this matter.

Thank you.

alexanderjordanbaker commented 1 month ago

@LoisFromNeo This error is generally thrown when you attempt to decode something that isn't a notification as a notification, like a transaction or renewal info. Can you confirm you are actually decoding a notification itself, perhaps by putting the JWS into a decoder and confirming the output matches a notification?

LoisFromNeo commented 1 month ago

Oops, I just realized that the signedPayload I was passing was not the value of the signedPayload property in the body of the notification, but rather the entire object contained in the body itself. I apologize for not checking this thoroughly… Additionally, thank you for the quick response!