Skip to main content

Testing in Sandbox

We provide test values of various types that will produce different successful and unsuccessful results. These are only for use in the Sandbox environment.

Payment Methods

In place of a real single-use payment method, use these test payment method "nonces". These function as IDs for normal single-use payment methods, but will not be consumed.

You can pass these values as paymentMethodIds in any of the payment-method-related queries or mutations, including vaultPaymentMethod. Doing so will produce a normal vaulted PaymentMethod.

Example:

Mutation

mutation VaultPayPal($input: VaultPaymentMethodInput!) {
  vaultPaymentMethod(input: $input) {
    paymentMethod {
      usage
      details {
      ... on PayPalAccountDetails
        email
      }
    }
  }
}

Variables

{
  "input": {
    "id": "fake-paypal-billing-agreement-nonce"
  }
}

Response

"data": {
  "vaultPaymentMethod": {
    "paymentMethod": {
      "usage": "MULTI-USE",
      "details": {
        "email": "jane.doe@paypal.com"
      }
    }
  }
}

Charging Payment Methods

To create transactions with different statuses, use these test amounts as the amount on TransactionInput when charging a payment method.

Note: using the values for testing card verification in a chargePaymentMethod mutation will not test transaction statuses. You must use the appropriate amount value to do so.

Example:

Mutation

mutation ChargeCreditCardUnsuccessfully($input: ChargePaymentMethodInput!) {
  chargePaymentMethod(input: $input) {
    transaction {
      status
      paymentMethodSnapshot {
        ... on CreditCardDetails {
          brandCode
          bin
          last4
        }
      }
    }
  }
}

Variables

{
  "input": {
    "paymentMethodId": "fake-valid-nonce",
    "transaction": {
      "amount": "2046.00"
    }
  }
}

Response

"data": {
  "chargePaymentMethod": {
    "transaction": {
      "status": "PROCESSOR_DECLINED",
      "paymentMethodSnapshot": {
        "brandCode": "VISA"
        "bin": "401288",
        "last4": "1881",
      }
    }
  }
}
icon

Cookies help customize Braintree for you, and some are necessary to make our site work. By using Braintree, you accept our use of cookies. Learn more about the cookies we use and how you can manage them.