Skip to content
kdevjanr edited this page Jul 31, 2023 · 8 revisions

Android Mobile SDK

Before you start the integration

Read through the following steps first to understand how the integration process works. This will help you to understand why these steps are required and why you need to follow a specific sequence.

Step 1: Access your test account

You need to make sure that you have access to a test account with Amazon Payment Services. It is a full test environment that allows you to fully simulate transactions.

Step 2: Choose between a standardized or custom payment UI

The Amazon Payment Services Android SDK provides you with a standard payment UI that you can use to quickly integrate in-app payments. The standard UI offers limited customizability.

Alternatively, you can choose to build your own payment UI using Amazon Payment Services Android SDK building blocks, we describe this in the section on custom-coding a payment processing UI.

Step 3: Make sure that you are using the correct integration type

Prior to building the integration, you need to make sure that you are selecting and using the proper parameters in the API calls as per the required integration type. All the mandatory parameters are mentioned under every section in the API document

Step 4: Install the Amazon Payment Services Android SDK in your development environment

You need to add the repositories to your build file and add the SDK to your build.gradle, also setting the correct Android permissions.

Step 5: Create a test transaction request

You need to create a test transaction request. Processing a valid API request depends on transaction parameters included, you need to check the documentation and read every parameter possible to reduce the errors in processing the transaction.

Step 6: Process a transaction response

After every payment, Amazon Payment Services returns the transaction response on the URL configured in your account under Technical Settings, Channel Configuration.

For more details check the transaction feedback instructions. You need to validate the response parameters returned on this URL by calculating the signature for the response parameters using the SHA response phrase configured in your account under security settings.

Step 7: Test and Go Live

You can use our test card numbers to test your integration and simulate your test cases. The Amazon Payment Services team may need to test your integration before going live to assure your application integration.

Mobile SDK transaction workflow

Below, we describe the transaction workflow when you process a payment using the Amazon Payment Service Android Mobile SDK.

  1. Your customer clicks on the Pay button in your app.

  2. Your merchant system (back-end) generates a mobile SDK token using the Amazon Payment Services API

  3. Your app passes the parameters, including the SDK token, to the Android mobile SDK

  4. The Android mobile SDK starts a secure connection and sends the transaction request to the Amazon Payment Services server to be validated.

  5. The Amazon Payment Services API validates the SDK token, device_ID and other request parameters and returns the validation response to the Android SDK.

  6. Assuming validation is passed your merchant app displays a payment page to the customer.

  7. Your customer enters their payment details on the payment page in the Android SDK prompt on their device.

  8. The Amazon Payment Services Android SDK validates your customer's details and sends a transaction (Authorization or Purchase) request to the relevant payment processor and issuing bank.

  9. The payment processor processes the transaction request and returns a transaction response to the Android SDK

  10. The Amazon Payment Services Android SDK returns the transaction response to your merchant app

  11. Your merchant app displays the response to your customer

Installing the Mobile SDK

These are the first steps you need to follow to integrate the Amazon Payment Services Android SDK into your Android application.

Installing the Android Mobile SDK

You need to complete two steps to install the Amazon Payment Services Android SDK.

Step 1

First, you need to add the repository to your build file. Add it in your root build.gradle at the end of repositories:


allprojects {
  repositories {
    ...
    maven { url https://android-sdk.payfort.com }
  }
}



Step 2

Add the Add fortSDK to your build.gradle dependencies using this code:


apply plugin: 'com.android.application' 
android { ... } 
dependencies {
  implementation("com.amazon:fortpayment:+:release@aar"){
    transitive = true
}  
}


Setting Android OS permissions

You need to set the following two permission so that the Android mobile SDK works properly:


< uses-permission android:name="android.permission.INTERNET" />
< uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


Creating a mobile SDK token

A mobile SDK authentication token is required to authenticate every request sent to the SDK. The token is also significant to process payment operations with Amazon Payment Services through our Android mobile SDK.

To get started with our Android mobile SDK you must first establish the ability to generate a mobile SDK token.

NOTE: The creation and initiation of a mobile SDK token happens on your server -- your server must generate the token by sending a request to the Amazon Payment Services API.

A unique authentication token must be created for each transaction. Each authentication token has a life-time of only one hour if no new request from the same device is sent.

Android mobile SDK token URLs

These are the URLs you need to use when you request a mobile SDK token for your Android app:

Test Environment URL

https://sbpaymentservices.payfort.com/FortAPI/paymentApi

Production Environment URL

https://paymentservices.payfort.com/FortAPI/paymentApi

Submitting token request parameters

You need to submit parameters as a REST POST request using JSON. Below we list the range of parameters for the Android mobile SDK token request.

Android Mobile SDK Token Request Parameters

When you send your request for an Android mobile SDK token you must send the following parameters to Amazon Payment Services:

Mobile SDK Token Request Parameters

Mobile SDK Token Request Example

error_reporting(E_ALL);
ini_set('display_errors', '1');

$url = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';

$arrData = array(
'command' => 'SDK_TOKEN',
'access_code' => 'xxxxxxxx',
'merchant_identifier' => 'xxxxxx',
'language' => 'en',
'device_id'=> 'ffffffff-a9fa-0b44-7b27-29e70033c587',
'signature' => '7cad05f0212ed933c9a5d5dffa31661acf2c827a'
);


$ch = curl_init( $url );
# Setup request to send json via POST.
$data = json_encode($arrData);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
# Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
# Send request.
$result = curl_exec($ch);
curl_close($ch);
# Print response.
echo "$result";
curl -H "Content-Type: application/json" -d
'{"command":"SDK_TOKEN","language":"en","access_code":"xxxxx","merchant_identifier":"xxxxx",,"language":"en","device_id":"ffffffff-a9fa-0b44-7b27-29e70033c587",
"signature":"7cad05f0212ed933c9a5d5dffa31661acf2c827a"}'
https://sbpaymentservices.payfort.com/FortAPI/paymentApi
import urllib
import urllib2
import json

url = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';
arrData = {
'command' : 'SDK_TOKEN',
'access_code' : 'xxxxxx',
'merchant_identifier' : 'xxxxxx',
'language' : 'en',
'device_id': 'ffffffff-a9fa-0b44-7b27-29e70033c587',
'signature' : '7cad05f0212ed933c9a5d5dffa31661acf2c827a',
};

values = json.dumps(arrData)
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
page = response.read()
print page + '\n\n'
String jsonRequestString = "{\"command\" : \"SDK_TOKEN\" , "
       +"\"access_code\" : \"xxxxxxxx\", "
       +"\"merchant_identifier\" : \"xxxxxx\", "
       + "\"language\" : \"en\","
       + "\"device_id\"\"ffffffff-a9fa-0b44-7b27-29e70033c587\", "
       + "\"signature\" : \"7cad05f0212ed933c9a5d5dffa31661acf2c827a\"}";

