Anchor to section titled 'undefined'

customerPaymentMethodCreditCardCreate
mutation

Requires write_customers access scope. Also: Requires write_customer_payment_methods scope.

Creates a credit card payment method for a customer using a session id. These values are only obtained through card imports happening from a PCI compliant environment. Please use customerPaymentMethodRemoteCreate if you are not managing credit cards directly.


The billing address.

Anchor to customerId
customerId
required

The ID of the customer.

The Cardserver session ID. Obtained by storing card data with Shopify's Cardsink. Exchanging raw card data for a session ID must be done in a PCI complaint environment.


Was this section helpful?

If the card verification result is processing. When this is true, customer_payment_method will be null.

The list of errors that occurred from executing the mutation.


Was this section helpful?
Hide code
Mutation reference
Copy
mutation customerPaymentMethodCreditCardCreate($billingAddress: MailingAddressInput!, $customerId: ID!, $sessionId: String!) {
  customerPaymentMethodCreditCardCreate(billingAddress: $billingAddress, customerId: $customerId, sessionId: $sessionId) {
    customerPaymentMethod {
      # CustomerPaymentMethod fields
    }
    processing
    userErrors {
      field
      message
    }
  }
}
Hide code
Input
Copy
{
  "billingAddress": {
    "address1": "<your-address1>",
    "address2": "<your-address2>",
    "city": "<your-city>",
    "company": "<your-company>",
    "countryCode": "AC",
    "firstName": "<your-firstName>",
    "lastName": "<your-lastName>",
    "phone": "<your-phone>",
    "provinceCode": "<your-provinceCode>",
    "zip": "<your-zip>"
  },
  "customerId": "gid://shopify/<objectName>/10079785100",
  "sessionId": "<your-sessionId>"
}
input MailingAddressInput {
  address1: String
  address2: String
  city: String
  company: String
  country: String
  countryCode: CountryCode
  firstName: String
  id: ID
  lastName: String
  phone: String
  province: String
  provinceCode: String
  zip: String
}