This sample app demonstrates how to add secure Bitcoin payments to your Appery.io mobile app with the BitPay Cordova SDK.
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:
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.
Go to https://test.bitpay.com.
Click Sign Up, select Business Account, and then click the Sign Up button.
Provide an Organization name that will be listed in your invoices and fill in the other fields before clicking Create Account.
Click the link in the verification email sent to you and log in.
Click Get Verified, fill in the form, and then click Verify.
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.
Click the Start accepting Bitcoin button.
Now, your test BitPay Account is ready.
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).
From the App page, select Create new app. Enter "BitPayApp" for the app name.
Select Ionic as the app type with a Blank template.
Click the Create button.
When the App Builder loads, select From Plugin in the CREATE NEW dropdown.
Check BitPay App plugin and press the Import selected plugins button.
In the popup dialog that appears, set the start page to BitPay_Home and confirm.
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:
From the platform main dashboard (not the App Builder), go to Resources > Cordova Plugins.
Click Import Cordova plugin.
Click Choose file and upload the plugin file you had downloaded.
Click Import plugin.
The plug-in will appear under Cordova plugins.
Next, enable the BitPay Cordova plugin in your app:
Inside an app, go to Project > App settings > Cordova plugins > Imported Cordova plugins.
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
Go to https://test.bitpay.com/api-tokens
(or Payment Tools > Integration Resources > Manage API Tokens in your BitPay Account).
Click the Add New Token button and generate a token with the Point-of-Sale capability without client authentication.
Inside an app, go to Services > BitPay_Settings and set bitpay_token to the provided value.
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 :
That’s all you need to do. You can now export your app as an
.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
Settlement payments from BitPay to merchant’s Bitcoin wallet are made automatically, every business day.
Updated 6 months ago