// Define and Initialize HttpClient
HttpClient httpClient = HttpClientBuilder.create().build();
// Intialize HttpPOST with FORT Payment services URL
HttpPost request = new HttpPost("https://sbpaymentservices.payfort.com/FortAPI/paymentApi");
// Setup Http POST entity with JSON String
StringEntity params = new StringEntity(jsonRequestString);
// Setup request type as JSON
request.addHeader("content-type", "application/json");
request.setEntity(params);
// Post request to FORT
HttpResponse response = httpClient.execute(request);
// Read response using StringBuilder
StringBuilder sb = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(
   response.getEntity().getContent()), 65728);
String line = null;
while ((line = reader.readLine()) != null) {
 sb.append(line);
}
// Print response
System.out.println(sb.toString());
require 'json'
require 'net/http'
require 'net/https'
require 'uri'
require 'openssl'

arrData = {
'command' => 'SDK_TOKEN',
'access_code' => 'xxxxxx',
'merchant_identifier' => 'xxxxxxx',
'language' => 'en',
'device_id'=> 'ffffffff-a9fa-0b44-7b27-29e70033c587',
'signature' => '7cad05f0212ed933c9a5d5dffa31661acf2c827a'
};

arrData = arrData.to_json
uri = URI.parse("https://sbpaymentservices.payfort.com/FortAPI/paymentApi")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new("/v1.1/auth")
request.add_field('Content-Type', 'application/json')
request.body = arrData
response = http.request(request)
ATTRIBUTES Description
service_command
Alpha
Mandatory
max: 20
Command.
Possible/ expected values: SDK_TOKEN
Special characters: _
access_code
Alphanumeric
Mandatory
Max: 20
Access code.
Example: zx0IPmPy5jp1vAz8Kpg7
merchant_identifier
Alphanumeric
Mandatory
Max: 20
The ID of the Merchant.
Example: CycHZxVj
language
Alpha
Mandatory
Max: 2
The checkout page and messages language.
Possible/ expected values: en/ ar
device_id
Alphanumeric
Mandatory
Max: 100
A unique device identifier.
Example: ffffffff-a9fa-0b44-7b27-29e70033c587
Special characters: -
signature
Alphanumeric
Mandatory
Max: 200
A string hashed using the Secure Hash Algorithm. Please refer to section Signature
Example: 7cad05f0212ed933c9a5d5dffa31661acf2c827a

NOTE: device_id is a value to be generated from the UUID Class Reference, you can generate this parameter by using the following command: FortSdk.getDeviceId(appContext)

Android Mobile SDK Token Response Parameters

These parameters will be returned in the Amazon Payment Services response:

ATTRIBUTES Description
service_command
Alpha
Max: 20
Command.
Possible/ expected values: SDK_TOKEN
access_code
Alphanumeric
Max: 20
Access code.
Example: zx0IPmPy5jp1vAz8Kpg7
merchant_identifier
Alphanumeric
Max: 20
The ID of the Merchant.
Example: CycHZxVj
language
Alpha
Max: 2
The checkout page and messages language.
Possible/ expected values: en/ ar
device_id
Alphanumeric
Max: 100
A unique device identifier.
Example: ffffffff-a9fa-0b44-7b27-29e70033c587
signature
Alphanumeric
Max: 200
A string hashed using the Secure Hash Algorithm. Please refer to section Signature
Example: 7cad05f0212ed933c9a5d5dffa31661acf2c827a
sdk_token
Alphanumeric
Max: 100
An SDK Token to enable using the Amazon Payment Services Mobile SDK.
Example: dwp78q3
response_message
Alphanumeric
Max: 150
Message description of the response code. It returns according to the request language.
Possible/ expected values: Please refer to section messages
response_code
Numeric
Max: 5
Response Code carries the value of our system's response. *The code consists of five digits, the first 2 digits represent the response status, and the last 3 digits represent the response messages.
Example: 20064
status
Numeric
Max: 2
A two-digit numeric value that indicates the status of the transaction.
Possible/ expected values: Please refer to section statuses

NOTE: Every parameter the merchant sends in the request should be received by the merchant in the response - even the optional parameters.

Processing transactions with the Android SDK

In this section we outline how you process a transaction using the Android mobile SDK. Your first step is to create a mobile SDK token as described above.

Two routes for in-app payment processing

As a merchant you have two ways in which you can process payments using the Amazon Payment Services Android mobile SDK.

  1. Standard payment processing UI

    You can use the standard Amazon Payment Services Android SDK interface to display a standard payment UI screen. This option is customizable in two ways -- you can hide the loading screen, and some of the UI elements can be customized. We address standard UI customization options in this section.

  2. Custom payment processing UI

    Alternatively, you can choose to build your own payment processing UI by custom-coding an in-app payment processing feature. With this mobile SDK feature we allow Amazon Payment Services merchants to integrate and implement a native app checkout experience without displaying a default payment screen.

    Using this integration method your customers can securely enter their payment card details on a fully customized merchant checkout landing page using the your customized payment UI.

    The Amazon Payment Services Android SDK provides key building blocks including payment card input fields and an action pay button that you can encapsulate inside the checkout landing page and to provide your own inline customer experience.

    Amazon Payment Services' SDK card input fields will securely transmit the completed payment card data to Amazon Payment Services APIs for processing and to complete the transaction placement.

    Read more about a customized payment processing UI in this section.

Standard checkout implementation

1: Define a Callback Manager

Define and initialize an instance of the FortCallBackManager in your activity as follows:


private FortCallBackManager fortCallback= null;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (fortCallback == null)
        fortCallback = FortCallback.Factory.create();
}


2: Attach the Callback to the Activity

You need to add the following statement to the onActivityResult function as follows:


@Override protected void onActivityResult(int requestCode, int resultCode, Intent  data){  
super.onActivityResult(requestCode, resultCode,  data); fortCallback.onActivityResult(requestCode,resultCode,data);
}

3: Call the Android Mobile SDK and Collecting the Android SDK request

The below code registers a new callback for a new request. The registerCallBack requires the following inputs:


public void registerCallback(
        Activity context, final FortRequest fortRequest, String
        environment, final int requestCode, final FortCallBackManager callbackManager, boolean   showLoading, final
        FortInterfaces.OnTnxProcessed callback)


Below is a description for each parameter:

