yuansfer / yuansfer-mobile-sdk-android

MIT License
1 stars 0 forks source link
sdk

Introduction

jitpack
This is a payment sdk that supports mainstream payment methods such as WeChat Pay, Alipay, Cash App and Braintree etc.

Getting Started

Configuration

How to use

// For WeChat Pay val request = WechatPayReq(appId, partnerId, prepayId, packageValue, nonceStr, timeStamp, sign) Pockyt.createWechatPay().requestPay(request) { vLog.log("Paid:${it.isSuccessful}, cancelled:${it.isCancelled}, $it") }

// For Braintree Drop-in val dropInRequest = DropInRequest() val request = DropInReq(activity, authorization, dropInRequest) Pockyt.createDropIn().requestPay(request) { vLog.log("Obtained nonce:${it.isSuccessful}, cancelled:${it.isCancelled}, desc:${it.respMsg}, vendor:${it.dropInResult?.paymentMethodType}, nonce:${it.dropInResult?.paymentMethodNonce?.string}, deviceData:${it.dropInResult?.deviceData}") if (it.isSuccessful) { submitNonceToServer(jsonObject.optJSONObject("result").optString("transactionNo") , it.dropInResult?.paymentMethodNonce?.string ?: "" , it.dropInResult?.deviceData) } }

// For Card val request = CardReq(activity, authorization, card, true) Pockyt.createCardPay().requestPay(request) { vLog.log("Obtained nonce:${it.isSuccessful}, desc:${it.respMsg}, nonce:${it.cardNonce?.string}, deviceData:${it.deviceData}") if (it.isSuccessful) { submitNonceToServer("Your transactionNo", it.cardNonce!!.string, it.deviceData) } }

// For PayPal val checkoutRequest = PayPalCheckoutRequest("0.01") checkoutRequest.currencyCode = "USD" val paypalRequest = PayPalReq(this, authorization, checkoutRequest, true) Pockyt.createPaypal().requestPay(paypalRequest) { vLog.log("Obtained nonce:${it.isSuccessful}, cancelled:${it.isCancelled}, desc:${it.respMsg}, nonce:${it.paypalNonce?.string}, deviceData:${it.deviceData}") if (it.isSuccessful) { submitNonceToServer("Your transactionNo", it.paypalNonce!!.string, it.deviceData) } }

// For Venmo val request = VenmoReq(this, authorization, VenmoRequest(VenmoPaymentMethodUsage.MULTI_USE), true) Pockyt.createVenmo().requestPay(request) { vLog.log("Obtained nonce:${it.isSuccessful}, cancelled:${it.isCancelled}, desc:${it.respMsg}, nonce:${it.venmoNonce?.string}, deviceData:${it.deviceData}") if (it.isSuccessful) { submitNonceToServer("Your transactionNo", it.venmoNonce!!.string, it.deviceData) } }

// For Google Pay val googlePayRequest = GooglePayRequest() googlePayRequest.transactionInfo = TransactionInfo.newBuilder() .setTotalPrice("1.00") .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL) .setCurrencyCode("USD") .build() googlePayRequest.googleMerchantId = "merchant-id-from-google"; googlePayRequest.isBillingAddressRequired = true val request = GooglePayReq(this, authorization, googlePayRequest) Pockyt.createGooglePay().requestPay(request) { vLog.log("Obtained nonce:${it.isSuccessful}, cancelled:${it.isCancelled}, desc:${it.respMsg}, nonce:${it.paymentNonce?.string}") if (it.isSuccessful) { submitNonceToServer("Your transactionNo", it.paymentNonce!!.string) } }

// For CashApp val requestData = CashAppRequest.OneTimeRequest(scopeId, amount) val request = CashAppReq(clientId, requestData) Pockyt.createCashApp().requestPay(request) { if (it.isSuccessful) { // Payment Approved vLog.log("Payment approved") queryTransactionResult(transactionNo) } else { vLog.log("Payment failed: ${it.respMsg}") } }


* For Braintree, After obtaining the nonce from the payment result, call the Pockyt process API (`/creditpay/v3/process`) to complete the payment.

## Note

* Drop-in UI of Braintree is a complete, ready-made payment UI that offers a quick and easy way to securely accept payments. The UI includes a card entry form and, if enabled, PayPal, Venmo and Google Pay.
* For Braintree payment, it is recommended to retrieve and upload deviceData to reduce the rejection rate. For card payments, you can choose to include threeDSecure verification based on your requirements.
* Due to the refactoring of version 2.x.x using Kotlin, it is not compatible with version 1.x.x, when the android project is pure java language, recommended configuration for supporting Kotlin.
* If you are using WeChat Pay and need to obfuscate your code, please add the following code to ensure the proper functionality of the SDK.

-keep class com.tencent.mm.opensdk. { *; } -keep class com.tencent.wxop.* { ; } -keep class com.tencent.mm.sdk. { *; }