piavart / rustore-client

nodejs rustore client
MIT License
2 stars 2 forks source link

"Cannot parse null string" error occured while calling getPurchase() #1

Closed caiknife closed 7 months ago

caiknife commented 7 months ago

Hello, I'm an engineer from China, and I'm working on connecting RuStore billing system to an app with your rustore-client project.

Here below is my source code.

// rustore.js
const {RuStoreClient, RS_InvoiceStatus} = require("@piavart/rustore-client")
const privateKey = "MIIEvAIB..."
const companyID = 23
const client = new RuStoreClient(privateKey, companyID)

class RuStore {
    async getPurchase(purchaseToken) {
        try {
            let purchase = await client.getPurchase(purchaseToken)
            return purchase
        } catch (e) {
            throw e
        }
    }

    async getSubscription(purchaseToken) {
        try {
            let purchase = await client.getSubscription(purchaseToken)
            return purchase
        } catch (e) {
            throw e
        }
    }

    checkStatus(status) {
        try {
            return status === RS_InvoiceStatus.Confirmed
        } catch (e) {
            throw e
        }
    }
}

const rustore = new RuStore()

module.exports = {
    rustore
}

Here below is a test code.

//rustore.test.js
const {test, describe, expect} = require("@jest/globals")
const {rustore} = require("./rustore");

describe("rustore", () => {
    test("getPurchase", async () => {
        try {
            // this purchaseToken is a real token in my app
            let purchaseToken = "1000005247.2520743208"
            let result = await rustore.getPurchase(purchaseToken)
            console.log(result)
        } catch (e) {
            console.error(e.stack)
            console.error(e.data)
        }
    })
})

After excuting the test code, there is always an error.

console.error
    Error: Cannot parse null string
        at RuStoreClient.request (/Users/caiknife/WebstormProjects/tank_server/node_modules/@piavart/rustore-client/dist/client.js:45:19)
        at process._tickCallback (internal/process/next_tick.js:68:7)

      11 |             console.log(result)
      12 |         } catch (e) {
    > 13 |             console.error(e.stack)
         |                     ^
      14 |             console.error(e.data)
      15 |         }
      16 |     })

      at Object.test (pub/utils/pay/rustore.test.js:13:21)

  console.error
    { code: 'ERROR',
      message: 'Cannot parse null string',
      body: null,
      timestamp: '2024-04-12T14:15:19.021183821+03:00' }

      12 |         } catch (e) {
      13 |             console.error(e.stack)
    > 14 |             console.error(e.data)
         |                     ^
      15 |         }
      16 |     })
      17 |

      at Object.test (pub/utils/pay/rustore.test.js:14:21)

Can you help me on this issue?

Looing forward to your response, thanks so much!

piavart commented 7 months ago

Hi! I'll try to watch it on Monday. If anything, write to me on telegram @piavart

пт, 12 апр. 2024 г. в 15:33, Cai Zhijiang @.***>:

Hello, I'm an engineer from China, and I'm working on connecting RuStore billing system to an app with your rustore-client project.

Here below is my source code.

// rustore.jsconst {RuStoreClient, RS_InvoiceStatus} = @.***/rustore-client")const privateKey = "MIIEvAIB..."const companyID = 23const client = new RuStoreClient(privateKey, companyID) class RuStore { async getPurchase(purchaseToken) { try { let purchase = await client.getPurchase(purchaseToken) return purchase } catch (e) { throw e } }

async getSubscription(purchaseToken) {
    try {
        let purchase = await client.getSubscription(purchaseToken)
        return purchase
    } catch (e) {
        throw e
    }
}

checkStatus(status) {
    try {
        return status === RS_InvoiceStatus.Confirmed
    } catch (e) {
        throw e
    }
}}

const rustore = new RuStore() module.exports = { rustore}

Here below is a test code.

//rustore.test.jsconst {test, describe, expect} = @.***/globals")const {rustore} = require("./rustore"); describe("rustore", () => { test("getPurchase", async () => { try { // this purchaseToken is a real token in my app let purchaseToken = "1000005247.2520743208" let result = await rustore.getPurchase(purchaseToken) console.log(result) } catch (e) { console.error(e.stack) console.error(e.data) } })})

