pub struct PrimerClient { /* private fields */ }
Implementations§
Source§impl PrimerClient
impl PrimerClient
Source§impl PrimerClient
impl PrimerClient
pub fn new(url: &str, authentication: PrimerAuthentication) -> Self
pub fn with_authentication(self, authentication: PrimerAuthentication) -> Self
pub fn authenticate<'a>(&self, r: RequestBuilder<'a>) -> RequestBuilder<'a>
pub fn with_middleware<M: Middleware + 'static>(self, middleware: M) -> Self
Sourcepub fn retrieve_client_side_token_client_session_get(
&self,
) -> RetrieveClientSideTokenClientSessionGetRequest<'_>
pub fn retrieve_client_side_token_client_session_get( &self, ) -> RetrieveClientSideTokenClientSessionGetRequest<'_>
Retrieve a client session
This API call retrieves all the details associated with the client session corresponding to the client token that is provided in the request. The fields with empty values are excluded from the response.
Sourcepub fn create_client_side_token_client_session_post(
&self,
args: CreateClientSideTokenClientSessionPostRequired<'_>,
) -> CreateClientSideTokenClientSessionPostRequest<'_>
pub fn create_client_side_token_client_session_post( &self, args: CreateClientSideTokenClientSessionPostRequired<'_>, ) -> CreateClientSideTokenClientSessionPostRequest<'_>
Create a client session
Creating a client session generates a client token: a temporary key used to initialize Universal Checkout and authenticate it against your account.
Universal Checkout automatically retrieves all the settings from the client session and the Dashboard to configure the payment methods and the checkout experience.
Note:
When creating a Client Session, please make sure to provide currencyCode
, orderId
, and at least one of amount
or lineItems
.
If any of these are not yet available, you can provide them when making the payment request.
POST /client-session
does not have required fields as all fields are not always known when a client session is created.
Use PATCH /client-session
to update the parameters throughout the checkout session.
Client tokens expire after 24 hours.
Sourcepub fn update_client_side_token_client_session_patch(
&self,
args: UpdateClientSideTokenClientSessionPatchRequired<'_>,
) -> UpdateClientSideTokenClientSessionPatchRequest<'_>
pub fn update_client_side_token_client_session_patch( &self, args: UpdateClientSideTokenClientSessionPatchRequired<'_>, ) -> UpdateClientSideTokenClientSessionPatchRequest<'_>
Update client session
You can update a clients session created earlier with the PATCH /client-session
API call.
The only required field for the request is clientToken
. Other supported request fields are same as for the POST /client-session
API call.
You need to specify only the fields you wish to update. However, if the items that are to be updated are of type array
, then you need to provide the complete array along with modified items.
If you wish to update nested fields on the client session, such as the customer emailAddress
field, you can pass the customer
object with only one field, emailAddress
, to update.
If you simply wish to clear the value of the field, pass null
as your input.
You can update paymentMethod.vaultOnSuccess
field but updating of the paymentMethod.options
field through PATCH /client-session
is not supported.
The response will contain all the fields of the client session including the ones that were changed.
Sourcepub fn list_payments_payments_get(&self) -> ListPaymentsPaymentsGetRequest<'_>
pub fn list_payments_payments_get(&self) -> ListPaymentsPaymentsGetRequest<'_>
Search & list payments
Retrieve a list of your payments.
Results are paginated, they will only return up to 100 payments maximum.
To access the next page of result, set the cursor
query parameter to the value of nextCursor
in
your current result payload. Use prevCursor
to go back to the previous page.
Note: this endpoint returns a list of
summarized payments. Not all payments attributes are present. You can use
the query parameters to filter payments. You can separate multiple query parameters with the &
symbol.
Query parameters with types of the form “Array of strings” (such as the status parameter) can be specified as a comma-separated list.
For example, if you wanted to get both FAILED
and CANCELLED
payments, for customer john-123
, you would use:
curl --location --request GET 'https://api.primer.io/payments?status=FAILED,CANCELLED&customer_id=john-123' \
--header 'X-Api-Key: <YOUR_API_KEY>'
You can alternatively specify a list by repeating the parameter multiple times.
Note: payments will be available within a minute from being created.
Sourcepub fn create_payment_payments_post(
&self,
payment_method_token: &str,
) -> CreatePaymentPaymentsPostRequest<'_>
pub fn create_payment_payments_post( &self, payment_method_token: &str, ) -> CreatePaymentPaymentsPostRequest<'_>
Create a payment
Create and authorize a payment for a given customer order. You should provide a payment method token here to avoid PCI implications.
If only a payment method token is passed, the values passed with the Client Session is used to determine the amount, currency etc.
Note: amount
, currencyCode
and orderId
are required during payment creation. Make sure to pass these fields when creating a client session, or if not yet available, when creating a payment.
All fields provided on this request will take preference over any field on the order
associated with the client session. E.g. if you pass amount
on this request, it will override the amount
on the order
associated with the Client Session.
Sourcepub fn capture_payment_payments_id_capture_post(
&self,
id: &str,
amount: Value,
final_: bool,
) -> CapturePaymentPaymentsIdCapturePostRequest<'_>
pub fn capture_payment_payments_id_capture_post( &self, id: &str, amount: Value, final_: bool, ) -> CapturePaymentPaymentsIdCapturePostRequest<'_>
Capture a payment
If you have successfully authorized a payment, you can now
fully capture, or partially capture funds from the authorized payment, depending
on whether your selected payment processor supports it. The payment will
be updated to SETTLED
or SETTLING
, depending on the payment method type.
The payload sent in this capture request is completely optional. If you don’t send a payload with the capture request, the full amount that was authorized will be sent for capture. Below are the available payload attributes, which give you more granular control when capturing funds, if you require it.
Sourcepub fn cancel_payment_payments_id_cancel_post(
&self,
id: &str,
reason: &str,
) -> CancelPaymentPaymentsIdCancelPostRequest<'_>
pub fn cancel_payment_payments_id_cancel_post( &self, id: &str, reason: &str, ) -> CancelPaymentPaymentsIdCancelPostRequest<'_>
Cancel a payment
Provided the payment has not reached SETTLED
status, Primer will
send a “void” request to the payment processor, thereby cancelling the payment
and releasing the hold on customer funds. Upon success, the payment will transition
to CANCELLED
. The payload is optional.
Sourcepub fn refund_payment_payments_id_refund_post(
&self,
args: RefundPaymentPaymentsIdRefundPostRequired<'_>,
) -> RefundPaymentPaymentsIdRefundPostRequest<'_>
pub fn refund_payment_payments_id_refund_post( &self, args: RefundPaymentPaymentsIdRefundPostRequired<'_>, ) -> RefundPaymentPaymentsIdRefundPostRequest<'_>
Refund a payment
By default, this request will refund the full amount.
Optionally, pass in a lesser amount for a partial refund.
Sourcepub fn resume_payment_payments_id_resume_post(
&self,
id: &str,
resume_token: &str,
) -> ResumePaymentPaymentsIdResumePostRequest<'_>
pub fn resume_payment_payments_id_resume_post( &self, id: &str, resume_token: &str, ) -> ResumePaymentPaymentsIdResumePostRequest<'_>
Resume a payment
Resume a payment’s workflow execution from a paused state. This is usually required when a Workflow was paused in order to get further information from the customer, or when waiting for an asynchronous response from a third party connection.
Sourcepub fn get_payment_by_id_payments_id_get(
&self,
id: &str,
) -> GetPaymentByIdPaymentsIdGetRequest<'_>
pub fn get_payment_by_id_payments_id_get( &self, id: &str, ) -> GetPaymentByIdPaymentsIdGetRequest<'_>
Get a payment
Retrieve a payment by its ID.
Sourcepub fn vault_payment_method_payment_methods_token_vault_post(
&self,
payment_method_token: &str,
customer_id: &str,
) -> VaultPaymentMethodPaymentMethodsTokenVaultPostRequest<'_>
pub fn vault_payment_method_payment_methods_token_vault_post( &self, payment_method_token: &str, customer_id: &str, ) -> VaultPaymentMethodPaymentMethodsTokenVaultPostRequest<'_>
Save a payment method token
Save a SINGLE_USE
payment method token so it can be used
again later. You can optionally choose to verify the payment method
before vaulting. If verification fails, no payment method data will
be vaulted. Verification can minimise fraud and boost subscription
rates for recurring payments.
If you try to vault an already vaulted token, you will get the existing vaulted token back.
Sourcepub fn get_payment_methods_payment_methods_get(
&self,
customer_id: &str,
) -> GetPaymentMethodsPaymentMethodsGetRequest<'_>
pub fn get_payment_methods_payment_methods_get( &self, customer_id: &str, ) -> GetPaymentMethodsPaymentMethodsGetRequest<'_>
List saved payment methods
Retrieve a list of stored payment methods for a customer.
Sourcepub fn delete_payment_method_payment_methods_token_delete(
&self,
payment_method_token: &str,
) -> DeletePaymentMethodPaymentMethodsTokenDeleteRequest<'_>
pub fn delete_payment_method_payment_methods_token_delete( &self, payment_method_token: &str, ) -> DeletePaymentMethodPaymentMethodsTokenDeleteRequest<'_>
Delete a saved payment method
Delete a saved payment method.
Sourcepub fn set_payment_method_default_payment_methods_token_default_post(
&self,
payment_method_token: &str,
) -> SetPaymentMethodDefaultPaymentMethodsTokenDefaultPostRequest<'_>
pub fn set_payment_method_default_payment_methods_token_default_post( &self, payment_method_token: &str, ) -> SetPaymentMethodDefaultPaymentMethodsTokenDefaultPostRequest<'_>
Update the default saved payment method
Update a saved payment method to be the default stored payment method for a customer.