# How can I include customer data in the checkout page

**URL:** https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387
**Category:** ⚙️ API
**Tags:** collect-api, hosted-checkout
**Created:** [August 29, 2022, 10:54am UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387 "2022-08-29T10:54:31Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![devsmartup](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@devsmartup](https://community.rapyd.net/u/devsmartup)
#### Post date: [August 29, 2022, 10:54am UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387/1 "2022-08-29T10:54:31Z")

</div>

Hi, I add in the checkout page fields for the customers to fill in their credentials like their address and their email and I also want to show the name of the product on the checkout page so I can identify each product and I want all of the information to be stored in the rapyd dashboard  
is this possible I tried to do it like this but nothing changed

```auto

$checkout_body = ["amount" => "{$_POST['amount']}",
				  "complete_payment_url" => "{$_POST['complete_payment_url']}",
				  "country" => "{$_POST['country']}",
				  "error_payment_url" => "{$_POST['error_payment_url']}",
				  "complete_checkout_url" => "https://website.com/",
				  "description" => "product 1",
				  "custom_elements"=>["display_description" => "true"],
				  "3d_required" => "true",
				   "cart_items" => [ 
					   "name" => "pack1",
					   "amount" => "{$_POST['amount']}",
					   "quantity" => "1",
					   "image" => "image.jpg",
				   ],
				  "currency" => "{$_POST['currency']}"];
$body_string = json_encode(array_map('trim',json_decode(json_encode($checkout_body,JSON_FORCE_OBJECT), true)));

$body_string = str_replace("\\/", '/', $body_string);

$sig_string = $http_method.$path.$salt.$timestamp.$access_key.$secret_key.$body_string;
$hash_sig_string = hash_hmac("sha256", $sig_string, $secret_key);

$signature = base64_encode($hash_sig_string);

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://sandboxapi.rapyd.net/v1/checkout",
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => $body_string
));

curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'access_key: '.$access_key.'',
    'salt: '.$salt.'',
    'timestamp: '.$timestamp.'',
    'signature: '.$signature.''
));

$response = curl_exec($curl);

$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:".$err;
} else {
echo $response;
    $res=json_decode($response);
    $url=$res->data->redirect_url;
    header("Location: $url");
    die();
   
}

```

---

<div class="post-metadata">

### Author: ![Legato](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/legato/32/41_2.png) [@Legato](https://community.rapyd.net/u/Legato)
#### Post date: [August 29, 2022, 12:27pm UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387/2 "2022-08-29T12:27:45Z")

</div>

Hi @devsmartup,  
Welcome to the Rapyd developer community!  
I suggest to create a hosted page with a predefined customer. After the customer purchases the products via the hosted checkout page, the details can be found in the ‘Customers’ section of the Client Portal.  
Step 1:

```auto
curl --location --request POST 'https://sandboxapi.rapyd.net/v1/checkout' \
--header 'Content-Type: application/json' \
--header 'access_key: MTHG' \
--header 'salt: 456af0f22' \
--header 'timestamp: 1661775419' \
--header 'signature: Y2FmZWEwOQ==' \
--data-raw '{
    "complete_payment_url": "http://example.com/complete",
    "country": "SG",
    "currency": "SGD",
    "customer": "cus_c150cfd8771f014ebba7e60fd76c99ee",
    "error_payment_url": "http://example.com/error",
    "merchant_reference_id": "0912-2021",
    "language": "en",
    "metadata": {
        "merchant_defined": true
    },
    "payment_method_types_include": [
        "sg_grabpay_ewallet"
    ],
    "expiration": 1662027189,
    "cart_items": [{
            "name": "Bluetooth speaker model SJ-8097",
            "amount": 120.00,
            "quantity": 2
        }, {
            "name": "Pack of rechargeable batteries model 90-P",
            "amount": 3.45,
            "quantity": 1
        }
    ]
}'
{
    "status": {
        "error_code": "",
        "status": "SUCCESS",
        "message": "",
        "response_code": "",
        "operation_id": "322c1597-4e66-4185-a2c0-9d01aef678d5"
    },
    "data": {
        "id": "checkout_f9cf262dd62f3897a32ad43e674d496c",
        "status": "NEW",
        "language": "en",
        "merchant_color": "323fff",
        "merchant_logo": null,
        "merchant_website": "https://rapyd.net",
        "merchant_customer_support": {},
        "merchant_alias": "Doc Team",
        "merchant_terms": null,
        "merchant_privacy_policy": null,
        "page_expiration": 1662983799,
        "redirect_url": "https://sandboxcheckout.rapyd.net?token=checkout_f9cf262dd62f3897a32ad43e674d496c",
        "merchant_main_button": "place_your_order",
        "cancel_checkout_url": "https://rapyd.net",
        "complete_checkout_url": "https://rapyd.net",
        "country": "SG",
        "currency": "SGD",
        "amount": 243.45,
        "payment": {
            "id": null,
            "amount": 243.45,
            "original_amount": 0,
            "is_partial": false,
            "currency_code": "SGD",
            "country_code": "SG",
            "status": null,
            "description": "Payment via Checkout",
            "merchant_reference_id": "0912-2021",
            "customer_token": "cus_c150cfd8771f014ebba7e60fd76c99ee",
            "payment_method": null,
            "payment_method_data": {},
            "expiration": 1662027189,
            "captured": false,
            "refunded": false,
            "refunded_amount": 0,
            "receipt_email": null,
            "redirect_url": null,
            "complete_payment_url": "http://example.com/complete",
            "error_payment_url": "http://example.com/error",
            "receipt_number": null,
            "flow_type": null,
            "address": null,
            "statement_descriptor": null,
            "transaction_id": null,
            "created_at": 0,
            "updated_at": 0,
            "metadata": {
                "merchant_defined": true
            },
            "failure_code": null,
            "failure_message": null,
            "paid": false,
            "paid_at": 0,
            "dispute": null,
            "refunds": null,
            "order": null,
            "outcome": null,
            "visual_codes": {},
            "textual_codes": {},
            "instructions": {},
            "ewallet_id": null,
            "ewallets": [],
            "payment_method_options": {},
            "payment_method_type": null,
            "payment_method_type_category": null,
            "fx_rate": null,
            "merchant_requested_currency": null,
            "merchant_requested_amount": null,
            "fixed_side": null,
            "payment_fees": null,
            "invoice": null,
            "escrow": null,
            "group_payment": null,
            "cancel_reason": null,
            "initiation_type": "customer_present",
            "mid": null,
            "next_action": "not_applicable"
        },
        "payment_method_type": null,
        "payment_method_type_categories": null,
        "payment_method_types_include": [
            "sg_grabpay_ewallet"
        ],
        "payment_method_types_exclude": null,
        "customer": "cus_c150cfd8771f014ebba7e60fd76c99ee",
        "custom_elements": {
            "save_card_default": false,
            "display_description": false,
            "payment_fees_display": true,
            "merchant_currency_only": false,
            "billing_address_collect": false,
            "dynamic_currency_conversion": false
        },
        "timestamp": 1661774199,
        "payment_expiration": null,
        "cart_items": [
            {
                "name": "Bluetooth speaker model SJ-8097",
                "amount": 120,
                "quantity": 2,
                "image": null
            },
            {
                "name": "Pack of rechargeable batteries model 90-P",
                "amount": 3.45,
                "quantity": 1,
                "image": null
            }
        ],
        "escrow": null,
        "escrow_release_days": null
    }
}

```

Step 2: Customer purchases items via checkout page:

 ![2022-08-29 14_57_45-Checkout](https://us1.discourse-cdn.com/flex016/uploads/rapyd/original/3X/e/6/e614d637d7609edb77ba1d60f7f5dd7bd57be6ad.png)

Step 3 (Optional): “Customers” section of Client Portal displays the data:

 ![2022-08-29 15_24_48-](https://us1.discourse-cdn.com/flex016/uploads/rapyd/original/3X/e/6/e6b9a3bd2f2140009e05982dfedfa370cbda320c.png)

You can also find more details when you inspect the related payment:

 ![2022-08-29 15_34_45-Collect - Rapyd Client Portal](https://us1.discourse-cdn.com/flex016/uploads/rapyd/original/3X/c/7/c7b754253bc563ed6f1a77634c4eda3c27a44b34.png)

---

<div class="post-metadata">

### Author: ![devsmartup](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@devsmartup](https://community.rapyd.net/u/devsmartup)
#### Post date: [August 29, 2022, 12:47pm UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387/3 "2022-08-29T12:47:00Z")

</div>

Thank you for your reply,  
I am quite confused about the predefined customer, do you mean that I should create a form that will add a customer? I want to display the save card details page. how can I do that?

---

<div class="post-metadata">

### Author: ![Legato](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/legato/32/41_2.png) [@Legato](https://community.rapyd.net/u/Legato)
#### Post date: [August 29, 2022, 12:58pm UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387/4 "2022-08-29T12:58:36Z")

</div>

My pleasure 🙂  
Regarding your first question, see this section on customers and creating a customer:  
[https://docs.rapyd.net/build-with-rapyd/reference/customers](https://docs.rapyd.net/build-with-rapyd/reference/customers)  
After you create a customer, you can add the customer id (string starting with **cus\_** ) when you create the checkout page.  
There are samples here (on the right pane of the page):  
[https://docs.rapyd.net/build-with-rapyd/reference-link/create-checkout-page](https://docs.rapyd.net/build-with-rapyd/reference-link/create-checkout-page)

Regarding your second question, note that the checkout page also supports payment methods other than cards. When a card is used for a payment via the checkout page, the related payment details include the card details.

See also:

> **[How to Save Your Customer Details During the Checkout Process - Rapyd](https://www.rapyd.net/blog/save-your-customer-details-during-checkout/)**
>
> You can save your customer's card details during the checkout process to create a smooth customer workflow while capturing user data.

Thanks

---

<div class="post-metadata">

### Author: ![devsmartup](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@devsmartup](https://community.rapyd.net/u/devsmartup)
#### Post date: [August 29, 2022, 1:25pm UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387/5 "2022-08-29T13:25:41Z")

</div>

so there is no way to include customer details on the checkout page, I have to make a form and create a customer and then use the customer id to create a checkout page in order to get the information of the customer in Rapyd dashboard.  
and for the save card details page, it shows for certain payment methods . is this right?

---

<div class="post-metadata">

### Author: ![Legato](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/legato/32/41_2.png) [@Legato](https://community.rapyd.net/u/Legato)
#### Post date: [August 29, 2022, 1:35pm UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387/6 "2022-08-29T13:35:02Z")

</div>

Checkout this video of one of our previous hackathon winners as an example for an integration:

[![](https://us1.discourse-cdn.com/flex016/uploads/rapyd/original/3X/7/b/7baef9de4d6ac7fe86fca0a556cc1907c547d6d7.jpeg "Rapyd G-Force") ](https://www.youtube.com/watch?v=eYc85VBhwd8)

---

<div class="post-metadata">

### Author: ![devsmartup](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@devsmartup](https://community.rapyd.net/u/devsmartup)
#### Post date: [August 29, 2022, 1:55pm UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387/7 "2022-08-29T13:55:33Z")

</div>

Thank you for the video, but it did not helped me. sir I don’t think you undrestand what I want. we have an e-commerce website and we have lot of unknowing customers so each time somone wants to buy something he has to fill in his credancials so we can identify each prodact and know whitch customer bought that product . everything is automaticly added(customers and orders) using php code which generate a chekout page

---

<div class="post-metadata">

### Author: ![Community\_Team](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Community\_Team](https://community.rapyd.net/u/Community_Team)
#### Post date: [August 29, 2022, 9:48pm UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387/8 "2022-08-29T21:48:44Z")

</div>

Hi @devsmartup,

I understand you are looking for a way to save your customer credentials.

I believe I understand your problem, however can you help us understand the exact solution you are looking for?

Are you looking for a way to input customer details AND payment information on the same form?

I believe currently, with the Rapyd API, this would have to be two forms but could be within the workflow. For example billing information first creating the customer and then payment information with save card details.

@Legato shared share relevant information, about the customer and then using Save card details `save_card_details: true` to save the credit card details in the back ground and save it to the generated customer ID.

---

<div class="post-metadata">

### Author: ![devsmartup](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@devsmartup](https://community.rapyd.net/u/devsmartup)
#### Post date: [August 30, 2022, 8:46am UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387/9 "2022-08-30T08:46:46Z")

</div>

Hello @Community_Team

> Are you looking for a way to input customer details AND payment information on the same form?

yes exactly.

> I believe currently, with the Rapyd API, this would have to be two forms but could be within the workflow.

does Rapyd provide such a thing if yes can you tell me how to do it ?

---

<div class="post-metadata">

### Author: ![Community\_Team](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Community\_Team](https://community.rapyd.net/u/Community_Team)
#### Post date: [September 1, 2022, 11:28pm UTC](https://community.rapyd.net/t/how-can-i-include-customer-data-in-the-checkout-page/55387/10 "2022-09-01T23:28:42Z")

</div>

Thanks @devsmartup, to answer your question directly, you cannot input all of this information at once on the same form for a user checking out the first time.

It can however be in the same workflow for the user.

Yes you would create the form tied to the [Create a Customer API request](https://docs.rapyd.net/build-with-rapyd/reference/customers).

Most payment workflows would have checkout as guest, or create an account, so this is where you could do this.

That will create a customer ID as @Legato shared and then you can [generate the checkout page](https://docs.rapyd.net/build-with-rapyd/reference-link/create-checkout-page) as he shared. One this page you can collect the billing address and a new card that can be saved. This form will be generated for you.

##### Create Checkout Page for Customer - Billing Collect

![checkout-for-customer-collect-billing](https://us1.discourse-cdn.com/flex016/uploads/rapyd/original/3X/b/e/bed6d472f8dd5036e7834a2dfdb580610363bdea.gif)

##### Create Checkout Page for Customer - Complete Payment

![checkout-for-customer-complete](https://us1.discourse-cdn.com/flex016/uploads/rapyd/original/3X/a/7/a746acf822df005676931fbf1f5b0cab7141b585.gif)
