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
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 RequirementsAndroid 4.1+
Support AndroidX
#
How it worksDownload binance_pay_sdk_v1.0.0.aar and Import SDK
Merchants redirect customers to Binance Checkout Page.
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')}
- Sync Project
#
Usage#
1. Create BinancePayListenerclass 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 Parameters2.1 Crypto payments(C2B)
val param = BinancePayParam(merchantId, prepayId, timeStamp, nonceStr, certSn, sign)valbinancePay = BinancePayFactory.getBinancePay(context)binancePay.pay(param, listener)
2.2 Transfer or send cryptos(C2C)
val binancePay = BinancePayFactory.getBinancePay(context)binancePay.pay(orderId, type, listener)
#
Integrate with iOS SDK#
Minimum RequirementsiOS 10+
Swift 5.1+
#
How it worksDownload BinancePaySDK.xcframework
Add BinancePaySDK.xcframework into Frameworks, Libraries and Embedded Content of your target
Embed Type should be Embed & Sign
#
Usage#
1. Languagepublic 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 Parameters2.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 APIBinancePay.shared.pay(with: 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. ErrorsTypes 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}