Initiating a Payment for Mobile Android Payments

For this payment request, the user enters card data directly on the mobile device. Use this payment request type when the following holds:

  • Paysafe does not support Android Pay in the country in which you are operating; and
  • Your consumer does not have any cards on file with Google.

The method below will call the single-use token service within the Customer Vault API, using credit card and billing address details. This API will return a single-use token. Single-use tokens are valid for only 15 minutes and are not consumed by verification.

The request to the Customer Vault API requires the use of the API key for single-use tokens.

Once a single-use token is received from the Customer Vault API, it must be sent to the merchant's server. The merchant must then include it in the payment request that is sent to the Card Payments API (using the API key for server-to-server API calls).

import com.paysafe.PaysafeApiClient;
import com.paysafe.Environment;
import com.paysafe.customervault.SingleUseToken;

PaysafeApiClient client = new PaysafeApiClient(apiKey, apiPassword, Environment.TEST, accountNumber);

try {
      SingleUseToken sObjResponse = client.customerVaultService().createSingleUseToken(
              SingleUseToken.builder()
                 .card()
                   .holderName("Mr. John Smith")
                   .cardNum("4917480000000008")
                   .cardExpiry()
                     .month(7)
                     .year(2019)
                     .done()
                   .billingAddress()
                     .street("100 Queen Street West")
                     .street2("Unit 201")
                     .city("Toronto")
                     .country("CA")
                     .state("ON")
                     .zip("M5H 2N2")
                     .done()
                  .done()
                 .build());

      return sObjResponse;

} catch (IOException e) {
   e.printStackTrace();
} catch (PaysafeException e) {
   e.printStackTrace();
} catch (Exception e) {
   e.printStackTrace();
}
Did you find this page useful?