Skip to main content

Documentation

Customer

Customer profile, where payment methods are stored for future use.

Details of the payment method are stored securely in Rapyd's vault, including sensitive personal identifying information (PII) that is subject to regulation by law or payment card industry (PCI) rules. When the payment method is required for an operation, the client uses a token and not the PII.

Creating a Customer Profile

Save the customer’s payment methods for future use.

This procedure describes how to create a customer profile. The customer profile stores the customer's address and payment methods. Sensitive personal data is stored in Rapyd's vault, and the customer profile holds payment method tokens that allow the client to use those payment methods without access to the personal data.

You can create a customer and then later add a payment method, or you can do both together in a single operation. This procedure describes creating a customer with a payment method.

This procedure is made up of the following steps:

  1. Determine the requirements of the payment method.

  2. Create a Customer object with the required information.

Step 1. Get Payment Method Required Fields

Determines the fields required for a particular payment method.

  1. List Payment Methods by Country - Returns all available payment methods for the indicated country. In production, it returns only the payment methods that the client is authorized to use by the terms of the Rapyd contract.

  2. Run Get Payment Method Required Fields. For this example, we will use the sg_credit_cup_card payment method.

    Get Payment Method Required Fields - Response

    {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "b463d69d-d625-4649-8541-684bcb6ede64"
        },
        "data": {
            "type": "sg_credit_cup_card",
            "fields": [
                {
                    "name": "name",
                    "type": "string",
                    "regex": "",
                    "is_required": true,
                    "instructions": "card holder name"
                },
                {
                    "name": "number",
                    "type": "string",
                    "regex": "",
                    "is_required": true,
                    "instructions": "card number"
                },
                {
                    "name": "expiration_month",
                    "type": "string",
                    "regex": "",
                    "is_required": true,
                    "instructions": "expiration month as string, 01-12"
                },
                {
                    "name": "expiration_year",
                    "type": "string",
                    "regex": "",
                    "is_required": true,
                    "instructions": "expiration year in to digits as string, 18-99"
                },
                {
                    "name": "cvv",
                    "type": "string",
                    "regex": "",
                    "is_required": true,
                    "instructions": "card cvv"
                }
            ],
            "payment_method_options": [
                {
                    "name": "3d_required",
                    "type": "boolean",
                    "regex": "",
                    "description": "Allows the client to determine whether the customer is required to complete 3DS authentication for the transaction",
                    "is_required": false,
                    "is_updatable": false
                }
            ],
            "payment_options": [
                {
                    "name": "capture",
                    "type": "boolean",
                    "regex": "",
                    "description": "Determines when the payment is processed for capture.",
                    "is_required": false,
                    "is_updatable": false
                },
                {
                    "name": "complete_payment_url",
                    "type": "string",
                    "regex": "",
                    "description": "the complete_payment_url field must be filled in.",
                    "is_required": true,
                    "is_updatable": false
                },
                {
                    "name": "error_payment_url",
                    "type": "string",
                    "regex": "",
                    "description": "the error_payment_url field must be filled in.",
                    "is_required": true,
                    "is_updatable": false
                },
                {
                    "name": "statement_descriptor",
                    "type": "string",
                    "regex": "/^[a-zA-Z0-9]{0,22}/",
                    "description": "A text description suitable for a customer's payment statement. Limited to 22 characters.",
                    "is_required": false,
                    "is_updatable": false
                }
            ],
            "minimum_expiration_seconds": 0,
            "maximum_expiration_seconds": 604800
        }
    }
       
    

    The response indicates that the following fields are required for the payment method:

    • name

    • number

    • expiration_month

    • expiration_year

    • cvv

    Under payment_options, there are two fields which are required for adding a card payment method to a customer:

    • complete_payment_url

    • error_payment_url

Step 2. Create Customer

Creates a Customer object with the required information.

Run Create Customer with values for all the required fields.

Create Customer - Request

Request URL: post https://sandboxapi.rapyd.net/v1/customers

{
    "name": "John Doe",
    "payment_method": {
        "type": "sg_credit_cup_card",
        "fields": {
            "number": "4111111111111111",
            "expiration_month": "10",
            "expiration_year": "23",
            "cvv": "123",
            "name": "John Doe"
        },
        "complete_payment_url": "https://complete.rapyd.net/",
        "error_payment_url": "https://error.rapyd.net/"
    }
}
   

Create Customer - Response

{
    "status": {
        "error_code": "",
        "status": "SUCCESS",
        "message": "",
        "response_code": "",
        "operation_id": "acc384b0-1430-4d7d-a2b0-327be9da975a"
    },
    "data": {
        "id": "cus_81da79bf18af36e64b49c1c374faa524",
        "delinquent": false,
        "discount": null,
        "name": "John Doe",
        "default_payment_method": "card_c01d1b10f309884f381cfc499cdfb1ec",
        "description": "",
        "email": "",
        "phone_number": "",
        "invoice_prefix": "",
        "addresses": [],
        "payment_methods": {
            "data": [
                {
                    "id": "card_c01d1b10f309884f381cfc499cdfb1ec",
                    "type": "sg_credit_cup_card",
                    "category": "card",
                    "metadata": null,
                    "image": "https://iconslib.rapyd.net/checkout/sg_credit_cup_card.png",
                    "webhook_url": "",
                    "supporting_documentation": "",
                    "next_action": "3d_verification",
                    "name": "John Doe",
                    "last4": "1111",
                    "acs_check": "unchecked",
                    "cvv_check": "unchecked",
                    "bin_details": {
                        "type": null,
                        "brand": null,
                        "level": null,
                        "country": null,
                        "bin_number": "411111"
                    },
                    "expiration_year": "23",
                    "expiration_month": "10",
                    "fingerprint_token": "ocfp_e599f990674473ce6283b245e9ad2467",
                    "redirect_url": "https://sandboxcheckout.rapyd.net/3ds-payment?token=payment_178af04b589334ee6406eee7a430e028"
                }
            ],
            "has_more": false,
            "total_count": 1,
            "url": "/v1/customers/cus_81da79bf18af36e64b49c1c374faa524/payment_methods"
        },
        "subscriptions": null,
        "created_at": 1668353979,
        "metadata": {},
        "business_vat_id": "",
        "ewallet": "",
        "network_reference_id": 962926,
        "complete_payment_url": "https://complete.rapyd.net/",
        "error_payment_url": "https://error.rapyd.net/"
    }
}
   

The Customer object is created. The payment method token for sg_credit_cup_card appears in the payment_methods array and the default_payment_method field. Use this token to create a payment or subscription or to pay an order.