Skip to main content

Integrate Waynance Pay with your App

Waynance Pay is a contactless and QR, borderless and secure cryptocurrency payment technology designed by Waynance. Waynance Pay allows you to pay on any network, token and wallet, from anywhere in the world.

To begin, register your application with Waynance Accounts, and get the SDK . For now, please contact us.

Signature Rule (For server engineer)#

Waynance Pay backend will check the signature against pay param, including "certSn", "merchantId", "noncestr", "prepayId" and "timeStamp".

AttributesTypeRequiredLimitationDescription
certSnstringY-API identity key issued by Waynance payment system
merchantIdlongY-The merchant account id, issued when merchant been created at Waynance.
noncestrstringYmust be 32 digitsA random string with 32 bytes, e.g. random ascii decimal within a-z and A-Z and loop 32 times to form a random string
prepayIdstringY-unique id generated by waynance
timeStamplongYWaynance pay only process request within 1sUnixTimestamp in millis that the requests send, guarantee the machine time is sync with the network

Signature generation logic is as below, 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 SDK for Android#

Requirements#

  • Android 4.1+
  • Support AndroidX

Import SDK#

  1. Download waynance_pay_sdk_v1.0.0.aar
  2. Add waynance_pay_sdk_v1.0.0.aar into libs directory
  3. Add dependence for app module, just like this:
    android{    repositories {        flatDir {            dirs 'libs'        }    }}dependencies {    implementation fileTree(include: ['*.jar'], dir: 'libs')    implementation (name: 'waynance_pay_sdk_v1.0.0', ext: 'aar')
  4. Sync project

Usage#

1. Create WaynancePayListener#
class PayListener : WaynancePayListener {   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: WaynancePayException) {       // When there is an error in the payment process,this will be called     }}val listener = PayListener()
2. To Pay#

2.1 Crypto payments(C2B)

val param = WaynancePayParam(merchantId, prepayId, timeStamp, nonceStr, certSn, sign)val waynancePay = waynancePayFactory.getWaynancePay(context)WaynancePay.pay(param, listener)

2.2 Transfer or send cryptos(C2C)

val WaynancePay = WaynancePayFactory.getWaynancePay(context)waynancePay.pay(orderId, type, listener)

Error Types:
Maybe you will encounter several situations:

  • UnInstall Error:This means that you have not installed the Waynance app, and then a pop-up window will be displayed to guide you to download
  • UnSupported Error:This means that your Waynance app version is too low, and then a pop-up window will be displayed to guide you to get the latest Waynance app
  • Other Error:Will be called back to you via WaynancePayListener

Integrate SDK for iOS#

Requirements#

  • iOS 10+
  • Swift 5.1+

Installation#

Munual#
  1. Download WaynancePaySDK.xcframework
  2. Add WaynancePaySDK.xcframework into Frameworks, Libraries and Embeded Content of your target
  3. Embed Type should be Embed & Sign

Usage#

Pay#
  1. Create Request Parameters:
// Crypto payments(C2B) parameterspublic struct OrderInitParameters {    let merchantId: String    let prepayId: String    let timestamp: Int64    let noncestr: String    let certSn: String    let sign: String    let redirectScheme: String}
// Transfer or send cryptos(C2C) parameterspublic struct C2CInitParameters {    let id: String    let type: String    let redirectScheme: String}
  1. Call api:
WaynancePay.shared.pay(with: parameters, containerView: self.view) { (result) in   switch result {   case .success:    print("success")   case .failure(let error):    print("failure \(error)")   }}

WaynancePaySDK will show up an alert if user doesn't install Waynance app on his/her device. The alert will show on the containerView.

  1. Error Types: Here are the errors you may get from WaynancePaySDK:
public enum PayError: Error {    case invalidParameters(OrderInitParametersError)    case WaynanceAppNotInstalled    case waynanceAppNotSupported    case openAppFailed    case fromWaynanceApp(code: Int, message: String)}
public enum OrderInitParametersError: Error {    case invalidMerchantId    case invalidPrepayId    case invalidTimestamp    case invalidNonceStr    case invalidCertSn    case invalidSign    case invalidRedirectScheme}

Language#

public enum languageMode {    case automatic                  // SDK automatically use the same language as iOS system    case manual(Language: Language) // You can specify the language}
WaynancePay.shared.languageMode = .automatic

FAQ#

Unable to trigger the Waynance App#

Include Waynance Pay in the plist file to trigger Waynance app

<key>LSApplicationQueriesSchemes</key><array><string>com.Waynance.app.Waynance</string><string>com.Waynance.pay.support</string></array>
Unable to redirect from Waynance App back to your App#
  1. Add your url scheme in Info Url Types
  2. Set this url-scheme as redirectScheme when using WaynancePaySDK img
Did not receive callback#

Under AppDelegate: include the WaynancePay.shared.handle function to receive callback.

    func application(_ app: UIApplication, open url: URL, options:        [UIApplication.OpenURLOptionsKey : Any[ = [:]) -> Bool {        WaynancePay.shared.handle(openURL: url)        }