BitPay Sample App

Sample app that uses BitPay Cordova SDK.

🚧

Important Note!

Note that the option of creating new apps with the Ionic and Bootstrap frameworks was removed but we still support the projects that were created with them earlier.

This sample app demonstrates how to add secure Bitcoin payments to your Appery.io mobile app with the BitPay Cordova SDK.

Bitcoin Wallet

As a customer making purchases with BitPay App you’ll need a Bitcoin wallet installed on your phone. Bitcoin wallet is an app that lets you receive, hold, and spend bitcoins.

A list of Bitcoin wallets is maintained by BitPay. If you choose the BitPay Wallet app from this list, you’ll be able to create a Testnet wallet in it. Testnet wallets are a handy way to test Bitcoin purchases.

There should exist 2 Bitcoin wallets for the purchase to take a place, one for the customer and one for the merchant. You can create them within your BitPay Wallet and name the first one as Customer Test Wallet and the second one as Merchant Test Wallet. Be sure to set the Testnet option ON in "Additional options".

📘

Here's how to create a Testnet wallet within Copay or BitPay Wallet apps:

https://help.bitpay.com/businesses-and-organizations/implementation-and-development/can-i-test-bitpay-without-signing-up

BitPay Account

To use the BitPay API you will need to sign up for an account. In this tutorial, we will use https://test.bitpay.com to create a merchant account on a BitPay test server. To make real payments, you will need to sign up for an account at https://bitpay.com.

  1. Go to https://test.bitpay.com.

  2. Click Sign Up, select Business Account, and then click the Sign Up button.

  3. Provide an Organization name that will be listed in your invoices and fill in the other fields before clicking Create Account.

  4. Click the link in the verification email sent to you and log in.

  5. Click Get Verified, fill in the form, and then click Verify.

  6. Click Add a Bank Account and provide the address of your Merchant Test Wallet. There are many ways to create a Testnet wallet.
    This Bitcoin wallet will be used by merchants to receive payments. You should also provide your Bank Account details to complete the BitPay Settlement. Any testing data can be provided here; test merchant account applications are automatically accepted in BitPay’s test environment.

  7. Click the Start accepting Bitcoin button.

Now, your test BitPay Account is ready.

Create the App

🚧

Important Note!

Note that the option of creating new apps with the Ionic framework was removed but we still support the projects that were created with it earlier.

In this step, you are going to import a plugin to make the app (client).

  1. From the App page, select Create new app. Enter "BitPayApp" for the app name.

  2. Select Ionic as the app type with a Blank template.

  3. Click the Create button.

  4. When the App Builder loads, select From Plugin in the CREATE NEW dropdown.

  5. Check BitPay App plugin and press the Import selected plugins button.

  6. In the popup dialog that appears, set the start page to BitPay_Home and confirm.

BitPay Cordova Plug-in

Go to https://github.com/bitpay/cordova-sdk and save this repository as a ZIP file.

Next, upload the BitPay Cordova plugin to Appery.io:

  1. From the platform main dashboard (not the App Builder), go to Resources > Cordova Plugins.

  2. Click Import Cordova plugin.

  3. Click Choose file and upload the plugin file you had downloaded.

  4. Click Import plugin.

The plug-in will appear under Cordova plugins.

Next, enable the BitPay Cordova plugin in your app:

  1. Inside an app, go to Project > App settings > Cordova plugins > Imported Cordova plugins.

  2. To enable the plugin for the current app, check the box for the BitPay SDK.

📘

More info about adding Cordova plugins into Appery.io can be found

Here

BitPay API Token

  1. Go to https://test.bitpay.com/api-tokens
    (or Payment Tools > Integration Resources > Manage API Tokens in your BitPay Account).

  2. Click the Add New Token button and generate a token with the Point-of-Sale capability without client authentication.

  3. Inside an app, go to Services > BitPay_Settings and set bitpay_token to the provided value.

Add Certificate

For Android, add the distribution certificate on the Project > App settings > Android binary page; for iOS add the distribution certificate on the Project > App settings > iOS binary page.

📘

Certificate management in Appery.io is described further :

Here

Running the App

That’s all you need to do. You can now export your app as an .apk or .ipa file and install it on your device.

Select the amount of bitcoins you want to pay and click the Make payment button. You will be redirected to the BitPay_Invoice_Details page where the status of your invoice can be checked. Click the Open wallet button.

The Bitcoin wallet then opens, so you can transfer the requested funds. You can also switch back to your app, where you can see information about the status of your payment on the BitPay_Invoice_Details page.

Settlement payments from BitPay to merchant’s Bitcoin wallet are made automatically, every business day.