Skip to content

Platform / Task

Add a payment method

Updated · 4 min read

Add a card to a billing account on the payment provider's hosted page, confirm it, and check paymentMethodStatus so the account's projects can create billable resources.

On this page6 sections

A project can create billable resources only once its billing account has a verified payment method. You enter the card on the payment provider’s hosted page; card details never pass through Origin Cloud.

Before you begin

When a payment method is needed

A billing account’s paymentMethodStatus is one of three values:

paymentMethodStatusMeaning
NONENo verified payment method. Billable resources are refused.
VERIFIEDA payment method is on file and verified.
NOT_REQUIREDBilling is arranged with Origin Cloud directly, and no payment method is needed.

While the status is NONE, these operations in the account’s projects are refused with PAYMENT_METHOD_REQUIRED:

  • Launch an instance
  • Create, import or grow a volume
  • Create a snapshot
  • Allocate a Floating IP
  • Create a NAT gateway

Creating VPCs, subnets, security groups and other network configuration doesn’t need a payment method, so you can set up your network first, once the organization is ACTIVE: creating a VPC, including the default VPC, is refused until then. The organization must also be ACTIVE for the operations above. See Organization review status.

Add the payment method

The steps send GraphQL requests with curl. Each request uses this pattern, with the request body on standard input:

terminal
curl -sS https://api.origincloud.eu/graphql \
  -H "$(origin id token --as-header --raw)" \
  -H "Content-Type: application/json" \
  --data @- <<'EOF'
<request-body>
EOF
  1. Find the billing account the project is charged to, and its current status:

    JSON
    {
      "query": "query($org: OrgId!, $p: ProjectId!) { admin { project(orgId: $org, projectId: $p) { billingAccountId } billingAccounts(input: {orgId: $org}) { billingAccountId displayName paymentMethodStatus } } }",
      "variables": { "org": "<org-id>", "p": "<project-id>" }
    }

    If the project’s billing account is VERIFIED or NOT_REQUIRED, you’re done.

  2. Start the setup on that billing account:

    JSON
    {
      "query": "mutation($org: OrgId!, $ba: BillingAccountId!) { admin { startPaymentMethodSetup(input: {orgId: $org, id: $ba}) { redirectUrl } } }",
      "variables": { "org": "<org-id>", "ba": "<billing-account-id>" }
    }

    The response contains a redirectUrl.

  3. Open the redirectUrl in your browser and enter the card details. When you finish, the page returns you to the Origin Cloud console.

  4. Confirm the setup:

    JSON
    {
      "query": "mutation($org: OrgId!, $ba: BillingAccountId!) { admin { confirmPaymentMethodSetup(input: {orgId: $org, id: $ba}) { paymentMethodStatus paymentMethodBrand paymentMethodLast4 } } }",
      "variables": { "org": "<org-id>", "ba": "<billing-account-id>" }
    }

    The platform checks the result with the payment provider. Returning to the console alone proves nothing.

  5. Verify that paymentMethodStatus is VERIFIED. The response also shows the card brand and its last four digits. Example output (illustrative):

    JSON
    {
      "data": {
        "admin": {
          "confirmPaymentMethodSetup": {
            "paymentMethodStatus": "VERIFIED",
            "paymentMethodBrand": "visa",
            "paymentMethodLast4": "4242"
          }
        }
      }
    }

Every project charged to this billing account can now create billable resources. Send any request that was refused with PAYMENT_METHOD_REQUIRED again, unchanged.

If the confirmation fails

Both mutations fail with BAD_REQUEST naming billing_account_id in these cases:

  • The checkout wasn’t completed. You left the hosted page before finishing, or the card was declined. Finish the hosted page, or start again from step 2.
  • No setup is in progress. Nothing was started, or the setup was already confirmed. Check paymentMethodStatus: if it’s VERIFIED, you’re done.
  • The account needs no payment method. Its status is NOT_REQUIRED.

Starting again always works and replaces any unfinished setup.

Replace the payment method

Run the same steps on a billing account that is already VERIFIED. The new card replaces the old one when you confirm it. Until then, the old card stays in place.