Web Services for iOS Core SDK
This section provides a reference for the following Web Service APIs for Code iOS Core:
- Fetch Payment Option
- VAS
- Check Offer Status
- Get Offer Status
- Get EMI According to Interest
- Verify Payment
- Check is Domestic
- Get Transaction Info
- Get Bin Info
- Get Checkout Details
- Lookup API
- Tokenization
Initialise Web Service
Create an object of the PayUWebServiceResponse class and call the respective methods. You will get the result in the completion handler of the method.
PayUWebServiceResponse *webServiceResponse = [PayUWebServiceResponse new];
Note: If there is an error in the parameters passed by the merchant, it will give the errorMessage string. Else, you will get the parsed object.
Fetch payment option
This API will give a payment option enabled for merchants and saved cards. Integrate this API by calling the getPayUPaymentRelatedDetailForMobileSDK
method:
[webServiceResponse getPayUPaymentRelatedDetailForMobileSDK:self.paymentParamForPassing withCompletionBlock:^(PayUModelPaymentRelatedDetail *paymentRelatedDetails, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}else{
// It is good to go & paymentRelatedDetails is having the full detail of it
}
}];
Note:
- paymentRelatedDetails.availablePaymentOptionsArray gives you all the available payment options for you.
- paymentRelatedDetails.oneTapStoredCardArray>, paymentRelatedDetails.storedCardArray, paymentRelatedDetails.netBankingArray, paymentRelatedDetails.cashCardArray, paymentRelatedDetails.EMIArray, paymentRelatedDetails.NoCostEMIArray gives available OneTapCard,StoredCard, NetBanking, CashCard, EMI and NoCostEMI
VAS integration
This API is used to get the list of down Net Banking and down card BIN. Integrate this API by calling the callVASForMobileSDKWithPaymentParam
method:
[webServiceResponse getPayUPaymentRelatedDetailForMobileSDK:self.paymentParamForPassing withCompletionBlock:^(PayUModelPaymentRelatedDetail *paymentRelatedDetails, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}else{
// It is good to go & paymentRelatedDetails is having the full detail of it
}
}];
Note: You can check if a particular NetBanking service is down or not by just passing the bankCode or card-bin (first 6 digits of card number) and in completionBlock, the response will be fetched, for instance.
[webServiceResponse getVASStatusForCardBinOrBankCode:@"AXIB" withCompletionBlock:^(id ResponseMessage, NSString *errorMessage, id extraParam) {
if (errorMessage == nil) {
if (ResponseMessage == nil) {
// It means given NetBanking code or cardnumber is not down i.e. it is in good to go condition
}else{
NSString * responseMessage = [NSString new];
responseMessage = (NSString *) ResponseMessage;
// It means given NetBanking code or cardnumber is down and you can display the responseMessage if you want or you can customize it
}
}else{
// Something went wrong errorMessage is having the Detail
}
}];
Check Offer Details API
This API helps you get the details of the offer key, whether the given offer key is valid or not. If we provide the amount to this API, this API also returns the discount with value. You can use this API for payment modes such as CC/DC, StoreCard, OneTap Card, and NetBanking. Integrate this API by calling the getOfferDetails method. The supported payment types are:
- Credit Card or Debit Card
- Store Card or One Tap Card
- Net Banking
Credit card or debit card
Set the cardnumber
parameter in the paymentParamForPassing
object as in the following code snippet:
self.paymentParamForPassing.cardNumber = @”5123456789012346”;
self.paymentParamForPassing.hashes.offerDetailsHash = @"hash";
After setting cardNumber
call the getOfferDetails method by passing the second parameter as PAYMENT_PG_CCDC
as follows:
[webServiceResponse
getOfferDetails:self.paymentParamForPassing forPaymentType:PAYMENT_PG_CCDC withCompletionBlock:^(PayUModelOfferDetails *offerDetails, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// offerDetails object is having the detail of the offer key
}
}];
Stored card or one-tap card
If you want to check the offer for one particular stored card and then set the card token, use the following code block:
self.paymentParamForPassing.cardToken = @”643567vbhbvgh5678gvv77b”;
self.paymentParamForPassing.hashes.offerDetailsHash = @"hash";
If you want to check the offer for all stored cards and then set cardToken
as empty or null:
self.paymentParamForPassing.cardToken = nil;
self.paymentParamForPassing.hashes.offerDetailsHash = @"hash";
Note: For Stored Card or One Tap Card, you must configure userCredentials inside your payment parameters.
After setting cardToken
, call the getOfferDetails()
method by passing the second parameter as PAYMENT_PG_STOREDCARD
, for instance:
[webServiceResponse
getOfferDetails:self.paymentParamForPassing forPaymentType:PAYMENT_PG_STOREDCARD withCompletionBlock:^(PayUModelOfferDetails *offerDetails, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// offerDetails object is having the detail of the offer key
}
}];
Net Banking
In case merchants want to know whether any particular Net Banking is eligible for the offer, set the bankcode
as described in the following code block:
self.paymentParamForPassing.bankCode = @”AXIB”;
self.paymentParamForPassing.hashes.offerDetailsHash = @"hash";
In case you want to get a list of Net Banking that are eligible for any particular offer, set bankCode
as NIL or empty as described in the following code block:
self.paymentParamForPassing.bankCode = nil;
self.paymentParamForPassing.bankCode = nil;
self.paymentParamForPassing.hashes.offerDetailsHash = @"hash";
After setting bankcode
, call the getOfferDetails()
method by passing the second parameter as PAYMENT_PG_NET_BANKING
as described in the following code block:
[webServiceResponse
getOfferDetails:self.paymentParamForPassing forPaymentType:PAYMENT_PG_NET_BANKING withCompletionBlock:^(PayUModelOfferDetails *offerDetails, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// offerDetails object is having the detail of the offer key
}
}];
Get Offer status
This API is helpful in checking whether the offer is available for a given card number or not. If an offer is available, it will return the discount amount. Integrate this API by calling the getOfferStatus method:
[webServiceResponse getOfferStatus:self.paymentParamForPassing withCompletionBlock:^(PayUModelOfferStatus *offerStatus, NSString *errorMessage, id extraParam) {
if (errorMessage == nil) {
//It is good to go & offerStatus.discount contains the discounted amount if there is any offer & offerStatus.msg contains the message why offer is not available
}
else{
// Something went wrong errorMessage is having the Detail
}
}];
Get EMI amount according to interest
This API helps you get details of all the available EMIs. Set the amount in the payment parameter for this API as described in the following code block.
[webServiceResponse getOfferStatus:self.paymentParamForPassing withCompletionBlock:^(PayUModelOfferStatus *offerStatus, NSString *errorMessage, id extraParam) {
if (errorMessage == nil) {
//It is good to go & offerStatus.discount contains the discounted amount if there is any offer & offerStatus.msg contains the message why offer is not available
}
else{
// Something went wrong errorMessage is having the Detail
}
}];
Call the getEMIAmountAccordingToInterest
method to integrate this API as described in the following code block:
[webServiceResponse
getEMIAmountAccordingToInterest:self.paymentParamForPassing withCompletionBlock:^(NSDictionary *dictEMIDetails, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// dictEMIDetails is having the EMI detail
}
}];
Verify payment
This web service is used to reconcile the transaction with PayU. When PayU posts back the final response to you (merchant), PayU provides a list of parameters (including the status of the transaction). For example, success, failure, etc. On a few occasions, the transaction response is initiated from our end, but it does not reach you due to network issues or user activity (like refreshing the browser, etc.).
Note:
PayU strongly recommends that this API is used to reconcile with PayU’s database once you receive the response. This will protect you from any tampering by the user and help in ensuring safe and secure transaction experience.
For this API, you need to set transactionID inside your payment parameters for instance:
self.paymentParamForPassing.transactionID = @"tnxID1|txnID2|txnID3";
self.paymentParamForPassing.hashes.verifyTransactionHash = @"hash";
Note: You can send multiple txnIDs (transaction IDs) using the pipe symbol(|) as a separator.
Call the verifyPayment()
method to integrate this API as described in the following code block:
[webServiceResponse
verifyPayment:self.paymentParamForPassing withCompletionBlock:^(NSDictionary *dictVerifyPayment, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// dictVerifyPayment is having the verifyPayment detail
}
}];
Check Is Domestic for iOS
The checkIsDomestic API is used to get the following using the BIN number, that is, the first six digits of a credit card or debit card:
- BIN information
- Detect whether a particular BIN number is international or domestic.
- Determine the card’s issuing bank, the card type brand, that is, Visa, Master, etc.,
- Determine the card category, that is, credit, debit, etc.
For this API, you need to set cardNumber
in the payment params similar to the following code block:
self.paymentParamForPassing.transactionID = @"tnxID1|txnID2|txnID3";
self.paymentParamForPassing.hashes.verifyTransactionHash = @"hash";
Call the checkIsDomestic method to integrate this API as described in the following code block:
[webServiceResponse
verifyPayment:self.paymentParamForPassing withCompletionBlock:^(NSDictionary *dictVerifyPayment, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// dictVerifyPayment is having the verifyPayment detail
}
}];
Get transaction info
This API is used to extract the transaction details between two given time periods. The API takes the input as two dates and the time (initial and final) between which the transaction details are needed. The output would consist of the status of the API (success or failed) and all the transaction details in an array format. Set startTime and endTime in the payment params as described in the following code block:
self.paymentParamForPassing.startTime = @"2014-01-12 16:00:00";
self.paymentParamForPassing.endTime = @"2014-01-12 16:00:50";
self.paymentParamForPassing.hashes.getTransactionInfoHash = @"hash";
Call the getTransactionInfo
method to integrate with this API as described in the following code block:
[webServiceResponse
getTransactionInfo:self.paymentParamForPassing withCompletionBlock:^(NSArray *arrOfGetTxnInfo, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// arrOfGetTxnInfo is the array of PayUModelGetTxnInfo which is having detail of transaction
}
}];
GetBinInfo API – iOS
The GetBinInfo API is used to detect whether a particular BIN number is international or domestic. In addition, it is useful to determine the card’s issuing bank, the card type brand, that is, Visa, Mastercard, etc., and the card category, that is, credit card, debit card, etc. The BIN number is the first six digits of a credit or debit card. This API is also helpful in knowing whether the card BIN is eligible for Standing Instructions. For this API, you need to set the card number in the payment parameters.
This API is used to get the card BIN details. For this API, you need to set the following parameter in the payment params similar to the following code block:
self.paymentParamForPassing.startTime = @"2014-01-12 16:00:00";
self.paymentParamForPassing.endTime = @"2014-01-12 16:00:50";
self.paymentParamForPassing.hashes.getTransactionInfoHash = @"hash";
Call the GetBINInfo method to integrate with this API as described in the following code block:
[webServiceResponse
getTransactionInfo:self.paymentParamForPassing withCompletionBlock:^(NSArray *arrOfGetTxnInfo, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// arrOfGetTxnInfo is the array of PayUModelGetTxnInfo which is having detail of transaction
}
}];
GetCheckoutDetails API
It provides information on additionalCharges, bankDownStatus, taxSpecification, offerDetails, customerEligibility, merchantDetails, extendedPaymentDetails, and pg id information for payment options on a merchant key. Calling this API is similar to other Web Services, the only difference is that it requires a JSON in var1. Check the following code block for more details:
{
"useCase":{
"getExtendedPaymentDetails":true,
"getTaxSpecification":true,
"checkDownStatus":true,
"getAdditionalCharges":true,
"getOfferDetails":true,
"getPgIdForEachOption":true,
"checkCustomerEligibility":true,
"getMerchantDetails":true,
"getPaymentDetailsWithExtraFields":true
},
"filters":{
"paymentOptions":{
"emi":{
"dc":"HDFC",
"cardless":"ZESTMON"
},
"bnpl":"MOBIZIP"
}
},
"requestId":"iOS230113135103",
"customerDetails":{
"mobile":"9876543210"
},
"transactionDetails":{
"amount":"1"
}
}
Here, requestId is a unique random number passed in the request.
For this API, you need to set amount, additionalCharges, checkDownStatus, checkTaxSpecification, checkOfferDetails, checkCustomerEligibility, getMerchantDetails, getExtendedPaymentDetails and getPgIdForEachOption in the payment parameters, for instance:
self.paymentParamForPassing.getExtendedPaymentDetails = true;
self.paymentParamForPassing.checkTaxSpecification = true;
self.paymentParamForPassing.checkDownStatus = true; self.paymentParamForPassing.checkAdditionalCharges = true;
self.paymentParamForPassing.checkOfferDetails = true; self.paymentParamForPassing.getPgIdForEachOption = true; self.paymentParamForPassing.checkCustomerEligibility = true;
self.paymentParamForPassing.getMerchantDetails = true; self.paymentParamForPassing.getPaymentDetailsWithExtraFields = true;
self.paymentParamForPassing.amount = @"<Amount>"; self.paymentParamForPassing.hashes.getCheckoutDetailsHash = @"hash"; PayUModelGetCheckoutAPIFilters *getCheckoutAPIFilters = [PayUModelGetCheckoutAPIFilters new]; getCheckoutAPIFilters.dcEMIBankCode = @"<BankCode>"; getCheckoutAPIFilters.cardlessEMIBankCode = @"<BankCode>"; getCheckoutAPIFilters.bnplBankCode = @"<BankCode>"; self.paymentParamForPassing.getCheckoutAPIFilters = getCheckoutAPIFilters;
To integrate this API, call the getCheckoutDetail for instance:
[webServiceResponse
getCheckoutDetail:self.paymentParamForPassing withCompletionBlock:^(NSArray *paymentRelatedDetails, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// paymentRelatedDetails object is having the required detail
}
}];
Lookup API
This API is used when integrating multi-currency payments. To use Lookup API for iOs, follow these subsections:
- Prerequisites
- Post Parameters
- Calculate the Signature for Hash
Before you begin
Connect with your Key Account Manager at PayU to get the following credentials:
- Merchant Access Key
- Merchant Secret Key
Lookup API needs a JSON request. Product types need to be passed either as DCC or MCP. Direct Currency Conversion (DCC) returns the conversion prices for card currency only. To get all enabled currencies on Merchant Access Key along with their conversion prices, use product type as MCP. For DCC, cardBin is mandatory, while for MCP cardBin is not required
The following example is to request for MCP as a product type:
{
"merchantAccessKey":"E5ABOXOWAAZNXB6JEF5Z",
"baseAmount":
{
"value":10000.00,
"currency":"INR"
},
"merchantOrderId":"OBE-JU89-13151-110",
"productType":"MCP",
"signature":"be5a56667354d9e2ea5ea1c6af78b0afc1894eb2"
}
For this API you need to set the amount, lookupAPIHash, and lookuprequestId parameters in the payment parameters for instance.
self.paymentParamForPassing.amount = @"Total amount";
self.paymentParamForPassing.hashes.lookupApiHash = @"HMACSHA1 Signature";
self.paymentParamForPassing.lookupRequestId = @"Any unique id";
Request parameters
The details of the parameters used in Lookup API are:
Parameter | Description |
---|---|
Amount | Transaction Amount |
Card Bin | First 6 digits of the card number |
Currency | Base Currency of Transaction (“INR”) |
Merchant Access Key | Merchant Access Key provided by PayU |
Merchant OrderId | A unique request id for the Lookup API request |
Product Type | Use MCP to get all enabled currency on Merchant Access Key or DCC to get direct currency conversion for card currency |
Signature | Hmac SHA1 hash created with formula explained below |
Calculate the signature for hash
Use the following data to calculate the signature for creating the HmacSHA1 hash.
Signature
=HMAC-SHA1(data, key);Data
= baseCurrency+merchantOrderId+baseAmountKey
= Secret Key shared with the merchant at the time of onboardingExample
: INROBE-JU89-13151-11010000.00
To integrate this API, call the mcpLookup
method for instance:
[webServiceResponse
mcpLookup:self.paymentParamForPassing withCompletionBlock:^(PayUModelMultiCurrencyPayment *paymentRelatedDetails, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// PayUModelMultiCurrencyPayment object is having the required detail
}
}];
Check Sodexo card balance
This can be used to fetch detail of the Sodexo card with the source ID:
self.paymentParamForPassing.sodexoSourceId = @"<Sodexo source id>;
self.paymentParamForPassing.hashes.checkBalanceApiHash = @"hash";
To integrate this API call the fetchSodexoCardDetails method similar to the following code block:
[webServiceResponse
fetchSodexoCardDetails.paymentParamForPassing withCompletionBlock:^(PayUModelSodexoCardDetail *sodexoCardDetail, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
// sodexoCardDetail object is having the required detail
}
}];
Tokenized payment
You can store and get stored card details from the vault.
Get tokenized payment details
Get details of the stored card to make payment on another PG.
self.paymentParam.userCredentials = @"<user_credentials>";
self.paymentParam.cardToken = @"<cardToken>";
self.paymentParam.amount = @"100";
self.paymentParam.currency = @"INR";
self.paymentParamForPassing.hashes.getTokenizedPaymentDetailHash = @"hash";
To integrate this API call the getTokenizedPaymentDetails method similar to the following:
[webServiceResponse getTokenizedPaymentDetails.paymentParamForPassing withCompletionBlock:^(PayUModelTokenizedPaymentDetails *tokenizedPaymentdetails,NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
//It is good to go & deleteStoredCardMessage is having the full detail of it
}
}];
Get tokenised stored cards
This API is helpful in getting all the stored cards for a particular user. For this API, you need to set theuserCredentials
in the payment params similar to the following:
self.paymentParam.userCredentials = @"<user_credentials>";
self.paymentParamForPassing.hashes.getTokenizeddStoredCardHash = @"hash";
To integrate this API call the getTokenizedStoredCards method similar to the following:
[webServiceResponse getTokenizedStoredCards:self.paymentParamForPassing withCompletionBlock:^(NSDictionary *dictStoredCard,NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
//It is good to go & deleteStoredCardMessage is having the full detail of it
}
}];
Delete tokenised stored cards
This API is helpful in deleting stored cards.
self.paymentParam.userCredentials = @"<user_credentials>";
self.paymentParam.cardToken = @"<cardToken>";
self.paymentParam.networkToken = @"<networkToken>";
self.paymentParam.issuerToken = @"<issuerToken>";
self.paymentParamForPassing.hashes.deleteTokenizedStoredCardHash = @"hash";
To integrate this API call the deleteTokenizedStoredCard method similar to the following:
[webServiceResponse deleteTokenizedStoredCard:self.paymentParamForPassing withCompletionBlock:^(NSString *deleteStoredCardStatus, NSString *deleteStoredCardMessage, NSString *errorMessage, id extraParam) {
if (errorMessage) {
// Something went wrong errorMessage is having the Detail
}
else{
//It is good to go & deleteStoredCardMessage is having the full detail of it
}
}];
Updated about 1 month ago