# Creating Payment but got error

**URL:** https://community.rapyd.net/t/creating-payment-but-got-error/55513
**Category:** ⚙️ API
**Tags:** collect-api
**Created:** [September 2, 2022, 5:10pm UTC](https://community.rapyd.net/t/creating-payment-but-got-error/55513 "2022-09-02T17:10:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ritikranjan12](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/ritikranjan12/32/20250_2.png) [@ritikranjan12](https://community.rapyd.net/u/ritikranjan12)
#### Post date: [September 2, 2022, 5:10pm UTC](https://community.rapyd.net/t/creating-payment-but-got-error/55513/1 "2022-09-02T17:10:00Z")

</div>

Hello,I am currentlyy trying to create a payment request with the below code.

```auto
try {
        const body = {
                amount: 101,
                currency: "INR",
                payment_method: {
                    type: "in_rupay_debit_card"
                }
           };
            const result = await makeRequest('POST', '/v1/payments', body);
            res.json({"output": result})        
          } catch (error) {
            res.json({"output": error})
          }

```

But getting error !

```auto
"body": {
      "status": {
        "error_code": "CREATE_CARD_TYPE_REQUIRES_ONLY_ONE_OF_FIELDS_OR_TOKEN",
        "status": "ERROR",
        "message": "The request tried to add a payment method to a customer, but both the 'type' and 'token' body parameters are set, or they are both unset. The request was rejected. Corrective action: Set one of the following parameters: 'type' or 'token'.",
        "response_code": "CREATE_CARD_TYPE_REQUIRES_ONLY_ONE_OF_FIELDS_OR_TOKEN",
        "operation_id": "b80c5fa2-adaf-4b53-9a56-7aa7fe39937b"
      }
    }

```

Can anyone suggest me how to resolve 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 2, 2022, 5:48pm UTC](https://community.rapyd.net/t/creating-payment-but-got-error/55513/2 "2022-09-02T17:48:38Z")

</div>

Hi @ritikranjan12, if you’re trying to create a payment request you need to look at [Get Required Fields for Payment Method](https://docs.rapyd.net/build-with-rapyd/reference/payment-method-types#get-payment-method-required-fields) to see what to include for the required fields.

If you want to just use the payment method type, this would need to be [tokenized for a customer](https://docs.rapyd.net/build-with-rapyd/reference/customer-payment-methods#add-payment-method-to-customer) and then you can include the card ID.

Here’s what your request should look like

### [Create Payment](https://docs.rapyd.net/build-with-rapyd/reference/payments#create-payment)

##### Request

```auto
{
	"amount": 101,
	"currency": "INR",
	"payment_method": {
		"type": "in_rupay_debit_card",
		"fields": {
			"number": "4111111111111111",
			"expiration_month": "12",
			"expiration_year": "23",
			"name": "John Doe",
			"cvv": "345"
		},
		"metadata": {
		"merchant_defined": true
	}
	},
	"capture": true
}

```

##### Response

```auto
{
    "status": {
        "error_code": "",
        "status": "SUCCESS",
        "message": "",
        "response_code": "",
        "operation_id": "34660636-9842-45f9-983a-895ed3bde92a"
    },
    "data": {
        "id": "payment_be6ebf0d94ad13c87c12348bea96cdab",
        "amount": 101,
        "original_amount": 101,
        "is_partial": false,
        "currency_code": "INR",
        "country_code": "in",
        "status": "CLO",
        "description": "",
        "merchant_reference_id": "",
        "customer_token": "cus_7580469a79f773751a49a8e11013098f",
        "payment_method": "card_c5acbc0404089a7faf113a44e906edf6",
        "payment_method_data": {
            "id": "card_c5acbc0404089a7faf113a44e906edf6",
            "type": "in_rupay_debit_card",
            "category": "card",
            "metadata": {
                "merchant_defined": true
            },
            "image": "",
            "webhook_url": "",
            "supporting_documentation": "",
            "next_action": "not_applicable",
            "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": "12",
            "fingerprint_token": "ocfp_2a694038316f52122bbbb3ae926cfda9"
        },
        "auth_code": null,
        "expiration": 1662745417,
        "captured": true,
        "refunded": false,
        "refunded_amount": 0,
        "receipt_email": "",
        "redirect_url": "",
        "complete_payment_url": "",
        "error_payment_url": "",
        "receipt_number": "",
        "flow_type": "",
        "address": null,
        "statement_descriptor": "Test Business",
        "transaction_id": "",
        "created_at": 1662140617,
        "metadata": {},
        "failure_code": "",
        "failure_message": "",
        "paid": true,
        "paid_at": 1662140618,
        "dispute": null,
        "refunds": null,
        "order": null,
        "outcome": null,
        "visual_codes": {},
        "textual_codes": {},
        "instructions": [
            {
                "name": "instructions",
                "steps": [
                    {
                        "step1": "Enter card details."
                    },
                    {
                        "step2": "Goto 3DS page and enter OTP."
                    },
                    {
                        "step3": "Complete payment."
                    }
                ]
            }
        ],
        "ewallet_id": "ewallet_db4ad4a76278f94c4a83dd9b28b483ed",
        "ewallets": [
            {
                "ewallet_id": "ewallet_db4ad4a76278f94c4a83dd9b28b483ed",
                "amount": 101,
                "percent": 100,
                "refunded_amount": 0
            }
        ],
        "payment_method_options": {},
        "payment_method_type": "in_rupay_debit_card",
        "payment_method_type_category": "card",
        "fx_rate": 1,
        "merchant_requested_currency": null,
        "merchant_requested_amount": null,
        "fixed_side": "",
        "payment_fees": null,
        "invoice": "",
        "escrow": null,
        "group_payment": "",
        "cancel_reason": null,
        "initiation_type": "customer_present",
        "mid": "",
        "next_action": "not_applicable",
        "error_code": "",
        "remitter_information": {}
    }
}

```

---

<div class="post-metadata">

### Author: ![ritikranjan12](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/ritikranjan12/32/20250_2.png) [@ritikranjan12](https://community.rapyd.net/u/ritikranjan12)
#### Post date: [September 2, 2022, 6:10pm UTC](https://community.rapyd.net/t/creating-payment-but-got-error/55513/3 "2022-09-02T18:10:20Z")

</div>

> [@Community\_Team](#):
>
> ```auto
> "amount": 101,
> "currency": "INR",
> "payment_method": {
> "type": "in_rupay_debit_card",
> "fields": {
> "number": "4111111111111111",
> "expiration_month": "12",
> "expiration_year": "23",
> "name": "John Doe",
> "cvv": "345"
> },
> "metadata": {
> "merchant_defined": true
> }
> },
> "capture": true
> 
> ```

Got it!  
But It does not provide me the complete url for payment,then how may i proceed further?  
I had added my card details too!!

---

<div class="post-metadata">

### Author: ![CharlesDorsett](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/charlesdorsett/32/47_2.png) [@CharlesDorsett](https://community.rapyd.net/u/CharlesDorsett)
#### Post date: [September 4, 2022, 2:07pm UTC](https://community.rapyd.net/t/creating-payment-but-got-error/55513/4 "2022-09-04T14:07:52Z")

</div>

It looks to me like your request contains neither the ‘fields’ object nor the ‘payment\_method’ token. You must have one or the other, and not both.

---

<div class="post-metadata">

### Author: ![CharlesDorsett](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/charlesdorsett/32/47_2.png) [@CharlesDorsett](https://community.rapyd.net/u/CharlesDorsett)
#### Post date: [September 4, 2022, 2:11pm UTC](https://community.rapyd.net/t/creating-payment-but-got-error/55513/5 "2022-09-04T14:11:54Z")

</div>

You have to provide a value for ‘complete\_payment\_url’ and ‘error\_payment\_url’ when the payment method is in\_rupay\_debit\_card. These are the URLs that your customer is redirected to after he completes the payment or there is an error, respectively.