Parameter Description
context Passes the currency activity context.
fortRequest An instance of the model mentioned in Collect the Android Mobile SDK Request section.
environment This parameter used to determine whether the request is going to be submitted to the test or production environment. It has two possible values: - ENVIRONMENT.TEST - ENVIRONMENT.PRODUCTION
requestCode A unique ID for this request.
callBackManager The instance defined in section Define a Callback Manager.
showLoading A Boolean flag to show or hide the loading dialog.
callback A transaction callback listener that overrides the following three callback options: - onCancel(): called when the user cancels the payment by clicking the back button. - onSuccess(): called when the transaction is processed successfully. - onFailure(): called when the transaction is failed.

The Java model/ bean of the Android Mobile SDK request is as follows:



public class FortRequest implements Serializable {
    private Map<String, Object> requestMap;
    private boolean showResponsePage;

    public Map<String, Object> getRequestMap() {
        return
                requestMap;
    }

    public void setRequestMap(Map<String, Object> requestMap) {
        this.requestMap = requestMap;
    }

    public boolean isShowResponsePage() {
        return showResponsePage;
    }

    public void setShowResponsePage(boolean showResponsePage) {
        this.showResponsePage = showResponsePage;
    }
}


**NOTE: You can choose to display the Amazon Payment Services response page by passing "showResponsePage" value as "True".**

The “requestMap” must contain all the Amazon Payment Services parameters for the order/ transaction. (Detailed information can be found in our Amazon Payment Services Merchant Integration Guide).

Example:



private Map<String, Object> collectRequestMap(String sdkToken) {
        Map<String, Object> requestMap = new HashMap<>();
        requestMap.put("command", "PURCHASE");
        requestMap.put("customer_email", "[email protected]");
        requestMap.put("currency", "SAR");
        requestMap.put("amount", "100");
        requestMap.put("language", "en");
        requestMap.put("merchant_reference", "merchant_reference ");
   
        requestMap.put("sdk_token", sdkToken);
        return requestMap;
    }


  1. Initiate a checkout request:

For every transaction that needs to be processed, do the following call and handle the callback methods upon your business flow:

Example for register callback:


