# Create Payment - using a credit card token

To initiate a payment with a credit card token, first process a transaction using the customer's credit card information using one of the method below:

  1. Using full card details - (requires SAQ D PCI compliance)
  2. Using a credit card nonce
  3. Using hosted payment page

The response will provide a credit_card id, referencing the customer's card. This allows for future billing without requiring the customer to re-enter their full card details.

TIP

Processing payments with the credit_card id, enables seamless transactions for both subscription and non-subscription purchases. This eliminates the need for your customers to repeatedly enter their information for every purchase they make from you

# Using a credit card token

    Request example
    • Shell
    • JavaScript
    curl -X POST \
      https://api.ompay.com/v1/merchants/w3z8dfhkzvfq0j9n/payment \
      -H 'authorization: Basic ODZidWQ0Y2JremlxOXZmYzoweHI1ZDkwOHo2bmo4a2h6' \
      -H 'content-type: application/json' \
      -d '{
    		"intent": "sale",
    		"payer": {
    			"payment_type": "CC",
    			"funding_instrument": {
    				"credit_card_token":{
    					"credit_card_id":"20abc6eb-35fd-427e-b57e-c7eea99dd423"
    					,"cvv2":"123"			
    				}
    			},
    			"payer_info": {
    				"email": "tomhank@gmail.com",
    				"name": "Tom Hanks",
    				"billing_address": {
    					"line1": "18 Avenue",
    					"line2": "cassidy",
    					"city": "Rose-Hill",
    					"country_code": "mu",
    					"postal_code": "72101",
    					"state": "",
    					"phone": {
    						"country_code": "230",
    						"number": "57976041"
    					}
    				}
    			},
                "browser_info": {
    				"accept_header": "text/html,application/xhtml+xml,application/xml;q\u003d0.9,image/avif,image/webp,*/*;q\u003d0.8",
    				"color_depth": 24,
    				"java_enabled": false,
    				"javascript_enabled": true,
    				"language": "en-US",
    				"screen_height": "1080",
    				"screen_width": "1920",
    				"timezone_offset": -240,
    				"user_agent": "Mozilla/5.0 \u0026 #40;Windows NT 10.0; Win64; x64; rv:103.0\u0026#41; Gecko/20100101 Firefox/103.0",
    				"ip": "12.2.12.0",
    				"channel": "Web"
    			}
    		},
    		"payee": {
    			"email": "mail@test.com",
    			"merchant_id": "{{merchantId}}"
    		},
    		"transaction": {
    			"type": "1",
    			"amount": {
    				"currency": "USD",
    				"total": "300"
    			},
    			"invoice_number": "123455",
    			"items": [{
    					"sku": "100299S",
    					"name": "Ultrawatch",
    					"description": "Smart watch",
    					"quantity": "1",
    					"price": "500",
    					"shipping": "20",
    					"currency": "USD",
    					"url": "",
    					"image": "",
    					"tangible": "true"
    				},
    				{
    					"sku": "100269S",
    					"name": "Drone",
    					"description": "drone x",
    					"quantity": "1",
    					"price": "500",
    					"shipping": "20",
    					"currency": "USD",
    					"url": "",
    					"image": "",
    					"tangible": "true"
    				}
    			]
    		}
    	}'
    
    Response example
    	{
    		"id": "3XQWC579V8DQWF19NZ4R",
    		"reference_id": "3XQWC579V8DQWF19NZ4R",
    		"state": "pending",
            "result": {
                "authorisation_code": "00000",
                "redirect_url": "https://api.sandbox.ompay.com/v1/redirect/06a7fbfcacad4290b854597dc442138f",
                "authenticate_url": "https://api.sandbox.ompay.com/v1/authenticate/06a7fbfcacad4290b854597dc442138f",
                "code": "1007",
                "description": "Redirect"
            },
            "intent": "SALE",
    		"payer": {
    			"payment_type": "CC",
    			"funding_instrument": {
    				"credit_card": {
    					"id": "20abc6eb-35fd-427e-b57e-c7eea99dd423",
    					"type": "Visa",
    					"expire_month": 6,
    					"expire_year": 2025,
    					"name": "Tom Hanks",
    					"cvv_check": "Y",
    					"avs_check": "S",
    					"last4": "9996",
    					"bin": "454347",
    					"bin_data": {
    						"bin": "454347",
    						"country_code": "MU",
    						"country_name": "Mauritius",
    						"bank_name": "MCB",
    						"card_scheme": "Visa",
    						"card_type": "Credit",
    						"card_category": "1"
    					}
    				}
    			},
    			"payer_info": {
    				"id": "35d4d1ec-4f9d-416d-acdc-d12f4bf0c6df",
    				"email": "tomhank@gmail.com",
    				"name": "Tom Hanks",
    				"billing_address": {
    					"phone": {
    						"country_code": "230",
    						"number": "57976041"
    					},
    					"line1": "18 Avenue",
    					"line2": "cassidy",
    					"city": "Rose-Hill",
    					"country_code": "MU",
    					"postal_code": "72101",
    					"state": ""
    				}
    			}
    		},
    		"transaction": {
    			"amount": {
    				"currency": "USD",
    				"total": "300"
    			},
    			"type": "1",
    			"mode": "1",
    			"items": [
    				{
    					"sku": "100299S",
    					"name": "Ultrawatch",
    					"description": "Smart watch",
    					"quantity": "1",
    					"price": "500",
    					"shipping": "",
    					"url": ""
    				},
    				{
    					"sku": "100269S",
    					"name": "Drone",
    					"description": "drone x",
    					"quantity": "1",
    					"price": "500",
    					"shipping": "",
    					"url": ""
    				}
    			],
    			"shipping_address": {
    				"phone": {}
    			},
    			"invoice_number": "123455"
    		},
    		"custom": {},
    		"risk_check": true,
    		"three_d": {},
    		"create_time": "2023-06-10T18:07:16Z",
    		"subscriptions": null
    	}
    

    TIP

    1. Please ensure that when processing Omannet transactions, the intent is set to sale.
    2. In case the response includes a redirect_url, kindly redirect your customers to that URL to complete the OTP flow.

    # Request

    To proceed with a sale or authorized payment for future capture, you will need to include the payment details within the JSON request body. Depending on your specific requirements, set the intent parameter to either "sale" or "auth".

    It is also essential to provide the necessary "payer" and "transaction" details.

    The type of payment that will be created is determined by the specific combination of the "payment_method" and "funding_instrument" parameters.

    # Header parameters

    The request require a Basic authentication in the header. For more information about HTTP request headers, see HTTP request headers.