Payment Gateway Setup (BitPay)

Overview
BitPay is a payment gateway for blockchain payments. To use this gateway please see below.
Live/Sandbox
You should set up a Sandbox account for testing to make sure that Maian Coin is working as expected.

Live Account:
https://bitpay.com

Sandbox Account
https://test.bitpay.com

IMPORTANT: Complete all steps as detailed here. You should install the BitPay app, add a Testnet wallet and add test coins via an online faucet for testing.
API Setup
1 Log into your live/sandbox account and complete all verification details to activate account.

2 From the menu click "Payment Tools" and then "Manage API Tokens".

3 Click "Add New Token" to generate new token. Label name doesn`t matter. Copy pairing code to clipboard. (Note that this must be activated in 24hrs or else you`ll need to generate a new token).

4 Log in to your Maian Coin control panel and navigate to "Settings > Payment/Currency > Parameters". Create a parameter entry called "bitpay-pairing-code" and enter the pairing code from the token you created.


5 On the "General" tab, select "BitPay" as the "BitCoin/Blockchain Gateway".

Setup completed. You are now ready to receive/test payments using BitPay.

IMPORTANT: The first time you test BitPay it will create public/private keys and pair the token to these keys. You only need to do this once for both your test and live setups. Once the token is paired it will detail the pairing in your BitPay account area.
Private/Public Keys
BitPay private/public keys, tokens and sin numbers are encrypted and stored securely in the Maian Coin database. In the unlikely event that your live data has been compromised, you should do the following:

1 Log into your live BitPay account, revoke the API token and generate a new one. Enter the new parameter value for "bitpay-pairing-code" in your payment settings.

2 Log into your database and run the following command (adjusting the prefix if necessary).

update `mcn_coin` set `st_value` = ''

The next time your system is used new keys, tokens and sin numbers will be generated.
Accepted Statuses
Maian Coin will only update a sale as completed when it receives a response of "confirmed" from BitPay. In some cases, there could be a delay before this response is received. If you would like the system to update a sale as completed for other statuses, add them to the 'accepted-statuses' array in the following file:

control/classes/gateways/class.bitpay.php

You should be cautious about this. Only the "confirmed" status confirms the sale on the blockchain and the merchant.

For a list of available statuses see the BitPay website.

If you wish to allow sales that are pending (if supported by gateway), see the "Process Pending Payments as Completed" option in the payment settings.
Allowed IP Addresses
At the time of these docs, BitPay offered no checks via IP addresses as verification is done via their API.