1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
//! The API's operations, grouped by resource.
//!
//! [`operation_table!`] is the single list of every operation: its group, method name,
//! request and response types, and documentation. Other code is generated from it by
//! passing a callback macro, so the clients' methods and the request-response pairing
//! cannot drift apart.
/// Invokes `$callback!` with the operation table, preceded by `[args]`.
///
/// The table is a list of groups:
///
/// ```text
/// group_method => HandleType {
/// /// docs
/// method(RequestType) -> ResponseType;
/// }
/// ```
macro_rules! operation_table {
($callback:ident $(, $arg:tt)*) => {
$callback! {
[$($arg),*]
account_updater_jobs => AccountUpdaterJobs {
/// Details of each card updated or deleted by the Account Updater
/// process in a month, up to 1000 per request; use paging for more.
get_details(GetAuJobDetailsRequest) -> GetAuJobDetailsResponse;
/// A summary of the Account Updater process's results for a month.
get_summary(GetAuJobSummaryRequest) -> GetAuJobSummaryResponse;
}
batches => Batches {
/// Statistics for a single batch.
get_statistics(GetBatchStatisticsRequest) -> GetBatchStatisticsResponse;
/// Settled batches in a date range (by default the last 24 hours),
/// optionally with statistics.
list_settled(GetSettledBatchListRequest) -> GetSettledBatchListResponse;
}
customer_profiles => CustomerProfiles {
/// Creates a customer profile, with any payment profiles and shipping
/// addresses.
create(CreateCustomerProfileRequest) -> CreateCustomerProfileResponse;
/// Creates a customer profile, payment profile and shipping address from
/// an existing successful transaction.
create_from_transaction(CreateCustomerProfileFromTransactionRequest) -> CreateCustomerProfileResponse;
/// Charges, refunds or voids using a stored customer profile.
create_transaction(CreateCustomerProfileTransactionRequest) -> CreateCustomerProfileTransactionResponse;
/// Deletes a customer profile with all its payment profiles and shipping
/// addresses.
delete(DeleteCustomerProfileRequest) -> DeleteCustomerProfileResponse;
/// A customer profile with its payment profiles and shipping addresses.
get(GetCustomerProfileRequest) -> GetCustomerProfileResponse;
/// The ids of every customer profile.
get_ids(GetCustomerProfileIdsRequest) -> GetCustomerProfileIdsResponse;
/// Updates a customer profile.
update(UpdateCustomerProfileRequest) -> UpdateCustomerProfileResponse;
}
customer_payment_profiles => CustomerPaymentProfiles {
/// Adds a payment profile to a customer profile.
create(CreateCustomerPaymentProfileRequest) -> CreateCustomerPaymentProfileResponse;
/// Deletes a payment profile from a customer profile.
delete(DeleteCustomerPaymentProfileRequest) -> DeleteCustomerPaymentProfileResponse;
/// A payment profile of a customer profile.
get(GetCustomerPaymentProfileRequest) -> GetCustomerPaymentProfileResponse;
/// A payment nonce for a payment profile.
get_nonce(GetCustomerPaymentProfileNonceRequest) -> GetCustomerPaymentProfileNonceResponse;
/// Payment profiles matching a search, such as cards expiring this month;
/// 10 per request, with paging for more.
list(GetCustomerPaymentProfileListRequest) -> GetCustomerPaymentProfileListResponse;
/// Updates a payment profile.
update(UpdateCustomerPaymentProfileRequest) -> UpdateCustomerPaymentProfileResponse;
/// Verifies a payment profile with a test transaction. No receipt email
/// is sent.
validate(ValidateCustomerPaymentProfileRequest) -> ValidateCustomerPaymentProfileResponse;
}
customer_shipping_addresses => CustomerShippingAddresses {
/// Adds a shipping address to a customer profile.
create(CreateCustomerShippingAddressRequest) -> CreateCustomerShippingAddressResponse;
/// Deletes a shipping address from a customer profile.
delete(DeleteCustomerShippingAddressRequest) -> DeleteCustomerShippingAddressResponse;
/// A shipping address of a customer profile.
get(GetCustomerShippingAddressRequest) -> GetCustomerShippingAddressResponse;
/// Updates a shipping address.
update(UpdateCustomerShippingAddressRequest) -> UpdateCustomerShippingAddressResponse;
}
hosted_pages => HostedPages {
/// A form token for the Accept Hosted payment page.
get_payment_page(GetHostedPaymentPageRequest) -> GetHostedPaymentPageResponse;
/// A token for the hosted customer profile page.
get_profile_page(GetHostedProfilePageRequest) -> GetHostedProfilePageResponse;
}
merchants => Merchants {
/// Merchant details, useful for OAuth and Accept integrations.
get(GetMerchantDetailsRequest) -> GetMerchantDetailsResponse;
/// Updates merchant details.
update(UpdateMerchantDetailsRequest) -> UpdateMerchantDetailsResponse;
}
misc => Misc {
/// Decrypts payment data, such as a Visa Checkout payload.
decrypt_payment_data(DecryptPaymentDataRequest) -> DecryptPaymentDataResponse;
/// Checks that the API is available. Sent without credentials.
is_alive(IsAliveRequest) -> IsAliveResponse;
/// Ends a mobile device session.
logout(LogoutRequest) -> LogoutResponse;
/// Checks that the credentials are valid.
test_authenticate(AuthenticateTestRequest) -> AuthenticateTestResponse;
}
mobile_devices => MobileDevices {
/// The Acceptance Device serial number for a merchant and mobile device.
get_acceptance_device(GetAdDetailsRequest) -> GetAdDetailsResponse;
/// Requests a PIN for mobile device login.
login_pin(MobileDeviceLoginPinRequest) -> MobileDeviceLoginPinResponse;
/// Verifies a login challenge.
login_verify_challenge(MobileDeviceLoginVerifyChallengeRequest) -> MobileDeviceLoginVerifyChallengeResponse;
/// Verifies a login PIN.
login_verify_pin(MobileDeviceLoginVerifyPinRequest) -> MobileDeviceLoginVerifyPinResponse;
/// Logs in a mobile device with multi-factor authentication.
mfa_login(MobileDeviceMfaLoginRequest) -> MobileDeviceMfaLoginResponse;
/// Registers a mobile device.
register(MobileDeviceRegistrationRequest) -> MobileDeviceRegistrationResponse;
/// Saves the Acceptance Device serial number for a merchant and mobile
/// device.
save_acceptance_device(SaveDeviceSnRequest) -> SaveDeviceSnResponse;
}
secure_payment_containers => SecurePaymentContainers {
/// Creates a secure payment container, returning opaque payment data.
create(SecurePaymentContainerRequest) -> SecurePaymentContainerResponse;
}
subscriptions => Subscriptions {
/// Cancels a subscription.
cancel(ArbCancelSubscriptionRequest) -> ArbCancelSubscriptionResponse;
/// Creates a recurring billing subscription.
create(ArbCreateSubscriptionRequest) -> ArbCreateSubscriptionResponse;
/// A subscription.
get(ArbGetSubscriptionRequest) -> ArbGetSubscriptionResponse;
/// A subscription's status.
get_status(ArbGetSubscriptionStatusRequest) -> ArbGetSubscriptionStatusResponse;
/// Subscriptions matching a search.
list(ArbGetSubscriptionListRequest) -> ArbGetSubscriptionListResponse;
/// Updates a subscription.
update(ArbUpdateSubscriptionRequest) -> ArbUpdateSubscriptionResponse;
}
transactions => Transactions {
/// Creates a transaction: authorize, capture, charge, refund, void, ...
create(CreateTransactionRequest) -> CreateTransactionResponse;
/// The details of a transaction.
get(GetTransactionDetailsRequest) -> GetTransactionDetailsResponse;
/// A lightweight summary of a transaction.
get_summary(GetTransactionSummaryRequest) -> GetTransactionSummaryResponse;
/// The transactions in a batch, up to 1000 per request; use paging for
/// more.
list(GetTransactionListRequest) -> GetTransactionListResponse;
/// The transactions of a customer profile or payment profile, up to 1000
/// per request; use paging for more.
list_for_customer(GetTransactionListForCustomerRequest) -> GetTransactionListResponse;
/// Unsettled transactions, up to 1000 per request; use paging for more.
list_unsettled(GetUnsettledTransactionListRequest) -> GetUnsettledTransactionListResponse;
/// Emails a receipt for a transaction to the customer.
send_receipt(SendCustomerTransactionReceiptRequest) -> SendCustomerTransactionReceiptResponse;
/// Approves or declines a held transaction.
update_held(UpdateHeldTransactionRequest) -> UpdateHeldTransactionResponse;
/// Updates the status of an order made of several transactions with the
/// same split tender id.
update_split_tender_group(UpdateSplitTenderGroupRequest) -> UpdateSplitTenderGroupResponse;
}
}
};
}
pub(crate) use operation_table;
/// Implements `ApiRequest` for each request in the table.
macro_rules! impl_api_requests {
([] $(
$group:ident => $handle:ident {
$(
$(#[$doc:meta])*
$method:ident($request:ident) -> $response:ident;
)*
}
)*) => {
$($(
impl $crate::api::ApiRequest for $crate::schema::$request {
type Response = $crate::schema::$response;
const OPERATION: &'static str = concat!(stringify!($group), ".", stringify!($method));
}
)*)*
};
}
operation_table!(impl_api_requests);
/// A client's resource handles and its methods returning them, one per group.
///
/// Arguments: `[Client, Transport, async]` or `[Client, Transport, blocking]`, where
/// `Client<T>` has an `execute` method for any `T: Transport`.
macro_rules! resource_handles {
(
[$client:ident, $transport:path, $mode:ident]
$(
$group:ident => $handle:ident {
$(
$(#[$doc:meta])*
$method:ident($request:ident) -> $response:ident;
)*
}
)*
) => {
impl<T: $transport> $client<T> {
$(
#[doc = concat!("The `", stringify!($group), "` operations.")]
pub fn $group(&self) -> $handle<'_, T> {
$handle { client: self }
}
)*
}
$(
#[doc = concat!(
"The `", stringify!($group), "` operations, from [`", stringify!($client),
"::", stringify!($group), "`]."
)]
pub struct $handle<'a, T> {
client: &'a $client<T>,
}
impl<T> Clone for $handle<'_, T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for $handle<'_, T> {}
impl<T> ::core::fmt::Debug for $handle<'_, T> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct(stringify!($handle)).finish_non_exhaustive()
}
}
impl<T: $transport> $handle<'_, T> {
$(
resource_handles!(@method $mode $method $request $response $(#[$doc])*);
)*
}
)*
};
(@method $mode:ident $method:ident $request:ident $response:ident $(#[$doc:meta])*) => {
resource_handles!(@sig $mode $method $request $response
$(#[$doc])*
#[doc = ""]
#[doc = concat!(
"Sends a [`", stringify!($request), "`](crate::schema::", stringify!($request),
") and returns its [`", stringify!($response), "`](crate::schema::",
stringify!($response), ")."
)]
);
};
(@sig async $method:ident $request:ident $response:ident $(#[$doc:meta])*) => {
$(#[$doc])*
pub async fn $method(
&self,
request: &$crate::schema::$request,
) -> ::core::result::Result<$crate::schema::$response, $crate::Error> {
self.client.execute(request).await
}
};
(@sig blocking $method:ident $request:ident $response:ident $(#[$doc:meta])*) => {
$(#[$doc])*
pub fn $method(
&self,
request: &$crate::schema::$request,
) -> ::core::result::Result<$crate::schema::$response, $crate::Error> {
self.client.execute(request)
}
};
}
pub(crate) use resource_handles;