Apply Payment Method to Cart
There are currently two methods for applying a guest payment method to a cart. The first method is to apply a generated payment token where the card data was tokenized before sending it to Violet. The second method is to send raw card data directly to Violet.
If your checkout flow does not require an additional step after applying a payment method you can provide the complete_checkout property in your request body with a value of true. This will submit your cart as an order and complete the checkout process if the payment method is valid.
Apply a payment method to the given cart. API Reference: Apply Payment Method
cart_id - The ID of the cart for which the payment method is being applied to
Applying a Generated Token
If you are building a client side application we recommend using the Stripe.js library to first tokenize your customers card data before sending it to Violet. You can learn more about how to do this in our Payments and Payouts section. Once you have a generated token you can apply it a cart with a request similar to the following example.
Applying a Credit/Debit Card
If using a generated payment token is not possible for your application and you plan on being PCI compliant you apply card data directly to a cart. The following snippet shows an example of this.
Tokens will always take priority over card data when applying the payment method to a cart. If you wish to use card data please leave the token property empty or simply omitted from the request body.