After excuting the test code, there is always an error.

console.error Error: Cannot parse null string at RuStoreClient.request @.***/rustore-client/dist/client.js:45:19) at process._tickCallback (internal/process/next_tick.js:68:7)

  11 |             console.log(result)
  12 |         } catch (e) {
> 13 |             console.error(e.stack)
     |                     ^
  14 |             console.error(e.data)
  15 |         }
  16 |     })

  at Object.test (pub/utils/pay/rustore.test.js:13:21)

console.error { code: 'ERROR', message: 'Cannot parse null string', body: null, timestamp: '2024-04-12T14:15:19.021183821+03:00' }

  12 |         } catch (e) {
  13 |             console.error(e.stack)
> 14 |             console.error(e.data)
     |                     ^
  15 |         }
  16 |     })
  17 |

  at Object.test (pub/utils/pay/rustore.test.js:14:21)

Can you help me on this issue?

Looing forward to your response, thanks so much!

— Reply to this email directly, view it on GitHub https://github.com/piavart/rustore-client/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJ4L4GM67YFNNGRLIOYWO3Y47IAPAVCNFSM6AAAAABGEB6QEWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2DAMBWGI2DMNA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

caiknife commented 7 months ago

Hi! I'll try to watch it on Monday. If anything, write to me on telegram @piavart пт, 12 апр. 2024 г. в 15:33, Cai Zhijiang @.>: Hello, I'm an engineer from China, and I'm working on connecting RuStore billing system to an app with your rustore-client project. Here below is my source code. // rustore.jsconst {RuStoreClient, RS_InvoiceStatus} = @./rustore-client")const privateKey = "MIIEvAIB..."const companyID = 23const client = new RuStoreClient(privateKey, companyID) class RuStore { async getPurchase(purchaseToken) { try { let purchase = await client.getPurchase(purchaseToken) return purchase } catch (e) { throw e } } async getSubscription(purchaseToken) { try { let purchase = await client.getSubscription(purchaseToken) return purchase } catch (e) { throw e } } checkStatus(status) { try { return status === RS_InvoiceStatus.Confirmed } catch (e) { throw e } }} const rustore = new RuStore() module.exports = { rustore} Here below is a test code. //rustore.test.jsconst {test, describe, expect} = @./globals")const {rustore} = require("./rustore"); describe("rustore", () => { test("getPurchase", async () => { try { // this purchaseToken is a real token in my app let purchaseToken = "1000005247.2520743208" let result = await rustore.getPurchase(purchaseToken) console.log(result) } catch (e) { console.error(e.stack) console.error(e.data) } })}) After excuting the test code, there is always an error. console.error Error: Cannot parse null string at RuStoreClient.request @./rustore-client/dist/client.js:45:19) at process._tickCallback (internal/process/next_tick.js:68:7) 11 | console.log(result) 12 | } catch (e) { > 13 | console.error(e.stack) | ^ 14 | console.error(e.data) 15 | } 16 | }) at Object.test (pub/utils/pay/rustore.test.js:13:21) console.error { code: 'ERROR', message: 'Cannot parse null string', body: null, timestamp: '2024-04-12T14:15:19.021183821+03:00' } 12 | } catch (e) { 13 | console.error(e.stack) > 14 | console.error(e.data) | ^ 15 | } 16 | }) 17 | at Object.test (pub/utils/pay/rustore.test.js:14:21) Can you help me on this issue? Looing forward to your response, thanks so much! — Reply to this email directly, view it on GitHub <#1>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJ4L4GM67YFNNGRLIOYWO3Y47IAPAVCNFSM6AAAAABGEB6QEWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2DAMBWGI2DMNA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Hello, I left messages for you on telegram, but telegram system noticed me that I can only send message in mutual contact. My telegram id is https://t.me/caiknife.

Please let me know if you need my private key or company id for debugging.