StripeKit 0.1.1
Stripe integration toolkit for C++
Loading...
Searching...
No Matches
RequestOptions.h
1/** RequestOptions.h
2 *
3 * Shared per-request options for outbound Stripe API calls.
4 *
5 * @author Hans de Ruiter
6 *
7 * @license See LICENSE.md for details.
8 */
9
10#pragma once
11
12#include <chrono>
13#include <optional>
14#include <string>
15#include <unordered_map>
16
17namespace stripekit {
18
19/**
20 * @ingroup client
21 *
22 * Per-call settings accepted by every client operation.
23 *
24 * @code
25 * stripekit::RequestOptions options;
26 * options.idempotency_key = "checkout-for-order-1234";
27 * options.timeout = std::chrono::seconds(30);
28 * @endcode
29 */
31 /**
32 * Makes the call safe to retry.
33 *
34 * If a response is lost and the same key is sent again, Stripe returns the
35 * original result instead of performing the work twice. Set this on
36 * anything that creates or charges, and derive the key from something
37 * stable in the application, such as an order id.
38 *
39 * @sa https://docs.stripe.com/api/idempotent_requests
40 */
41 std::optional<std::string> idempotency_key;
42
43 /**
44 * Overrides the adapter's default timeout for this call.
45 */
46 std::optional<std::chrono::milliseconds> timeout;
47
48 /**
49 * Extra HTTP headers, merged over the adapter's defaults.
50 *
51 * Mostly useful for pinning "Stripe-Version" to a known API version.
52 */
53 std::unordered_map<std::string, std::string> headers;
54};
55
56} // namespace stripekit
Async.h.
Definition Async.h:20
Per-call settings accepted by every client operation.
std::optional< std::string > idempotency_key
Makes the call safe to retry.
std::optional< std::chrono::milliseconds > timeout
Overrides the adapter's default timeout for this call.
std::unordered_map< std::string, std::string > headers
Extra HTTP headers, merged over the adapter's defaults.