Creating a Credit Card Payment

Created by Richard Moore, Modified on Wed, 12 Jul, 2023 at 1:54 PM by Richard Moore

Exact Payments can be used to process

  • Online (E-commerce) credit card payments
  • ACH payments
  • Apple Pay and Google Pay
  • PayPal


Steps to processing a credit card payment

  1. Create a Customer
  2. Create a Payment Method
  3. Attach Payment Method for a Customer
  4. Create a Payment
  5. Post-payments Actions


Before you begin

  1. Generate a token for authentication (ensure it has charges.create permissions)
  2. Have a Merchant account that is Live Capable. Use the List Accounts request to ensure that the account shows "isLiveCapable"true

Step 1 - Create a Customer


Note: It is not necessary to Create a Customer before Creating a Payment Method. However, Exact views this as the best practice.

curl --request POST \
  --url https://api.exactpaysandbox.com/account/64625a000b46cb07fd21d1d5/customer \
  --header 'Authorization: ' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "Ian Callaghan",
  "email": "[email protected]",
  "phone": "5555555555",
  "addresses": [
    {
      "label": "Home",
      "city": "Scottsdale",
      "country": "USA",
      "line1": "12621 N Frank Lloyd Wright Blvd",
      "line2": "200",
      "postalCode": "85259",
      "state": "AZ",
      "isDefault": true
    }
  ]
}'


A 201 response is returned on successful creation of a new Customer


{
    "id": "64668e4090fd7871007e8ff4",
    "token": "a40b5a57-9835-4b56-a6c5-77e00b787243",
    "createdAt": "2023-05-18T20:44:48.799Z",
    "updatedAt": "2023-05-18T20:44:48.799Z",
    "name": "Ian Callaghan",
    "email": "[email protected]",
    "phone": "5555555555",
    "addresses": [
        {
            "label": "Home",
            "city": "Scottsdale",
            "country": "USA",
            "line1": "12621 N Frank Lloyd Wright Blvd",
            "line2": "200",
            "postalCode": "85259",
            "state": "AZ",
            "isDefault": true
        }
    ]
}

Step 2 - Create a Payment Method

curl --request POST \
  --url https://api.exactpaysandbox.com/account/64625a000b46cb07fd21d1d5/payment-method \
  --header 'Authorization: ' \
  --header 'Content-Type: application/json' \
  --data '{
  "billingDetails": {
      "address": {
      "line1": "12621 N Frank Lloyd Wright Blvd",
      "city": "Scottsdale",
      "state": "AZ",
      "country": "USA",
      "postalCode": "85259"
    },
    "name": "Ian Callaghan",
    "email": "[email protected]",
    "phone": "5555555555",
  },
  "type": "card",
    "number": "5454545454545454",
    "cvc": "123",
    "expiry": {
      "month": 10,
      "year": 2028
    },
    "cvc": "275",
    "tokenType": "gateway"
  }
}'


A 201 response is returned on successful creation of a new Payment Method


{
    "type": "card",
    "token": "c4bc6b66-0c0d-4ee5-b70e-9d6706141aea",
    "updatedAt": "2023-05-18T21:00:43.960Z",
    "createdAt": "2023-05-18T21:00:43.962Z",
    "billingDetails": {
        "email": "[email protected]",
        "name": "Ian Callaghan",
        "phone": "5555555555",
        "address": {
            "city": "Scottsdale",
            "country": "USA",
            "line1": "12621 N Frank Lloyd Wright Blvd",
            "postalCode": "85259",
            "state": "AZ"
        }
    },
    "card": {
        "brand": "mastercard",
        "lastFour": "5454",
        "checks": {
            "cvcCheck": "full-match",
            "addressCheck": "not-verified"
        },
        "expiry": {
            "month": 10,
            "year": 2028
        },
        "tokenType": "gateway"
    }
}

Step 3 - Attach Payment Method for a Customer

curl --request POST \
  --url https://api.exactpaysandbox.com/account/64625a000b46cb07fd21d1d5/customer/64668e4090fd7871007e8ff4/payment-method \
  --header 'Authorization: ' \
  --header 'Content-Type: application/json' \
  --data '{
  "token": "c4bc6b66-0c0d-4ee5-b70e-9d6706141aea",
  "isDefault": true,
  "label": "iancallaghanDefault"
}'

A 201 response is returned confirming the Payment Method has been successfully attached to the specified Customer

{
    "type": "card",
    "token": "bbe3c387-ad33-4661-b598-742b0aeb5e2f",
    "updatedAt": "2023-05-18T21:00:43.960Z",
    "createdAt": "2023-05-18T21:00:43.962Z",
    "billingDetails": {
        "email": "[email protected]",
        "name": "Ian Callaghan",
        "phone": "5555555555",
        "address": {
            "city": "Scottsdale",
            "country": "USA",
            "line1": "12621 N Frank Lloyd Wright Blvd",
            "postalCode": "85259",
            "state": "AZ"
        }
    },
    "label": "iancallaghanDefault",
    "isDefault": true,
    "card": {
        "brand": "mastercard",
        "lastFour": "5454",
        "checks": {
            "cvcCheck": "full-match",
            "addressCheck": "not-verified"
        },
        "expiry": {
            "month": 10,
            "year": 2028
        },
        "tokenType": "gateway"
    }
}

Step 4 - Create a Payment


Now that the Payment Method has been attached to the Customer we can send the
customerId from Step 1 as a token in the Create Payment request.

Note: Use the "Create Payment for a given account" request


curl --request POST \
  --url https://api.exactpaysandbox.com/account/6151ffdbefd963001c6c9d2d/payment-method \
  --header 'Authorization: ' \
  --header 'Content-Type: application/json' \
  --data '{
    "amount": 100,
    "capture": true,
    "paymentMethod": {
    "token": "a40b5a57-9835-4b56-a6c5-77e00b787243"
  },
  "reference": {
    "customerRef": "iancallaghan",
    "referenceNo": "123456"
  }
}


A 201 response is returned confirming that the transaction was processed


{
    "id": "6466973779ec21386cc513d4",
    "paymentId": "6466973779ec21386cc513d4",
    "terminalId": "64625a01c816a98a00fdd995",
    "merchantId": "64625a002e31011546388b0c",
    "accountId": "64625a000b46cb07fd21d1d5",
    "type": "payment",
    "status": "completed",
    "approved": true,
    "captured": true,
    "voided": false,
    "refunded": false,
    "settled": false,
    "authorization": "ET116539",
    "amount": 100,
    "sentToBank": true,
    "createdAt": "2023-05-18T21:23:03.114Z",
    "funded": false,
    "customerId": "64668e4090fd7871007e8ff4",
    "reference": {
        "customerRef": "iancallaghan",
        "referenceNo": "123456"
    },
    "currencyCode": "USD",
    "bankResponse": {
        "code": "AA",
        "message": "Approved Transaction"
    },
    "paymentMethodDetails": {
        "cardBrand": "mastercard",
        "cardholder": "Ian Callaghan",
        "last4": "5454",
        "expiryMonth": 10,
        "expiryYear": 2028,
        "cvdCheck": {
            "code": "I",
            "description": "CVV2 code is invalid or empty"
        }
    },
    "merchant": {
        "name": "Test Merchant for Testing",
        "url": "https://www.testtest.com",
        "address": {
            "line1": "Test St",
            "city": "Green Bay",
            "state": "Wisconsin",
            "postalCode": "60006",
            "countryCode": "United States"
        }
    },
    "terminal": {
        "gatewayId": "R10392-96"
    }
}


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article