Struct PrimerClient

Source
pub struct PrimerClient { /* private fields */ }

Implementations§

Source§

impl PrimerClient

Source

pub fn from_env() -> Self

Source§

impl PrimerClient

Source

pub fn new(url: &str, authentication: PrimerAuthentication) -> Self

Source

pub fn with_authentication(self, authentication: PrimerAuthentication) -> Self

Source

pub fn authenticate<'a>(&self, r: RequestBuilder<'a>) -> RequestBuilder<'a>

Source

pub fn with_middleware<M: Middleware + 'static>(self, middleware: M) -> Self

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_payment_by_id_payments_id_get( &self, id: &str, ) -> GetPaymentByIdPaymentsIdGetRequest<'_>

Get a payment

Retrieve a payment by its ID.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more