Integration for Stored Card
8. Integration for Stored Card
To opt for the save card feature, you can contact the CPD team during the onboarding process. You can select the either the CPD card vault or a third-party vault. You need to send an authentication token for a single sign-on.
- When the SDK receives an initialize response, it checks if the response contains an mPoint Store-card.
If it contains a store card
- The SDK notifies the application that the store cards are available.
- The SDK provides a callback in the displayAvailablePayments method.
- You can authorize transactions for which customers use a stored card by providing CVV.
If the transaction is successful, you receive a callback in
displaPaymentConfirmation.
8.1 Initialize Request
You can Initialize Payment as given in the previous section.
Note: In initialize request for cards stored in Velocity wallet, you need to send an auth token or SSO token to authenticate a customer.
Initialize Response
To initialize a payment using stored cards, show the cards stored in a wallet. Implement the displayAvailablePayments
call back method to display the available wallets as shown in the following code sample:
override fun displayAvailablePayments(availablePayments: mPointAvailablePayments?, mpoint: mPoint?) {}
In the availablePayments,
the following sub-objects are available:
- Card
- Stored card
- APM
- Third-party wallet
- Aggregators
- Offline Payment
- Vouchers
8.2 Dynamic Currency Conversion
To make payment for a stored card, create the mPointExchangeOfferCriteria
object; instead of card number, send card ID as shown in the following code sample:
var offerCriteria = mPointExchangeOfferCriteria()
.setOrderNumber(orderId)
.setCardId(selectedCard.id) .setCardType(cardtype) .setCountry(CountryConfig.COUNTRY_CODES.getValues()
.get(countryid))
.setSaleAmount(saleAmount)
.setTransactionId(_mPoint.txnInfo.id) .setClientId(CLIENT_ID)
.setAccountId(ACCOUNT_ID)
.setClientInfo(clientInfo)
_mPoint.getForeignExchangeOffer(offerCriteria)
8.3 Authorize Card
You authorize payment either by showing a new card or a stored card. To authorize a card payment, show the cards stored in the vault, provide auth token, billing address, and client information. You can enable customers to provide their card CVV, depending on the PSP for a transaction.
8.3.1 FX Opt-in
An opt-in transaction is when a customer is making a payment with a new card and selects a card currency other than the original sale currency. The flow of the opt-in transaction is as follows:
- Complete the initialize payment successfully.
- Consume the FX API successfully.
- Finalize the payment offer and invoke the auth API as follows:
- Customers opted to make payment in currency other than the sale currency.
- Send opt-in as a Boolean flag as true.
- Send standard authorize parameters.
Note: The opt-in and SetDccOpted depends on a merchant’s requirement.
Refer to Dynamic Currency Conversion to create the mPointForeignExchangeInfo
object. For opt-in transactions, refer to the following code.
foreignExchangeInfo?.setDccOpted (true)
8.3.2 FX Opt-out
In opt-out transactions, the customer has the option to make payment in available card currencies but chooses to make payment in the sale currency. The flow of an opt-out transaction is as follows:
- Complete the initialize payment successfully.
- Consume the FX API successfully.
- Finalize the payment offer and invoke the auth API as follows:
- Customers opted to make payment using sale currency.
- b. Send opt-in as a Boolean flag as
false.
- Send standard authorize parameters.
Refer to Dynamic Currency Conversion to create the mPointForeignExchangeInfo
object. For opt-in transactions, refer to the following code.
foreignExchangeInfo?.setDccOpted(false)
The following code is an example of making payment with a new card with an option to save the card. To save a card set the value of setStoreCard
as true
, else set it as false.
When the next payment is made, the stored cards are displayed.
_mPoint.authorize(mPointAuthorizeInfo(cardtype)
.setCardNo(java.lang.Long.valueOf(cardNumer))
.setCardExpMonth(Integer.parseInt(expiryMonth))
.setCardExpYear(Integer.parseInt(expiryYear))
.setCvc(tempCvv.toString())
.setNameOnCard(cardName)
.setStoreCard(false)
.setCardValidFromMonth(validMonth.toInt())
.setCardValidFromYear(validYear.toInt())
.setClientInfo(clientInfo)
.setAddressInfo(addressInfo))
.setForeignExchangeOffer(foreignExchangeInfo)
To authorize a transaction using stored card, implement the following code:
mPoint.authorize(mPointAuthorizeInfo(cardtype)
.setTypeId(mPoint.AUTH_CARD)
.setPassword(authToken)
.setCvc(cvc)
.setViaAuthToken(true)
.setAuthToken(authToken)
.setForeignExchangeOffer(foreignExchangeInfo)
.setAddressInfo(addressInfo)
.setClientInfo(clientInfo))
To send authentication token during a transaction, set the value of setViaAuthToken
to true.
If you set it as false,
the authentication token is not sent.
8.4 3DS Redirection
Implement the displayWebView
method for 3DS redirection. This method generates a one-time password for a card transaction and provides a WebView instance. 3DS provides an additional layer of security. The displayWebView
method is used in all types of payment such as stored card, wallet, and APM.
Note: Implementing 3DS redirection depends on the PSP you select for conducting transactions.
override fun displayRaw3DSecureChallenge(mpoint: mPoint?): WebView
8.5 Payment Confirmation
Implement the displayPaymentConfirmation
call back method to receive the transaction status as shown in the following code sample:
override fun displayPaymentConfirmation(txn: mPointTxnInfo?, code: Int, mpoint: mPoint) {
Log.d(TAG, "displayPaymentConfirmation")
}
8.6 Create Account
Invoke the saveAccount
call to receive a callback in display to create, and then save an account.
Invoke the saveAccount call to receive a callback in display to create, and then save an account.
You must configure at least one of the following parameters to enable customers to create a profile:
- Mobile
- Email address
- Customer reference or customer ID
Note: A customer ID is unique and depends on the configured identification parameter.
You can configure this API in the following manner:
- Store account of customers directly in mPoint, which users can access using a password.
- Use single sign-on to verify a profile:
- Valid for both mProfile and third-party profile (mandatory)
- You must share authorization token with request if you are using an external CRM.
- You can authorize transactions for which customers use a stored card by providing CVV.
If the transaction is successful, you receive a callback in
displaPaymentConfirmation.
An eua-id is created after the profile of your customer is saved with Velocity. The following table provides the values of eua-id used to identify APIs that are called.
Eua-id | APU method used |
---|---|
-1 | Save account |
Greater than 0 | Save account |
The descriptions of the parameters are listed in the table below.
Parameter | Type | Description |
---|---|---|
fullname | String | The full name of the customer; pass this value as null to avoid collecting this information. |
card | Integer | The full name of the customer; pass this value as null to avoid collecting this information. |
cardname | String | The card name entered by a customer; pass it as null if the does not name the card. |
address | String | The billing address of a customer. |
authToken | String | The authentication token generated when a customer logs in. |
8.7 Save Card
When you receive callback in the display save card method, invoke the following method to save the profile of a customer. You must configure at least one of the following parameters to enable customers to create a profile:
- Mobile
- Email address
- Customer reference or customer ID
Note: A customer ID is unique and depends on the configured identification parameter.
You can configure this API in the following manner:
- Store account of customers directly in mPoint, which users can access using a password.
- Use single sign on to verify a profile: Valid for both mProfile and third-party profile (mandatory)
- You must share authorization token with request if you are using an external CRM. An eua-id is created after the profile of your customer is saved with Velocity.
The following table provides the values of eua-id used to identify APIs that are called.
Note: Invoke the save card payment flow only.
public void _saveCard(card : mPointCardInfo, name : String, clientinfo : mPointClientInfo, preferred : Boolean, address : mPointAddressInfo, authToken : String, cardHolderName : String)
The descriptions of the parameters are listed in the table below.
Parameter | Type | Description |
---|---|---|
card | Integer | The payment card which was used for an authorization. |
name | String | The card name entered by a customer; the value is Null if no changes are made to the card name. |
clientinfo | String | The clientinfo object used for identifying a customer. |
preferred | String | The value for this parameter can be one of the following:
|
address | String | The billing address of a customer. |
authToken | String | The authentication token generated to enable a customer to log in. |
8.8 Log in to Velocity Wallet
Your customers can log in to their profile using their credentials. You need to send an authentication token or SSO token to mPoint login API to authenticate them.
Note: The profile system can be of Velocity, merchant, or third-party.
You can use the following code sample for an SSO token:
public void loginViaToken(authToken: String, clientinfo : mPointClientInfo)
8.9 Update Card
You can implement the updateCard
method to update the
- Cards of your customers’ accounts
- Details of the customers’ stored cards
The descriptions of the parameters are listed in the table below.
Parameter | Type | Description |
---|---|---|
card | Integer | The card used for the authorization of payment. |
name | String | The name that a customer enters for a card. This value is null if no changes are made to the card name. |
cardHolderName | String | The name that a customer enters for a card holder. This value is null if no changes are made to the card name. |
expiryMonth | String | The month in which a card expires. |
expiryYear | String | The year in which a card expires. |
preferred | String | The value of the parameter can be one of the following: True if a card is preferred. False if a card is not preferred. Null if the setting is not changed. |
address | String | The address of the card holder. |
authToken | String | The authentication token from the mProfile. |
clientinfo | Object | The clientinfo object that specifies a customer. |
8.10 Delete a Card
If you use Delete a Card using auth token/access token/SSO token from the wallet, you must call the login API when a customer logs in. You can invoke the delete Card API only after the customer logs in.
You must send the following para card ID received in login API and set through viaAuthToken
.
Use following method to delete card from a wallet:
public void deleteCard(cardid: Int, String : accessToken, clientinfo : mPointClientInfo, viaAuthToken : Boolean)
The descriptions of the parameters are listed in the table below.
Parameter | Type | Description |
---|---|---|
cardid | Integer | The identification number of the card that will be deleted. |
accessToken | Alphanumeric string | A customer's authentication token or password. |
clientinfo | Object | The client information that needs to be included in a request. |
viaAuthToken | Boolean | Defines if the access is through an authentication token or a password. |
8.11 Delete Account
You can use the following code sample to enable customers to delete their account.
public void deleteAccount(password : String, accessToken : String, account : mPointAccountInfo, clientinfo : mPointClientInfo)
The descriptions of the parameters are listed in the table below.
Parameter | Type | Description |
---|---|---|
password | String | User password to log in. |
accessToken | Alphanumeric string | The customer’s authentication token or password. |
account | Object | The mPoint user account information. |
clientinfo | Object | The client information that needs to be included in the request. |
8.12 Handle Error
When using the split payment option, after getting callback in displayPaymentConfirmation you need to call getTxnStatus method to retrieve status of the transactions. When calling getTxnStatus pass session ID (available in mPoint class) to retrieve all transactions from the current session. To call getTxnStatus, use the following code sample:
if(isSplitPaymentApplicable){
if(mpoint!!.sessionId != null && mpoint.sessionId.isNotEmpty()){
mPoint.delegate = this
mPoint.getTxnStatus(-1, "", mpoint.sessionId, clientInfo)
}
}
To get transaction statuses response implement following delegate method:
override fun handleTxnStatus(arrListTxnStatusInfo: ArrayList<mPointTxnStatusInfo>?, paymentStatus: Int, arrListLinkedTransactions: ArrayList<mPointLinkedTransactions>?, mPoint: mPoint?) {
runOnUiThread {
var pendingAmount: Long = 0
if(null != arrListTxnStatusInfo && arrListTxnStatusInfo.size > 0){
for (txnStatusInfo : mPointTxnStatusInfo in arrListTxnStatusInfo){
// Retrieve Pending Amount
pendingAmount = txnStatusInfo.pendingAmount
}
}
when (paymentStatus) {
com.cellpointmobile.sdk.mPoint.PAYMENT_STATUS.MPOINT_PAYMENT_STATUS_PENDING.id ->
// Poll getTxnStatus()
getTxnStatus(mPoint!!.sessionId)
com.cellpointmobile.sdk.mPoint.PAYMENT_STATUS.MPOINT_PAYMENT_STATUS_COMPLETE.id -> {
if(pendingAmount == 0L)
// Split Payment Successful
else
// Retry Payment with Pending Amount
}
com.cellpointmobile.sdk.mPoint.PAYMENT_STATUS.MPOINT_PAYMENT_STATUS_FAILED.id -> {
// Retry Payment with Pending Amount
}
}
}
}
The merchant front end reads the response received to know the payment status. Read the paymentStatus parameter to know the status of the payment. If a transaction status has payment status as:
- Pending: call the getTxnStatus API again until you get the payment status either as Successful or Failed.
- Complete: the payment is successful.
- Failed: retry the payment.
To retry the payment, initialize the payment with the pending amount. This action helps a customer complete the payment using any option.
Send the pending amount you received from back end in the initialize request. After you initialize, a customer can complete the payment using any available payment option or can split the payment. This process repeats until the transaction is successful, fails, or maximum retries are attempted.
Note: If a customer decides not to retry a failed payment, call the Post-Status API as shown in the following code sample to notify that the session is complete:
mPoint.postStatus(mPoint.sessionId)
Refer to Handle Error for details.
8.13 Handle Status
Refer to Handle Status for details.
8.14 Sending FX Indicator
Refer to Sending FX Indicator for details.
Updated 7 months ago