PayOrc
SDKs

SDK - Add Card

Tokenize customer cards using the PayOrc Flutter SDK for secure storage and future payments.

SDK - Add Card

Generate an API Key for SDKs channel: Navigate to Developers → API Keys → Add new API key → Select SDK/Plugins in the Channel Dropdown.

1. Overview

This document provides guidance on how to tokenize a customer's card using the PayOrc Flutter SDK and securely use the generated token for future transactions.

2. Flow Summary

  1. Customer enters card details within the mobile application
  2. A successful request generates a secure card token
  3. Merchant stores the token securely on their backend
  4. SDK uses the stored token to process future payments

3. SDK Initialization

Initialize the SDK at application startup using your merchant credentials.

PayorcSdk.init(
  merchantKey: merchantKey,
  merchantSecret: merchantSecret,
  environment: PayorcEnvironment.sandbox,
  language: PayorcLanguage.english,
);

Always switch to PayorcEnvironment.production in live environments.

4. Card Tokenization (Add Card)

Use the addCard method to securely tokenize customer card details.

PayOrc.addNewCard(
  context,
  paymentRequest: _p.addCardPaymentRequest,
  initialCard: card,
  onAddCard: _handleAddCardSheetResult,
);

The _p.addCardPaymentRequest object includes all required transaction parameters. Billing and shipping details collected during card tokenization are reused for future transactions using the m_payment_token, eliminating the need to resend them.

PaymentRequest.addCard Parameters

FieldTypeDescription
orderDetailsArrayList of order details associated with the transaction.
mOrderId (optional)StringUnique order identifier generated by the merchant.
currencyStringTransaction currency in ISO format (e.g., USD, AED).
description (optional)StringDescription of the order (e.g., Event Ticket Purchase).
customerDetailsObjectContains customer-related information.
  mCustomerIdStringUnique identifier for the customer.
  nameStringFull name of the customer.
  emailStringEmail address of the customer.
  mobileStringCustomer mobile number.
  codeStringCountry dialing code (e.g., 971 for UAE).
billingDetailsObjectBilling address details of the customer.
  addressLine1StringPrimary billing address line.
  addressLine2 (optional)StringSecondary billing address line.
  city (optional)StringCity of the billing address.
  province (optional)StringState or province of the billing address.
  countryStringCountry code in ISO format (e.g., AE).
  pin (optional)StringPostal/ZIP code of the billing address.
shippingDetails (optional)ObjectShipping address and delivery-related information.
  shippingName (optional)StringName of the recipient for shipping.
  shippingEmail (optional)StringEmail address of the recipient.
  shippingCode (optional)StringCountry dialing code for shipping contact.
  shippingMobile (optional)StringMobile number of the recipient.
  addressLine1 (optional)StringPrimary shipping address line.
  addressLine2 (optional)StringSecondary shipping address line.
  city (optional)StringCity of the shipping address.
  province (optional)StringState or province of the shipping address.
  country (optional)StringCountry code in ISO format.
  pin (optional)StringPostal/ZIP code of the shipping address.
  locationPin (optional)StringGoogle Maps location URL for delivery reference.

CardData Structure

initialCard = CardData(
  this.cardNumber,
  required this.cardholderName,
  required this.expiryMonth,
  required this.expiryYear,
  required this.cvv,
);

5. Response Format

Use the payment_method_data.m_payment_token to securely tokenize customer card details. This token can be stored on your backend and used for future transactions without needing to handle sensitive card information again.

{
    "status": "success",
    "code": "CARD_VERIFIED",
    "message": "Your card has been successfully verified.",
    "payment_method_data": {
        "m_payment_token": "WVNnWlBoVEZRsOWhIZndPUT09",
        "scheme": "VISA",
        "card_country": "POLAND",
        "card_type": "DEBIT",
        "mask_card_number": "4111****1111"
    }
}
void _handleAddCardSheetResult(BuildContext sheetContext, CardData card) {
  ///  TODO: save card in List
}

Response Parameters

FieldTypeDescription
statusStringIndicates the overall status of the request (e.g., success, failed).
codeStringResponse code representing the result of the operation (e.g., CARD_VERIFIED).
messageStringHuman-readable message describing the result of the operation.
payment_method_dataObjectContains tokenized card and related metadata.
  m_payment_tokenStringUnique token generated for the card. This should be stored securely and used for future transactions.
  schemeStringCard network/brand (e.g., VISA, MASTERCARD, AMEX).
  card_countryStringCountry where the card was issued.
  card_typeStringType of card (e.g., CREDIT, DEBIT).
  mask_card_numberStringMasked card number showing only first 4 and last 4 digits.

6. Error Handling

Error CodeDescription
INVALID_CARDCard number validation failed
CARD_EXPIREDCard has expired
INVALID_CVVCVV validation failed
NETWORK_ERRORNetwork connectivity issue
SDK_NOT_INITIALIZEDSDK has not been initialized

7. Best Practices

  • Never store raw card numbers — Always use the token returned by the SDK.
  • Store tokens securely — Use encrypted storage (Keychain on iOS, EncryptedSharedPreferences on Android).
  • Validate inputs — Check card number, expiry, and CVV before submission.
  • Handle errors gracefully — Show appropriate messages for different error types.

On this page