Is there any way to set up recurring payments with the internet computer?

I’d like to incorporate subscriptions billed at regular intervals into my app, but at the moment, I’m unaware of any payment solutions on the internet computer that offers these features.

2 Likes

I haven’t used it, but I believe there is a “cronjob” feature available to canisters, which essentially allows update calls to be automatically initiated on a regular interval. I believe that feature would be the foundation of recurring payments. Hopefully someone else can shed more light.

Yeah, it lets you define a canister_heartbeat method that the IC will call periodically.

Although I believe it’s only available in Rust right now, and is not the most stable. It’d be great to get Motoko support at some point (there’s a pending issue).

5 Likes

Any update on canister_heartbeat method in motoko.
And is it stable in Rust for now?

You should be able to use the heartbeat in Rust or Motoko. I have live code with the heartbeat in Rust and it’s working great.

How’s your cycle consumption? That’s my only concern with heartbeat, since it fires really really often (and it’s up to the code to decide when to actually perform some logic).

1 Like

Actually I want to query call to another canister for its state, and update current canister state with the response.
This should happen periodically like polling.

I am thinking heartbeat is solution for it.
But now I am getting below error for motoko.

error [M0129], unexpected system method named heartbeat, expected preupgrade or postupgrade

Thanks

It would help if you provided a source code snippet.

It is definitely more expensive, right now it gets called every second or so.

For this error

error [M0129], unexpected system method named heartbeat, expected preupgrade or postupgrade
I have used snippet from example in Heartbeats :: Internet Computer

Are you asking the snippet for the error or the periodic polling?

I meant a snippet of your actual code that is breaking. Also what version of dfx are you using?

We need a public utility canister that takes the every second hit for everyone and and let’s you schedule your intervals. Some folks only need once a day. This should be standardized and daoified. I’ve been thinking about it for a while and just haven’t had the time to write it up. If someone thinks through it and writes it up we can incentivize the build with a bounty. The hardest part will be the testing to figure out how many async messages per heartbeat you can send out and building a routing mesh that scales.

One user on here wrote a pretty robust solution that is probably a good starting point.

4 Likes

Totally agreed. Where is that robust solution you mentioned though? If you have a link you could share, that would be great.

1 Like

This one has evolved a bit…not sure how far they got IC Cron - let's schedule some tasks bois - #18 by rckprtr

1 Like

You’re receiving this error because you’re using a dfx version (probably 0.8.4) that does not include a Motoko compiler that has heartbeat implemented and hence doesn’t undersand that syntax. Upgrade to a dfx that is greater than 0.9.x

any plans to recreate this for motoko?

No… for me Motoko is still to young c:

2 Likes