FortSdk.getInstance().registerCallback(this,fortRequest,5,fortCallback, showLoading,new
    FortInterfaces.OnTnxProcessed() {
    @Override public void onCancel (Map < String, Object > requestParamsMap, Map < String, Object > responseMap)
    {       
    }

    @Override public void onSuccess (Map < String, Object > requestParamsMap, Map < String, Object > fortResponseMap)
    {
    }

    @Override public void onFailure (Map < String, Object > requestParamsMap, Map < String, Object > fortResponseMap)
    {    
    } 
}


Android Mobile SDK Device ID Value

Please make sure to use the following Android SDK function to generate the device_id parameter value that must be used for creating the sdk_token from your business security server:

 
  **String device_id = FortSdk.getDeviceId(this);**
  
ATTRIBUTES Description
command
Alpha
Mandatory
max: 20
Command.
Possible/ expected values: AUTHORIZATION, PURCHASE.
Please refer to this section to know more about the differences.
merchant_reference
Alphanumeric
Mandatory
Max: 40
The Merchant’s unique order number.
Example: XYZ9239-yu898
Special characters: - _ .
amount
Numeric
Mandatory
Max: 10
The transaction's amount. *Each currency has predefined allowed decimal points that should be taken into consideration when sending the amount.
Example: 10000
currency
Alpha
Mandatory
Max: 3
The currency of the transaction’s amount in ISO code 3.
Example: AED
language
Alpha
Mandatory
Max: 2
The checkout page and messages language.
Possible/ expected values: en/ ar
customer_email
Alphanumeric
Mandatory
Max: 254
The customer's email.
Example: [email protected]
Special characters: _ - . @ +
sdk_token
Alphanumeric
Mandatory
Max: 100
An SDK Token to enable using the Amazon Payment Services Mobile SDK.
Example: Dwp78q3
token_name
Alphanumeric
Optional
Max: 100
The Token received from the Tokenization process.
Example: Op9Vmp
Special characters: . @ - _
payment_option
Alpha
Optional
Max: 10
Payment option.
Possible/ expected values:
- MASTERCARD
- VISA
- AMEX
- MADA (for Purchase operations and eci Ecommerce only) Click here to download MADA Branding Document
- MEEZA (for Purchase operations and ECOMMERCE eci only)
eci
Alpha
Optional
Max: 16
Ecommerce indicator.
Possible/ expected values: ECOMMERCE
order_description
Alphanumeric
Optional
Max: 150
A description of the order.
Example: iPhone 6-S
Special characters: ' / . _ - # : $ Space
customer_ip
Alphanumeric
Optional
max: 45
It holds the customer's IP address. *It's Mandatory, if the fraud service is active. *We support IPv4 and IPv6 as shown in the example below.
Example:
IPv4 → 192.178.1.10
IPv6 → 2001:0db8:3042:0002:5a55:caff:fef6:bdbf
Special characters: . :
customer_name
Alpha
Optional
Max: 40
The customer's name.
Example: John Smith
Special characters: _ \ / - . '
phone_number
Alphanumeric
Optional
max: 19
The customer's phone number.
Example: 00962797219966
Special characters: + - ( ) Space
settlement_reference
Alphanumeric
Optional
max: 34
The Merchant submits unique value to Amazon Payment Services. The value is then passed to the Acquiring bank and displayed to the merchant in the Acquirer settlement file.
Example: XYZ9239-yu898
Special characters: - _ .
merchant_extra
Alphanumeric
Optional
Max: 999
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
Special characters: . ; / _ - , ' @
merchant_extra1
Alphanumeric
Optional
Max: 250
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
Special characters: . ; / _ - , ' @
merchant_extra2
Alphanumeric
Optional
Max: 250
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
Special characters: . ; / _ - , ' @
merchant_extra3
Alphanumeric
Optional
Max: 250
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
Special characters: . ; / _ - , ' @
merchant_extra4
Alphanumeric
Optional
Max: 250
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
Special characters: . ; / _ - , ' @
merchant_extra5
Alphanumeric
Optional
Max: 250
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
Special characters: . ; / _ - , ' @
billing_stateProvince
Alphanumeric
Optional
max: 20
The state or province of the address.
Reference: ISO_3166-2
Example1: AMMAN
Example2: TALFILAH
billing_provinceCode
Alphanumeric
Optional
max: 3
The three character ISO 3166-2 country subdivision code for the state or province of the address. Providing this field might improve your payer experience for 3-D Secure payer authentication.
Reference: ISO_3166-2
Example1: AM
Example2: AT
billing_street
Alphanumeric
Optional
max: 100
The first line of the address. For example, this may be the street name and number, or the Post Office Box details.
billing_street2
Alphanumeric
Optional
max: 100
The second line of the address (if provided).
billing_postcode
Alphanumeric
Optional
max: 10
The post code or zip code of the address.
billing_country
Alphanumeric
Optional
min:3, max: 3
The 3 letter ISO standard Alphanumeric country code of the address.
billing_company
Alphanumeric
Optional
max: 100
The name of the company associated with this address.
billing_city
Alphanumeric
Optional
max: 100
The city portion of the address.
shipping_stateProvince
Alphanumeric
Optional
max: 20
The state or province of the address.
shipping_provinceCode
Alphanumeric
Optional
max: 3
The three character ISO 3166-2 country subdivision code for the state or province of the address. Providing this field might improve your payer experience for 3-D Secure payer authentication.
shipping_street
Alphanumeric
Optional
max: 100
The first line of the address. For example, this may be the street name and number, or the Post Office Box details.
shipping_street2
Alphanumeric
Optional
max: 100
The second line of the address (if provided).
shipping_source
Alphanumeric
Optional
How you obtained the shipping address.
Possible/ expected values: NEW_ADDRESS, ADDRESS_ON_FILE
shipping_sameAsBilling
Alphanumeric
Optional
Indicates whether the shipping address provided is the same as the payer's billing address. Provide this value if you are not providing the full shipping and billing addresses, but you can affirm that they are the same or different.
Possible/ expected values: DIFFERENT, SAME, UNKNOWN
shipping_postcode
Alphanumeric
Optional
max: 10
The post code or zip code of the address.
shipping_country
Alphanumeric
Optional
min:3, max: 3
The 3 letter ISO standard Alphanumeric country code of the address.
shipping_company
Alphanumeric
Optional
max: 100
The name of the company associated with this address.
shipping_city
Alphanumeric
Optional
max: 100
The city portion of the address.
agreement_id
Alphanumeric
Optional
max: 100
identifier for the agreement with the payer to process payments to be used in recurring payments
( Required for MADA )
recurring_mode
Alphanumeric
Optional
max: 20
Indicates if the subsequent payments within the agreement has same/different amount or unscheduled (unknown interval/amount).
( Required for MADA )
Possible/ expected values: UNSCHEDULED, VARIABLE, FIXED
recurring_transactions_count
Alphanumeric
Optional
max: 100
The number of merchant-initiated payments within the recurring payment agreement.
( Required for MADA and only if recurring_mode = VARIABLE or FIXED )
recurring_expiry_date
The date where the merchant needs to end the recurring. The format is YY-MM-DD [Numeric] with special character -
recurring_days_between_payments
The number of days between payments agreed with the payer under your agreement with them. The allowed data type is: Numeric only.

[NOTE]: Before sending the transaction value you must multiply the value by a factor that matches the ISO 4217 specification for that currency. Multiplication is necessary to accommodate decimal values. Each currency's 3-digit ISO code will have a specification for the number of digits after the decimal separator.

For example: If the transaction value is 500 AED; according to ISO 4217, you should multiply the value with 100 (to accommodate 2 decimal points). You will therefore send an AED 500 purchase amount as a value of 50000.

Another example: If the amount value was 100 JOD; according to ISO 4217, you should multiply the value with 1000 (to accommodate 3 decimal points). You therefore send a JOD 100 purchase amount as a value of 100000

Response parameters

ATTRIBUTES Description
command
Alpha
Max: 20
Command.
Possible/ expected values: AUTHORIZATION, PURCHASE.
Please refer to this section to know more about the differences.
merchant_reference
Alphanumeric
Max: 40
The Merchant’s unique order number.
Example: XYZ9239-yu898
amount
Numeric
Max: 10
The transaction's amount.*Each currency has predefined allowed decimal points that should be taken into consideration when sending the amount.
Example: 10000
currency
Alpha
Max: 3
The currency of the transaction’s amount in ISO code 3.
Example: AED
customer_email
Alphanumeric
Max: 254
The customer's email.
Example: [email protected]
fort_id
Numeric
Max: 20
The order's unique reference returned by our system.
Example: 149295435400084008
sdk_token
Alphanumeric
Max: 100
An SDK Token to enable using the Amazon Payment Services Mobile SDK.
Example: Dwp78q3
token_name
Alphanumeric
max: 100
The Token received from the Tokenization process.
Example: Op9Vmp
payment_option
Alpha
Max: 10
Payment option.
Possible/ expected values:
- MASTERCARD
- VISA
- AMEX
- MADA (for Purchase operations and eci Ecommerce only) Click here to download MADA Branding Document
- MEEZA (for Purchase operations and ECOMMERCE eci only)
eci
Alpha
Max: 16
The E-commerce indicator.
Possible/ expected values: ECOMMERCE
authorization_code
Alphanumeric
Max: 100
The authorization code returned from the 3rd party.
Example: P1000000000000372136
order_description
Alphanumeric
Max: 150
It holds the description of the order.
Example: iPhone 6-S
response_message
Alphanumeric
Max: 150
The message description of the response code; it returns according to the request language.
Possible/ expected values: Please refer to section messages
response_code
Numeric
Max: 5
Response Code carries the value of our system's response. *The code consists of five digits, the first 2 digits represent the response status, and the last 3 digits represent the response messages.
Example: 20064
customer_ip
Alphanumeric
max: 45
It holds the customer's IP address. *We support IPv4 and IPv6 as shown in the example below.
Example:
IPv4 → 192.178.1.10
IPv6 → 2001:0db8:3042:0002:5a55:caff:fef6:bdbf
customer_name
Alpha
Max: 40
The customer's name.
Example: John Smith
expiry_date
Numeric
Max: 4
The card's expiry date.
Example: 2105
card_number
Numeric
Max: 16
The masked credit card's number. Only the MEEZA payment option takes 19 digits card number.
AMEX payment option takes 15 digits card number.
Otherwise, they take 16 digits card number.
Example: 400555
***0001
status
Numeric
Max: 2
A two-digit numeric value that indicates the status of the transaction.
Possible/ expected values: Please refer to section statuses
phone_number
Alphanumeric
max: 19
The customer's phone number.
Example: 00962797219966
settlement_reference
Alphanumeric
max: 34
The Merchant submits unique value to Amazon Payment Services. The value is then passed to the Acquiring bank and displayed to the merchant in the Acquirer settlement file.
Example: XYZ9239-yu898
merchant_extra
Alphanumeric
Max: 999
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
merchant_extra1
Alphanumeric
Max: 250
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
merchant_extra2
Alphanumeric
Max: 250
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
merchant_extra3
Alphanumeric
Max: 250
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
merchant_extra4
Alphanumeric
Max: 250
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
merchant_extra5
Alphanumeric
Max: 250
Extra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.
Example: JohnSmith
billing_stateProvince
Alphanumeric
max: 20
The state or province of the address.
Reference: ISO_3166-2
Example1: AMMAN
Example2: TALFILAH
billing_provinceCode
Alphanumeric
max: 3
The three character ISO 3166-2 country subdivision code for the state or province of the address. Providing this field might improve your payer experience for 3-D Secure payer authentication.
Reference: ISO_3166-2
Example1: AM
Example2: AT
billing_street
Alphanumeric
max: 100
The first line of the address. For example, this may be the street name and number, or the Post Office Box details.
billing_street2
Alphanumeric
max: 100
The second line of the address (if provided).
billing_postcode
Alphanumeric
max: 10
The post code or zip code of the address.
billing_country
Alphanumeric
min:3, max: 3
The 3 letter ISO standard Alphanumeric country code of the address.
billing_company
Alphanumeric
max: 100
The name of the company associated with this address.
billing_city
Alphanumeric
max: 100
The city portion of the address.
shipping_stateProvince
Alphanumeric
max: 20
The state or province of the address.
shipping_provinceCode
Alphanumeric
max: 3
The three character ISO 3166-2 country subdivision code for the state or province of the address. Providing this field might improve your payer experience for 3-D Secure payer authentication.
shipping_street
Alphanumeric
max: 100
The first line of the address. For example, this may be the street name and number, or the Post Office Box details.
shipping_street2
Alphanumeric
max: 100
The second line of the address (if provided).
shipping_source
Alphanumeric
How you obtained the shipping address.
Possible/ expected values: NEW_ADDRESS, ADDRESS_ON_FILE
shipping_sameAsBilling
Alphanumeric
Indicates whether the shipping address provided is the same as the payer's billing address. Provide this value if you are not providing the full shipping and billing addresses, but you can affirm that they are the same or different.
Possible/ expected values: DIFFERENT, SAME, UNKNOWN
shipping_postcode
Alphanumeric
max: 10
The post code or zip code of the address.
shipping_country
Alphanumeric
min:3, max: 3
The 3 letter ISO standard Alphanumeric country code of the address.
shipping_company
Alphanumeric
max: 100
The name of the company associated with this address.
shipping_city
Alphanumeric
max: 100
The city portion of the address.
agreement_id
Alphanumeric
max: 100
identifier for the agreement with the payer to process payments to be used in recurring payments

Standard checkout UI sample code

Below we include a complete sample code section illustrating the full checkout process when you use the standard checkout UI. The sample includes capturing payment card data, initializing the Amazon Payment Services Android SDK, submitting payment card data and processing a transaction.




public class PayFortSdkSample extends Activity {
    private FortCallBackManager fortCallback = null;
    String deviceId = "", sdkToken = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

     // create Fort callback instance
        fortCallback = FortCallback.Factory.create();

        // Generating deviceId
        deviceId = FortSdk.getDeviceId(PayFortSdkSample.this);
        Log.d("DeviceId ", deviceId);

        // prepare payment request
        FortRequest fortrequest = new FortRequest();
        fortrequest.setRequestMap(collectRequestMap("PASS_THE_GENERATED_SDK_TOKEN_HERE"));
        fortrequest.setShowResponsePage(true); // to [display/use] the SDK response page
        // execute payment request callSdk(fortrequest);
    }

    private Map<String, Object> collectRequestMap(String sdkToken) {
        Map<String, Object> requestMap = new HashMap<>();
        requestMap.put("command", "PURCHASE");
        requestMap.put("customer_email", "[email protected]");
        requestMap.put("currency", "SAR");
        requestMap.put("amount", "100");
        requestMap.put("language", "en");
        requestMap.put("merchant_reference", "ORD-0000007682");
        requestMap.put("customer_name", "Sam");
        requestMap.put("customer_ip", "172.150.16.10");
        requestMap.put("payment_option", "VISA");
        requestMap.put("eci", "ECOMMERCE");
        requestMap.put("order_description", "DESCRIPTION");
        requestMap.put("sdk_token", sdkToken);
        return requestMap;
    }

    private void callSdk(FortRequest fortrequest) {

        FortSdk.getInstance().registerCallback(PayFortSdkSample.this, fortrequest,
                FortSdk.ENVIRONMENT.TEST, 5, fortCallback, new FortInterfaces.OnTnxProcessed() {
                    @Override
                    public void onCancel(Map<String, Object> requestParamsMap, Map<String, Object> responseMap) {
                        Log.d("Cancelled ", responseMap.toString());
                    }
                    @Override
                    public void onSuccess(Map<String, String> requestParamsMap, Map<String, Object> fortResponseMap) {    //TODO: handle me
                        Log.i("Success ", fortResponseMap.toString());
                    }
                    @Override
                    public void onFailure(Map<String, String> requestParamsMap,
                                          Map<String, Object> fortResponseMap) {
                        Log.e("Failure ", fortResponseMap.toString());
                    }

                });


    }


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        fortCallback.onActivityResult(requestCode, resultCode, data);
    }

}

