Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option of obtaining past-payments from a specific subscription. #719

Closed
ipr0310 opened this issue Jan 18, 2023 · 5 comments
Closed
Labels
enhancement New feature or request

Comments

@ipr0310
Copy link
Member

ipr0310 commented Jan 18, 2023

As the title says, we should have a way of getting the previous payments from a specific subscription.

As crypto automatic payments are getting more relevant, this is a necessary feature on any subscription-platform.

@ipr0310 ipr0310 added the enhancement New feature or request label Jan 18, 2023
@jjos2372
Copy link

jjos2372 commented Mar 2, 2023

We will have a new endpoint called getSubscriptionPayments for this.

jjos2372 added a commit that referenced this issue Mar 2, 2023
@jjos2372
Copy link

jjos2372 commented Mar 2, 2023

So now getSubscriptionPayments return the list of transactions for all payments of a given subscription.

If one wants all subscription payments of a given account, then use getAccountTransactions with type=21 and subtype=5.

@ipr0310
Copy link
Member Author

ipr0310 commented Mar 23, 2023

@jjos2372 I had to re-open this ticket because there is an pagination issue on this request, let me explain:

As you can see on this request, there are more than 65 transaction(Payments)
https://europe3.testnet.signum.network/api?requestType=getSubscriptionPayments&subscription=10129084965209757306

But the issue is happening when i try to make the request with pagination:
https://europe3.testnet.signum.network/api?requestType=getSubscriptionPayments&subscription=10129084965209757306&firstIndex=0&lastIndex=5

You will discover the following on the response:

  • You can notice that only 1 transaction is being returned
  • You can notice that the nextIndex is 6, when in reality only 1 item is being returned
{
    "transactions": [
        {
            "type": 21,
            "subtype": 5,
            "timestamp": 271864410,
            "deadline": 1440,
            "senderPublicKey": "04d794aa453a5bbdb8d580f1d9a76b6d7a25cde0ed38c098550ea0f784d9317a",
            "amountNQT": "1250000000",
            "feeNQT": "1000000",
            "fullHash": "8e26c06fafdcc500bfc4089372ff1129e7dc132ed0220f8a19fb71472d6390a9",
            "transaction": "55693216464250510",
            "attachment": {
                "version.SubscriptionPayment": 1,
                "subscriptionId": "10129084965209757306"
            },
            "attachmentBytes": "017ad613131cbd918c",
            "sender": "13112229684715917355",
            "senderRS": "TS-863D-FNXF-WVPM-DZZXD",
            "height": 527736,
            "version": 1,
            "ecBlockId": "0",
            "ecBlockHeight": 0,
            "cashBackId": "0",
            "block": "2048945161248419226",
            "confirmations": 3,
            "blockTimestamp": 271864629
        }
    ],
    "nextIndex": 6,
    "requestProcessingTime": 19
}

@ipr0310 ipr0310 reopened this Mar 23, 2023
@jjos2372
Copy link

That is the reason we have the nextIndex. Not all end points will return exactly the length you asked (when this is filtered in a second pass and cannot be directly filtered by a single sql request). If you follow the nextIndex you should be able to iterate over all items. Please check if this is the case, otherwise we have an issue.

@ipr0310
Copy link
Member Author

ipr0310 commented Mar 23, 2023

@jjos2372 Is an issue, because you can see on the request that firstIndex is equal to 0 and lastIndex is equal to 5
The nextIndex property is behaving good.

The issue is: The amount of Payments/Transactions that is being returned is just 1, when in reality, it must return 5 Payments/Transactions
See this example on postman:
image

Note: This subscription has more than 60 Payments/Transactions

https://europe3.testnet.signum.network/api?requestType=getSubscriptionPayments&subscription=10129084965209757306&firstIndex=0&lastIndex=5

This is the response

{
    "transactions": [
        {
            "type": 21,
            "subtype": 5,
            "timestamp": 271868730,
            "deadline": 1440,
            "senderPublicKey": "04d794aa453a5bbdb8d580f1d9a76b6d7a25cde0ed38c098550ea0f784d9317a",
            "amountNQT": "1250000000",
            "feeNQT": "1000000",
            "fullHash": "2235620d09a48bdf66474f99056e603c24b76605e52ab19ff0d094e4046bc48e",
            "transaction": "16108148851006911778",
            "attachment": {
                "version.SubscriptionPayment": 1,
                "subscriptionId": "10129084965209757306"
            },
            "attachmentBytes": "017ad613131cbd918c",
            "sender": "13112229684715917355",
            "senderRS": "TS-863D-FNXF-WVPM-DZZXD",
            "height": 527752,
            "version": 1,
            "ecBlockId": "0",
            "ecBlockHeight": 0,
            "cashBackId": "0",
            "block": "10398869759887365253",
            "confirmations": 2,
            "blockTimestamp": 271868846
        }
    ],
    "nextIndex": 6,
    "requestProcessingTime": 88
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants