CoinPayments (CP)

This Lib make integration with https://www.coinpayments.netarrow-up-right in easy way.

Initial setup

Need to setup public and private key:

  1. Go to this pagearrow-up-right and generate new key.

Press on button "Edit Permissions" and add API Key Permissions:

Check all options what you need

Then on bot /setup command:

Call API methods

All CoinPayments API method available herearrow-up-right.

For example for method Get Basic Account Informationarrow-up-right we need 2 commands: /info and /onInfo

/info command:

circle-info

In fields you can pass all fields from CoinPayments api. Just read helparrow-up-right.

/onInfo command:

Combine libs!

CoinPayments API do not have some methods. For example get balance by address, validate address, get transactions for address and etc.

Use Block.io Libarrow-up-right with CP Lib together!

Block.io is free if you do not use wallets there.

Receiving Payments

circle-check

It is possible to receive payment for a temporary or permanent wallet.

Temporary wallet benefits:

  • Fixed amount

  • Can bind the payment to the ordered product

  • Status and checkout page

  • QR code for payment

  • one address for one payment

Permanent wallet benefits:

  • Any amount

  • One address for several payments

  • User can transfer funds at any time

Setup: set IPN Secret

circle-exclamation

Once more! You need input any text (random text) as IPN secret in Merchant Settings page

Temporary wallet

We use command "create_transaction" with IPN.

Please see https://www.coinpayments.net/apidoc-create-transactionarrow-up-right for details.

Yes, you can write it via Libs.CoinPayments.apiCallmethod too. But there is an easier way.

Command /pay

circle-check

Automatically with Library:

circle-info

It is preferable to use method onPaymentCompleted and not method onIPN.

Since the method onPaymentCompleted completely covers the IPN and solves the problem with IPN Retries / Duplicate IPNsarrow-up-right

Command /onCreatePayment

Command /onPaymentCompleted

This command will be executed on successful payment

circle-info

Need install ResourcesLib

Finished!

Now you can receive payments

Information about extra payments and refunds.

It is possible to define buyer email in fields for options (seearrow-up-right code for command /pay )

triangle-exclamation

Additional Information

You can check payment status

command: /on_txn_id:

command /onIPN

You can get info from IPN. Really it is not needed in simple. Just use onPaymentCompleted option on createTransaction.

command onError

Permanent wallet

We use command "get_callback_address" with IPN.

Please see https://www.coinpayments.net/apidoc-get-callback-addressarrow-up-right for details.

Yes, you can write it via Libs.CoinPayments.apiCallmethod too. But there is an easier way.

Command /createWallet

circle-check

Automatically with Library:

circle-info

It is preferable to use method onIncome and not method onIPN.

Since the method onIncome completely covers the IPN and solves the problem with IPN Retries / Duplicate IPNsarrow-up-right

Command /onWalletCreate

Command /onIncome

command onError

Troubleshooting & Debuging

  • Do not use same CoinPayment account for receiving and transfering funds.

  • Go to pagearrow-up-right. This list must have history with completed income transaction(s)

  • Try to resend IPN - see Debuging

  • Verify that you have set IPN secretarrow-up-right

IPN History

You can view IPN History by link https://www.coinpayments.net/acct-ipn-historyarrow-up-right

Also you can resend IPN by checkin "Resend" checkbox and button "Re-send checked IPN(s)"

Test methods

Temporary wallet:

Also it is possible make test onPaymentCompleted event. It is good if you do not want make test payment.

Permanent wallet:

Also it is possible make test callTestPermanentWalletIncome event. It is good if you do not want make test payment.

Security

circle-exclamation

Do not use default names for secure commands such as /onIncome, /onPaymentCompleted

Anybody can run any command by names. So need to check that security command runned by CoinPayment Lib only!

triangle-exclamation

Grant only the really necessary permissions for the Api key. If yor bot do not need "create_withdrawal" or etc methods - turn theys off.

Check all options what you need

Read more about security herearrow-up-right

Do not process any before payment!

Any API commands can have errors: API errors, timeout errors, network errors, and other errors.

You need to withdraw, make deposit income only on success!

Because if you get an error, such a conclusion, replenishment of the deposit, etc. - will always be!

Here the balance will always be replenished, even if half of the Internet falls

Last updated

Was this helpful?