Customizing the payment UI

You can customize the payment UI presented by our Android SDK in a number of ways to better reflect your business. This is when you use the standard UI.

Customizing the Android Mobile SDK Payment Layout

We provide you with the res folder that includes the source code of the pages in order to customize the design, themes, etc. You can customize both English and Arabic layouts as needed. However, please take the following tips into consideration:

  • Don't change the layout name because it is considered an override process.

  • Make sure to use all the views that has the ID property in order to avoid the NullPointerException.

  • Redesign the view for portrait orientation. Note that Landscape orientation isn't supported.

  • You can support as much layout densities as you want.

Our Mobile SDK v 1.9 consists one of the following three main activities design:

  • activity_cc_payment.xml

  • activity_cc_response.xml

  • activity_init_secure_conn

Figure : Standard vs. Customized Mobile SDK Payment Page Design

Design Customization Codes:

The following code was used to customize the way the Amount is displayed in the Standard Mobile SDK Payment Page:


 < TextView
    android:id="@+id/amountTV"
    android:layout_width="match_parent"
    android:layout_height=”38dp"
    android:background="@color/pf_light_gray"
    android:gravity="center_horizontal|center_vertical"
    android:textColor="@color/colorBlack"
    android:textSize="@dimen/_13ssp"    app:layout_constraintTop_toBottomOf="@+id/appbarLayout />

The following code was used to customize the way the Amount is displayed in the Customized Mobile SDK Payment Page:



