iOS Native SDK(v2) - Merchant's Checkout
Please follow steps below to setup iOS Native SDK and start accepting payment via PortOne.
#
Steps to integrate iOS SDK:Download the framework from here
After downloading the .xcframework, drag and drop it in the project
Go to General → Frameworks, Library and Embedded Content and then drop the framework and change the Embed to Embed & sign.
Import the PortOnePaymentSDK as below at the required places.
Initialize the checkout instance to get the available methods in SDK as below
Set the environment as "dev" , "staging" to test in the required environments as below. While moving to the Production, set the environment to prod(default as prod).
Should pass the delegate to the initialization
Should implement the delegate methods as below to get the response of failure and success callbacks from the webView.
In the info.plist add the new Array type node LSApplicationQueriesSchemes as below:
Include the URLType in info.plist to redirect to your app(deep linking) as below
#
Handle the deep link- In sceneDelegate, redirect the deep link url to checkout instance
#
Initiate payments in following ways- Initiate with tokenization flow
- new credit card Payment
- saved credit card payment
- Initiate payment with non tokenization flow
- wallets, BNPL, net banking
Initiate the wallet Payment
Initialize the wallet payment with transactionRequest as below:
Pass the TransactionRequest to initiateWalletPayments as below:
Handle the success and failure cases from the delegate method as below:
#
Sample responseSuccess callback :
Failure Callback:
Initiate with new credit card Payment
Initialize the new card payment with transactionRequest as below:
cardDetails:
Pass the TransactionRequest and cardDetails to initiateNewCardPayment as below:
Handle the success and failure cases from the delegate method as below:
Sample Success and failure callback :
#
Initiate with Saved credit card PaymentInitialize the saved card payment with transactionRequest as below:
cardDetails:
Pass the TransactionRequest and cardDetails to initiateSavedCardPayment as below:
Handle the success and failure cases from the delegate method as below:
*Sample Success and failure callback :*
#
Fetch the saved cards for a particular numberCapture the mobile number and OTP to fetch the saved credit cards for a particular user.
To generate the OTP, call the method as below:
Parameter Description
Parameter Data type Mandatory Description mobileNumber string yes pass the mobile number with country code Response Description
Parameter Data type Description status_code String provides the code based on the transaction status (e.g: "2000", "3000") status_reason String provides the reason for failure additional_details object provides additional Information like message Id, SequenceNumber Sample Response :
After receiving the OTP to the given mobile number, the captured mobile number and OTP should pass to the fetchSavedCards as below to fetch the saved credit cards for the particular number.
Parameter Description
Parameter Data type Mandatory Description portOneKey string yes pass the portOne key formattedText string yes Contains mobile number with Country code. (eg: +16625655248 , +918341234123) OTP string yes Otp received to the given mobile number token string yes Token received from this api, if token is passed. then we can skip entering the otp part until the token is expiry. Response Description
Parameter Data type Description status_code String provides the code based on the transaction status (e.g: "2000", "3000") status_reason String provides the reason for failure additional_details object provides additional Information like message Id, SequenceNumber Sample Success and failure response:
#
Get Available Payment methodsGet the available payment methods with portOne key as below
Parameter Description
Parameter Data type Mandatory Description portOneKey string yes pass the portOne key currency string yes currency. (eg: VND, THB)
Sample Response:
Success and failure case
#
Pre-auth Transactions:Pass the transaction-type value in payload as PREAUTH to make a transaction without capture
transaction-type values are "PURCHASE" || "PREAUTH".
PURCHASE - for normal transaction
PREAUTH - for without capture transactions
To capture the transaction, call the captureTransactionAPI from the sdk with portOneOrderRef , portOnekey, jwtToken as the params.
Parameter Description
Parameter Data type Mandatory Description transactionOrderRef string yes Transaction order Id clientKey String yes PortOne key Response Description
Parameter Data type Description status_code String provides the code based on the transaction status (e.g: "2000", "3000") status_reason String provides the reason for failure message String provides user friendly message for the reason of failure is_success Bool true/false
#
Failover routing:For failover routing, need to pass the params of routingEnabled and routingParams in the payload while doing a transaction
Parameter Description
Parameter Data type Mandatory Description routingEnabled Bool yes true / false (if true, then it will capture as a failover routing) routingParams Object yes, if routingEnable is true type: "failover", route_ref: String(capture from merchant portal or via fetch routes api) Fetch Routes with portone key
Parameter Description
Parameter Data type Mandatory Description clientKey String yes PortOne key jwtToken string yes generate token with portone key and secret key.
#
Merchant centric card vault methodsAdd customer card
To add the card data for a customer, need to pass the customerId, client key, jwtToken and card details to the below method
Parameter Description
Parameter Data type Mandatory Description customerId String yes Customer Id clientKey String yes PortOne key cardDetails Object yes Pass the card details (card holder name, card number , expiry month, year and cvv ) jwtToken string yes generate token with portone key and secret key. Response Description
Parameter Data type Description message String Readable message status_reason string status reason status_code string provides the code based on the transaction status (e.g: "2000", "3000") content object provides the card details with token
Sample success and failed response code
Delete customer card
To delete the card data for a customer, need to pass the card token, customer id, client key, jwtToken to the below method
Parameter Description
Parameter Data type Mandatory Description customerId String yes Customer Id clientKey String yes PortOne key cardData Object yes Pass the card token jwtToken string yes generate token with portone key and secret key. Response Description
Parameter Data type Description message String Readable message status_reason string status reason status_code string provides the code based on the transaction status (e.g: "2000", "3000") Sample success and failed response code
Fetch all customer cards
To fetch all the cards data for a customer, need to pass the customer id, client key, jwtToken to the below method
Parameter Description
Parameter Data type Mandatory Description customerId String yes Customer Id clientKey String yes PortOne key jwtToken string yes generate token with portone key and secret key. Response Description
Parameter Data type Description message String Readable message status_reason string status reason status_code string provides the code based on the transaction status (e.g: "2000", "3000") content Object provides the list of card details in data object data Array Array of card details token String Card token partial_card_number String card number expiry_month String card expiry month expiry_year String card expiry year type String card type payment_channel_token Object can be ignore (PSP related data)
Sample success and failed response code
#
Sample Payload request:#
Sample success and failure responseGeneration#
Steps for Signature HashSample creation of signature hash. Follow the steps from the above link for more understanding
Generation#
Steps for generating JWT TokenSample creation of JWT token. Follow the steps from the above link for more understanding