Integrating SDK
6. Integrating SDK
Velocity SDK enables asynchronous communication using the delegate/interface pattern. The SDK enables your mobile application to implement the methods defined by mPoint payment interface.
To integrate the payment methods using the Velocity SDK, complete the following steps:
- Integrate the SDK using the CPD credentials for communicating with Velocity POP.
- Add the SDK path in Gradle file with specific version provided by CPD.
Note: The versions of these files are updated at regular intervals. Check with the CPD technical team if you have the latest version.
- Add nexus repository path in Gradle file
- Run Gradle Build command.
- Instantiate the SDK using the CPD credentials for communicating with Velocity POP.
- Initializing a payment using the SDK involves the following tasks:
- Invoke the initialize method on the SDK instance.
- Handle the SDK call back through the selected payment method.
- Construct the graphical user interface (GUI) for enabling customers to make payment using their selected payment method.
- Implement the following interfaces:
- mPointWalletDelegate
- mPointSchemeOwnerDelegate
- mPoint3DSecureDelegate
- mPointDelegate
- mPointWebViewDelegate
- mPointSchemeOwnerDelegate
- mPointForeignExchangeDelegate
- mPointGetBalanceDelegate
allprojects {
repositories {
maven {
url = uri("https://nexus.cellpointmobile.com/content/repositories/internal")
credentials {
username = "default-read"
password = "CPMRead4321"
}
}
}
}
Note: Instantiating and initializing a payment are common to all payment methods such as card payment, save cards, APM, and wallet.
You can authorize a payment with an SDK for one of the following payment methods:
- Card payment
- APM
- Wallet
- Aggregators
- Offline Payments
- Vouchers
- Split Payment
Note: CPD recommends you implement the following call back error methods for error handling in your application:
handleStatus
is called for high-level errors when the back-end rejects the request and returns one or more status codes giving the reason, or for operations that do not return any data, where the back-end returns the operation status.handleError
is called for low-level errors such as network connectivity problems.
Note: For handling web-view redirects, SDK supports devices with Android 5.0 (application programming interface, or API, level 21) and above only.
6.1 Instantiate SDK
To instantiate the SDK, you must:
- Implement interfaces.
- Ensure that you have all the prerequisites.
Instantiate the SDK by providing the appropriate configuration details as shown in the following code sample:
this._mpoint = mPoint(URL ("[CPD provided URL]"),
this,
"username",[USERNAME]
"password", [PASSWORD]
clientid, [CLIENT ID]
accountid, [ACCOUNT ID]
null,
context,
null,
RecordMap<String, String> (),
arrayOf(ClientInfo.IDENTIFIERS.DEVICEID)
this._mpoint.mode = mPoint.OUTPUT_MODE.NONE)
Note: Instantiating the SDK is common for all payment methods.
6.2 Initialize Payment
Initialize the payment transaction by invoking the initialize method of SDK as shown in the following code sample:
var mobile: Long = [MOBILE NUMBER];
var email: String = "[EMAIL ID]";
var countryId = CountryConfig.USA; //[AMOUNT] for USA
var currencyId = [CURRENCY_ID]
var operatorId = countryId * 100;
var amount = [AMOUNT];
amount= amount*100;
var orderID : String = "[ORDER ID NUMBER]";
var mPointOrderInfo = [ORDER_INFO_AID_DATA]
var txnType: String = mPointTxnInfo.TXN_TYPES. MPOINT_SHOPPING_ONLINE; // An example of Search and Book Flow
mPointClientInfo clientInfo = mPointClientInfo(appid, appversion, mPoint.LANGUAGES.da)
.setCountryId(countryId)
.setMobile(mobile)
.setEmail(email)
.setDeviceId(deviceid)
.setCustomerRef(customerRefId)
.setProfileId(profileId)
mPointInitializePaymentInfo paymentInfo = mPointInitializePaymentInfo()
paymentInfo.amount = amount
paymentInfo.country = CountryConfig.COUNTRIES.getValues().get(countryId)
paymentInfo.operator = operatorId
paymentInfo.mobile = mobile
paymentInfo.email = email
paymentInfo.language = mPoint.LANGUAGES.us
paymentInfo.setOrderno(orderID)
paymentInfo.clientinfo = clientInfo
paymentInfo.setCurrencyid(currencyId)
paymentInfo.txnType = txnType
paymentInfo.setHmac(hmac) // if hmac is available OR
paymentInfo.secretSalt = salt // if salt value is available
paymentInfo.order = mPointOrderInfo
paymentInfo.authToken = authToken
paymentInfo.sessionId = sessionId (required during payment retries)
mpoint.initialize(paymentInfo);
Note: Consider the following items:
- Do not send a float number in the int amount. The SDK handles a float number by multiplying it with 100. For example, the floating digit 100 becomes 10000 and 100.29 becomes 10029.
- Invoking the initialize method is same for card payments, stored cards, APM, wallets and aggregators.
The following are optional parameters: mPointOrderInfo
, authToken
, and sessionId
.
The following table shows a description of initialize payment parameters.
Parameter | Type | Required | Description |
---|---|---|---|
mobile | Integer | Yes | The MSISDN of a customer without International Dialling Code. Note: Mobile number can be mandatory or optional, based on the requirement of a merchant or a PSP. |
deviceId | Integer | Yes | The identification number of a device from which a customer makes a transaction. |
String | No | The email address of a customer. Note: Email can be mandatory or optional, based on the requirement of a merchant or a PSP. | |
countryId | Integer | Yes | The CPD-specific country code, which is available on request. |
currencyId | Integer | Yes | The CPD-specific ID of a currency selected for making payment. |
amount | Integer | Yes | The total amount that a customer is charged for a payment transaction in a country’s smallest currency. For example, the smallest currency of USD is penny. If the transaction amount is $120.30, then the amount field contains value 12030. |
orderId | String | No | The alphanumeric order ID that a merchant generates. Note: Some Payment Providers have strict guidelines for the orderId. The recommended pattern is "[a-zA-Z0-9._-] |
operatorId | Integer | Yes | The identification number of a customer’s Mobile Network Operator. A typical value is “country id” multiplied by 100. |
hmac | String | No | It is deprecated from version 2.3.1 onwards and is applicable only for the mRetail SDK. |
mPointOrderInfo | Object | No | The object of mPointOrderInfo. It contains details of order data and is required only for airlines. |
authToken | String | No | The token that CPD provides for making payment. |
sessionId | Integer | No | The session ID of a transaction. It is required only for required only if a customer retries making payment. |
mPointInitialize PaymentInfo | Object | Yes | The object of mPointInitializePaymentInfo. It contains all details required to construct initialize an API request. |
search and book | Object | Object | This is meant for travel merchants only. Refer to Search and Book Workflow for details. |
You can implement the following methods as part of the call back response for initializing a payment. Implement the displayAvailablePayments
call back method to display the available payment method as shown in the following code sample:
override fun displayAvailablePayments(availablePayments: mPointAvailablePayments?, mpoint: mPoint?) {}
In availablePayments,
the following sub-objects are available:
- Card
- Stored card
- APM
- Third-party wallet
- Aggregators
- Offline payment
- Vouchers
- Split Payment
Updated 7 months ago