< LinearLayout
    android:id="@+id/amountContainer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/pf_light_gray"
    android:gravity="center"
    app:layout_constraintTop_toBottomOf="@+id/appbarLayout">


    < ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="10dp"
        android:src="@drawable/merchant"
        android:layout_marginRight="10dp" />

    < TextView
        android:id="@+id/amountTV"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/_38sdp"
        android:gravity="center_horizontal|center_vertical"
        android:textColor="@color/colorBlack"
        android:textSize="@dimen/_13ssp"
        tools:text="10.00 USD" />
< / LinearLayout > 

As appears in the previous codes, elements with IDs haven't been changed in type or removed. For example: android:id="@+id/amountTV".

We were able to add static elements such as: "ImageView" element that contains the Merchant's logo.

To sum up, you can add any static elements or redesign the view, while keeping the views' elements used in the Standard layout that hold IDs.

[NOTE] The customized XML file should be added to the layout file in the target project (Merchant Application) to override the SDK file.

Custom-coding a payment processing UI

In this section we outline key information that you need to create your own payment processing UI using the tools in our Android SDK.

Stage 1: Generate an SDK token

You need to generate an SDK token before you can start processing payments using your custom payment processing UI. Refer to the SDK token section earlier in this document for instructions on creating an SDK token.

Stage 2: Creating the card components

You create your custom payment screen by using the following five components included in the Amazon Payment Services Android SDK:

Table of components

The Android Mobile SDK allows merchants to securely integrate the payment functions through Custom Components:

  • FortCardNumberView (Check CardBrand,CardNumber)

  • CardCvvView (Check if cvv match cardBrand)

  • CardExpiryView (Check date)

  • CardHolderNameView

  • PayfortPayButton (Collect data from previous Components)

Attributes Type Description
app:boxBackgroundShape Enum
1- none 2- filled 3- outlione
Whether the text input area should be drawn as a filled box, an outline box, or not as a box.
app:hintTextColor Reference or color Ex : #fff123 Color of the hint text.
app:hintText String Hint text to display when the text is empty.
app:textSize Dimension Ex : 12sp Size of the text. Recommended dimension type for text is "sp"
app:textColor Reference or color Ex : #fff123 text Color of the text displayed in the text input area
app:boxStrokeErrorColor Color Ex : #fff123 The color to use for the box's stroke in outline box mode when an error is being displayed. If not set, it defaults to errorTextColor if on error state
app:errorTextColor Color Ex : #fff123 Text color for any error message displayed. If set, this takes precedence over errorTextAppearance.
app:errorTextAppearance Reference Ex: @style/customStyle TextAppearance of any error message displayed.
app:boxBackgroundColor Color Ex : #fff123 The color to use for the box's background color when in filled box mode.If a non-stateful color resource is specified, default colors will be used for the hover and disabled states.

XML Usage

Card components



<!--CardNumber-->
   < com.payfort.fortpaymentsdk.views.FortCardNumberView
                android:id="@+id/etCardNumberView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:boxBackgroundShape="outline"
                />
 
   <!--CardExpiryView-->
    < com.payfort.fortpaymentsdk.views.CardExpiryView
                    android:id="@+id/etCardExpiry"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:boxBackgroundShape="outline" />
 
              <!--CardCvvView-->
                < com.payfort.fortpaymentsdk.views.CardCvvView
                    android:id="@+id/etCardCvv"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:boxBackgroundShape="outline" />
 
        <!--CardHolderNameView-->
       < com.payfort.fortpaymentsdk.views.CardHolderNameView
                android:id="@+id/cardHolderNameView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:boxBackgroundShape="outline" />


Stage 3: Initiate the actual payment.

PayfortPayButton

Responsible for collecting card data from Card Components above and Submit Successful payment with simple Few steps also it's had the capability to do Direct Pay without needs for Card Components



<!--PayfortPayButton-->
    < com.payfort.fortpaymentsdk.views.PayfortPayButton
        android:id="@+id/btntPay"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />


PayfortPayButton Methods


/**
 * Responsible for Save token or not
 * @param isRememberMe Boolean
 */
fun isRememberMeEnabled(isRememberMe: Boolean)

/**
 * Update Request After doing Setup
 * @param fortRequest FortRequest
 */
fun updateRequest(fortRequest: FortRequest)


/**
 * this Setup used with Pay with Full Components from outside SDK
 * @param environment String
 * @param request FortRequest
 * @param payComponents PayComponents
 * @param payFortCallback PayFortCallback
 */
fun setup(environment: String,
          request: FortRequest,
          payComponents: PayComponents,
          payFortCallback: PayFortCallback)

/**
 * this Setup used with DirectPay only
 * @param environment String
 * @param request FortRequest
 * @param payFortCallback PayFortCallback?
 */
fun setup(environment: String,
          request: FortRequest,
          payFortCallback: PayFortCallback?)


Sample Code

In this example we explain how to use PayfortPayButton with Card Components in the custom UI screen.

Kotlin


//You Need to Create PayComponents Object that holds all Card Components
val payComponents = PayComponents(etCardNumberView, cvvView = etCardCvv, etCardExpiry, holderNameView = cardHolderNameView)

//then you need to Create FortRequest via FortRequest.class
val fortRequest= FortRequest() // fill all the parameters required 

//then you need to choose the environment Via FortSdk.ENVIRONMENT it's contains TEST and PRODUCTION ENVIRONMENTS 
val  environment=  FortSdk.ENVIRONMENT.TEST

// Finally you need to decleare a PayFortCallback 
var callback=  object : PayFortCallback {
    override fun startLoading() {   }
    override fun onSuccess(requestParamsMap: Map<String, Any>, fortResponseMap: Map<String, Any>) {}
    override fun onFailure(requestParamsMap: Map<String, Any>, fortResponseMap: Map<String, Any>) { }
}

btnPay.setup(environment, fortRequest, payComponents, callback)

Java



//You Need to Create PayComponents Object that holds all Card Components
PayComponents payComponents = new PayComponents(etCardNumberView,  etCardCvv, etCardExpiry,  cardHolderNameView);

//then you need to Create FortRequest via FortRequest.class
FortRequest fortRequest = new FortRequest(); // fill all the parameters required 

//then you need to chsose the environment Via FortSdk.ENVIRONMENT it's contains   TEST and PRODUCTION ENVIRONMENTS
String environment = FortSdk.ENVIRONMENT.TEST;

// Finally you need to decleare a PayFortCallback 
PayFortCallback callback = new PayFortCallback() {
    @Override
    public void startLoading() { }
    @Override
    public void onSuccess(@NotNull Map<String, ?> requestParamsMap, @NotNull Map<String, ?> fortResponseMap) { }
    @Override
    public void onFailure(@NotNull Map<String, ?> requestParamsMap, @NotNull Map<String, ?> fortResponseMap) { }
};

    btnPay.setup(environment, fortRequest, payComponents, callback)


Using Direct Pay

The Direct Pay feature enables Amazon Payment Services merchants to securely process e-commerce transactions using tokenized payment card details.

For customers that already supplied their payment card details in a previous transaction and where a card token was generated, customers need to just provide the card security code to complete their purchase.

The card token and provided card security code can be sent to the Amazon Payment Services Android mobile SDK to complete the customer purchase through Direct Pay operation to complete the order placement using eCommerce channel.

Note you can use Direct Pay both with the standard payment UI or with a customized payment UI.

Direct Pay sample code

In this example we demonstrate how to use PayfortPayButton with DirectPay. This Method is required to pass card_security_code and token_name to FortRequest.

Kotlin



private fun collectRequestMap(sdkToken: String): FortRequest {
    val fortRequest = FortRequest()
    val requestMap: MutableMap<String, Any> = HashMap()
    requestMap["command"] = "AUTHORIZATION"
    requestMap["customer_email"] = "[email protected]"
    requestMap["currency"] = "AED"
    requestMap["amount"] = "100"
    requestMap["language"] = "en"
    requestMap["card_security_code"] = "123"
    requestMap["token_name"] = "payfort"
    requestMap["merchant_reference"] = "merchant_reference"
    requestMap["sdk_token"] = sdkToken
    fortRequest.requestMap = requestMap
    fortRequest.isShowResponsePage = false
    return fortRequest
}
//you need to Create FortRequest via FortRequest.class
val fortRequest=collectRequestMap("SDK_TOKEN")

//then you need to chsose the environment Via FortSdk.ENVIRONMENT it's contains TEST and PRODUCTION ENVIRONMENTS
val  environment=  FortSdk.ENVIRONMENT.TEST

// Finally you need to decleare a PayFortCallback
var callback=  object : PayFortCallback {
    override fun startLoading() {   }
    override fun onSuccess(requestParamsMap: Map<String, Any>, fortResponseMap: Map<String, Any>) {}
    override fun onFailure(requestParamsMap: Map<String, Any>, fortResponseMap: Map<String, Any>) { }
}

btnPay.setup(environment, fortRequest, callback)


</br>

Java



private FortRequest collectRequestMap(String sdkToken) {
    FortRequest fortRequest= new FortRequest();
    Map<String, Object> requestMap = new HashMap<>();
    requestMap.put("command", "AUTHORIZATION");
    requestMap.put("customer_email", "[email protected]");
    requestMap.put("currency", "AED");
    requestMap.put("amount", "100");
    requestMap.put("language", "en");
    requestMap.put("card_security_code", "123");
    requestMap.put("token_name", "payfort");
    requestMap.put("merchant_reference", "merchant_reference");
    requestMap.put("sdk_token", sdkToken);
    fortRequest.setRequestMap(requestMap);
    fortRequest.setShowResponsePage(false);
    return fortRequest;
}

//you need to Create FortRequest via FortRequest.class
FortRequest fortRequest = collectRequestMap(“SDK_TOKEN”);


//then you need to chsose the environment Via FortSdk.ENVIRONMENT it's contains TEST and PRODUCTION ENVIRONMENTS
String environment = FortSdk.ENVIRONMENT.TEST;

// Finally you need to decleare a PayFortCallback 
PayFortCallback callback = new PayFortCallback() {
    @Override
    public void startLoading() {}

    @Override
    public void onSuccess(@NotNull Map<String, ?> requestParamsMap, @NotNull Map<String, ?> fortResponseMap) {}


    @Override
    public void onFailure(@NotNull Map<String, ?> requestParamsMap, @NotNull   Map<String, ?> fortResponseMap) {}
};

    btnPay.setup(environment, fortRequest, callback);

Amazon Payment Services Android SDK transaction feedback

While a transaction is completed, we will send a response directly to your direct transaction feedback URL. In theory, direct response feedback cannot be interrupted unless the URL you provided for responses is not functional at the time of the response.

We do this so that your server receives a response even if your customer does not successfully redirect to the return URL on your website, which may happen if your customer's browser or connection fails during the transaction.

Receiving transaction feedback

There are two ways in which you receive transaction feedback:

Direct transaction feedback. Amazon Payment Services sends an immediate payment processing response whenever a transaction is completed.

You can rely on this response for transaction feedback even where your user closed the browser before getting redirected successfully to the redirection URL or where your user was not redirected due to a drop in the internet connection.

Notification feedback. Were we need to provide you with the status of a transaction once it is received. In other words, we send notification feedback to alert you to any changes in the status of a transaction.

For example, if the transaction was pending due to the unavailability of any party to the transaction, the final update will be pushed to your notification feedback endpoint.

Notification feedback deals with a wide range of scenarios and it is critical that your website is configured to receive notification feedback correctly. For example, transaction feedback can alert you to any transactions that were stuck in "uncertain" status, but which have recovered to final status.

Direct feedback allows you to subscribe to transaction updates for uncertain transactions whenever you process a payment. It is a method for receiving the transaction response automatically once the transaction had completed or if there was an update.

Registering Transaction Feedback URLs

To receive transaction feedback, you must register with Amazon Payment Services the transaction feedback URLs you set up on your server. Follow these steps:

  1. Log in to your back-office account.

  2. Select the active channel under Integration Settings > Technical Settings.

  3. Enter your Direct Transaction Feedback URL and Notification Transaction Feedback URL.

  4. Click "Save Changes" button.

Transaction Feedback Implementation

We will send the response via HTTP POST request in POST form format to your webhook URL. The submission type can be changed from POST form to JSON or XML in your APS account settings. We only permit configuring URLs in HTTPS for direct feedback and for notification feedback.

To acknowledge receiving the direct feedback and notification successfully, the webhook URL must return a 2xx or 302 HTTP status. In case the URL returns different HTTP responses, our server will keep retrying up to 10 times until we receive a success response. We wait ten seconds between retries.

You can change and configure the retry mechanism attributes to increase or decrease the number of retries, time between retries and the grace period before we send the notifications.

You must create endpoints that accept direct transaction feedback and notification feedback from us via a webhook. You can customize how transaction feedback works -- for example, by including the grace period before a direct feedback notification is sent, and the time elapsed between retrying feedback submission.

To customize transaction feedback, email [email protected]. You can request to change the submission type to JSON or XML. You can also change the grace period or the time interval between the retries please contact us on [email protected]

[NOTE] You can check the direct and notification feedback logs in your back office account to check the details related to the submission like the Transaction Feedback URL which was triggered, The response which our system pushed, the response Code and Status retuned from your Transaction Feedback URL.

[NOTE] The specifics of the data will differ based upon the financial operation that has been processed. Your code must be able to accommodate different data.

Validate API call

