Skip to main content

Mobile Integrations

Start accepting cryptocurrencies in your app with Binance SDK for both iOS and Android. It's quick and easy to integrate, allowing Binance customer to pay and get paid in crypto within your app instantaneously.

To begin, register your app with Binance accounts, and get the SDK.

  • Android SDK
  • iOS SDK

During integration, Binance Pay backend will check the signature against various pay parameters. For full Signature Rule, please go to Signature Rule (For server engineer).

Please follow the parameters order. Use "=" connect field and value, use "&" to separate fields.

String payload = "certSn=317c110ebf7baf641e8f49ab6851331737dbe98541947c53b9dbba27f8c8414f" + "&" + "merchantId=98765987" + "&" + "noncestr=5K8264ILTKCH16CQ2502SI8ZNMTM67VS" + "&" + "prepayId=98765987" + "&"+ "timeStamp=1618302830073";String signature = hex(hmac("sha512", payload, secretKey)).toUpperCase();

Integrate with Android SDK#

Minimum Requirements#

Android 4.1+

Support AndroidX

How it works#
  1. Download binance_pay_sdk_v1.0.0.aar and Import SDK

  2. Merchants redirect customers to Binance Checkout Page.

  3. Add repositories and dependence for app module

android{    repositories {        flatDir {            dirs 'libs'        }    }}dependencies {    implementation fileTree(include: ['*.jar'], dir: 'libs')    implementation (name: 'binance_pay_sdk_v1.0.0', ext: 'aar')}
  1. Sync Project
1. Create BinancePayListener#
class PayListener : BinancePayListener {   override fun onSuccess() {       // When the payment is successful, this will be called       }
   override fun onCancel() {       // When the payment is canceled, this will be called     }
override fun onError(exception: BinancePayException) {       // When there is an error in the payment process,this will be called     }}val listener = PayListener()
2. Create Payment Parameters#

2.1 Crypto payments(C2B)

val param = BinancePayParam(merchantId, prepayId, timeStamp, nonceStr, certSn, sign)valbinancePay = BinancePayFactory.getBinancePay(context), listener)

2.2 Transfer or send cryptos(C2C)

val binancePay = BinancePayFactory.getBinancePay(context), type, listener)

Integrate with iOS SDK#

Minimum Requirements#

iOS 10+

Swift 5.1+

How it works#
  1. Download BinancePaySDK.xcframework

  2. Add BinancePaySDK.xcframework into Frameworks, Libraries and Embedded Content of your target

  3. Embed Type should be Embed & Sign

1. Language#
public enum languageMode {    case automatic                  // SDK automatically use the same language as iOS system    case manual(Language: Language) // You can specify the language}
BinancePay.shared.languageMode = .automatic
2. Create Payment Parameters#

2.1 Crypto payments(C2B)

public struct OrderInitParameters {    let merchantId: String    let prepayId: String    let timestamp: Int64    let noncestr: String    let certSn: String    let sign: String    let redirectScheme: String}

2.2 Transfer or send cryptos(C2C)

public struct C2CInitParameters {    let id: String    let type: String    let redirectScheme: String}
3. Call API# parameters, containerView: self.view) { (result) in   switch result {   case .success:    print("success")   case .failure(let error):    print("failure \(error)")   }}

BinancePaySDK will trigger an alert if the user does not have Binance app installed on his/her device. The alert will be shown on the containerView.

4. Errors#

Types of error you may get from BinancePaySDK.

public enum PayError: Error {    case invalidParameters(OrderInitParametersError)    case binanceAppNotInstalled    case binanceAppNotSupported    case openAppFailed    case fromBinanceApp(code: Int, message: String)}
public enum OrderInitParametersError: Error {    case invalidMerchantId    case invalidPrepayId    case invalidTimestamp    case invalidNonceStr    case invalidCertSn    case invalidSign    case invalidRedirectScheme}