I reply to all queries on the forums and via email, once per day, Monday to Friday (not weekends).

If you are new here, please see some information on how to ask for support. Thank you!

Reply To: deposit UI help

dashed-slug.net Forums General discussion deposit UI help Reply To: deposit UI help



It looks like you are trying to create a whole plugin from scratch to process invoices. This is not something that the plugin does. I can’t guide your entire development effort for a new plugin. For that you probably need to create a different plugin. That includes doing the analysis and design, and choosing the appropriate technologies and architecture.

I can try to give you some pointers:

The code you posted is kinda wrong because it tries to read data from the wallets plugin via the browser’s DOM. You will likely encounter race conditions, where the data is not there at the time you are reading it. IF you wanted to read the user data, you should be using the get_coins_info call from JSON-API. BUT you probably don’t want to do this. You are trying to read addresses that YOUR code has generated, not the addresses that the wallets plugin has assigned to the users. So you must pass the data to the frontend in some other way.

To do deposits to CoinPayments independently from the plugin, you must do a call to GetDepositAddress. This will give you back an address that belongs to your CP wallet and that will notify you whenever there is a deposit via IPN.

You must keep track of these addresses that you generate. This will probably be in the DB. It’s up to you how to store it, but don’t use the plugin’s tables. You can create your own custom SQL tables or use Custom Post Types, or even store the addresses in options, user meta, etc depending on your design.

Once you know which addresses you have generated, you can hook into an action such as init or parse_request to listen for incoming IPNs. Since you will only be processing addresses that you know are generated with your plugin, these will not interfere with the existing IPN handler of the wallets plugin. You can then detect invoice payments and notify your users via email or any other way you see fit.

The wallets plugin uses the JSON-API (and the upcoming WP-REST API) for communication between frontend and backend. It then uses frontend javascript to create the qr code. Whether your plugin renders your address as a qrcode in the frontend or backend is up to you.

In summary: If you are trying to create invoices, this is a different plugin. The wallets plugin as it is now, cannot be extended to accept invoices. You must create a different plugin from scratch. Think about your requirements, do an analysis, and you will see that it is not appropriate to extend this plugin for your use case.

I’m really sorry for being so negative, but it doesn’t look like I can help you more with this. It really sounds like someone who studied business, not engineering, gave you the task of adapting the plugin for a totally different technical requirement. You should get back to them and tell them that the decision of which software to use to achieve a business requirement, is a technical decision, and must be done by an engineer.

Best of luck with your project.

with regards