Amazon Payment Services offers an API to request validation of the payment card details without performing an actual transaction.

Validate API can help you to initiate an API request in order to validate the input parameters values, this will reduce the possibility of encountered API errors due to wrong user inputs before processing the actual payment card transaction.

Fort SDK has a new method (validate) in FortSdk.class This method can validate FortRequest to check all parameters for validity.



/**
 * Responsible for Validating FortRequest
 * @param context Context
 * @param environment String
 * @param fortRequest FortRequest
 * @param fortCallback PayFortCallback
 */
fun validate(context: Context,
             environment: String
             ,fortRequest: FortRequest,
             fortCallback: PayFortCallback)


Example:

Java




// you need to Create FortRequest via FortRequest.class
FortRequest fortRequest = new FortRequest(); // fill all the parameters required
//then you need to chsose the environment Via FortSdk.ENVIRONMENT
//it's contains TEST and PRODUCTION ENVIRONMENTS
String environment = FortSdk.ENVIRONMENT.TEST;
// Finally you need to decleare a PayFortCallback
PayFortCallback callback = new PayFortCallback() {
    @Override
    public void startLoading() { }
    @Override
    public void onSuccess(@NotNull Map<String, ?> requestParamsMap, @NotNull Map<String, ?> fortResponseMap) { }
    @Override
    public void onFailure(@NotNull Map<String, ?> requestParamsMap, @NotNull Map<String, ?> fortResponseMap) { }
};

FortSdk fortSdk = FortSdk.getInstance();
    fortSdk.validate(this,environment,fortRequest,callback);

Kotlin



// you need to Create FortRequest via FortRequest.class
val fortRequest = FortRequest() // fill all the parameters required
//then you need to chsose the environment Via FortSdk.ENVIRONMENT it's contains TEST and PRODUCTION ENVIRONMENTS
val environment = FortSdk.ENVIRONMENT.TEST
// Finally you need to decleare a PayFortCallback
val callback: PayFortCallback = object : PayFortCallback {
    override fun startLoading() {}
    override fun onSuccess(requestParamsMap: Map<String, Any>, fortResponseMap: Map<String, Any>) {}

    override fun onFailure(requestParamsMap: Map<String, Any>, fortResponseMap: Map<String, Any>) {}
}

val fortSdk = FortSdk.getInstance()
fortSdk.validate(this, environment, fortRequest, callback)


[NOTE] When you make use of the Validate API call you still need to generate a mobile SDK token even though you are not processing a transaction.

Migrating the previous version

In this section we outline the steps you need to take to migrate the Amazon Payment Services Android SDK to the latest release. To complete the migration, follow these steps:

  1. Remove old SDK from Libs Folder

  2. Remove old dependencies from Gradle file that related to old SDK


dependencies {
    implementation  fileTree(include: ['*.jar'], dir: 'libs')
    api project(path: ':FORTSDKv1.6')
    api 'com.android.support:design:29+'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    api 'com.victor:lib:1.0.1'
    api 'com.google.code.gson:gson:2.8.0'
    api 'com.shamanland:fonticon:0.1.8'
    api('com.nispok:snackbar:2.11.+') {
        // exclusion is not necessary, but generally a good idea.
        exclude group: 'com.google.android', module: 'support-v4'
    }
    api 'com.google.guava:guava:19.0'
    api 'org.bouncycastle:bcprov-jdk16:1.46'
}

3: Check the installation steps in section 3

4: Make sure to sync new SDK in your Gradle File


  **File \> Sync Project with Gradle Files**
  

5: For merchants that already use custom layout feature, they need to replace their custom layout xml files that related to previous SDK versions (< 2.0) and override it with new one.

Note: if you override Arabic xml files you need to delete it since new SDK support it without the need to override it.

Below the difference between old SDK layout and new one:

XML Files old SDK new SDK
activity_cc_payment Download Download
activity_cc_response Download Download
activity_init_secure_conn Download Download

6: Change old imports to new imports

Old imports


import com.payfort.fort.android.sdk.base.FortSdk;
import com.payfort.sdk.android.dependancies.commons.Constants.FORT_PARAMS;
import com.payfort.fort.android.sdk.base.FortSdk;
import com.payfort.fort.android.sdk.base.callbacks.FortCallBackManager;
import com.payfort.fort.android.sdk.base.callbacks.FortCallback;
import com.payfort.sdk.android.dependancies.base.FortInterfaces;
import com.payfort.sdk.android.dependancies.models.FortRequest;


New imports


import com.payfort.fortpaymentsdk.constants.Constants.FORT_PARAMS;
import com.payfort.fortpaymentsdk.FortSdk;
import com.payfort.fortpaymentsdk.callbacks.FortCallBackManager;
import com.payfort.fortpaymentsdk.callbacks.FortCallback;
import com.payfort.fortpaymentsdk.callbacks.FortInterfaces;
import com.payfort.fortpaymentsdk.domain.model.FortRequest;
  

7: Make Sure to enable ViewBinding in your project

To enable view binding in a module, set the viewBinding build option to true in the module-level build.gradle file, as shown in the following example:


android {
    ...
    buildFeatures {
        viewBinding true  
   }
}


8: Make Sure to use Java 8

To start using supported Java 8 language features, update the Android plugin to 3.0.0 (or higher). After that, for each module that uses Java 8 language features (either in its source code or through dependencies), update the module's build.gradle file, as shown below:


android {
    ...
    // Configure only for each module that uses Java 8
    // language features (either in its source code or
    // through dependencies).
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
                targetCompatibility JavaVersion.VERSION_1_8
    }
    // For Kotlin projects
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
 </div>

Appendix: About the Software

About this software

The Amazon Payment Services Android mobile SDK allows merchants to securely integrate payment functionality into a native Android app. It allows merchants to easily accept in-app payments.

Instead of the traditional, time-consuming, and complex way of being redirected to the mobile browser to complete the payment, in-app payments can easily be offered thanks to the Android Mobile SDK. In turn, this gives the merchants' customers a smooth, pleasing user experience thanks to in-app payment functions through the native applications. (move to about this software)

Supported Platforms

The Amazon Payment Services Android SDK supports devices running Android 4.1.x and later (API level 16). In other words, Android Ice Cream Sandwich or higher is supported. This release supports Android Pie API 28.

Localization

You can use both English and Arabic when you implement the Android SDK.

Screen Orientation

Currently, portrait is the only orientation supported within the Amazon Payment Services mobile SDK -- unless you build a customized payment integration.

Supported Payment Methods

Using the Android SDK the merchant can process debit or credit card transactions only.

Supported Payment Options

The supported credit card payment options are VISA, MASTERCARD, American Express (AMEX), MADA and MEEZA.