Class: PaysecureApiDocumentationLive::CashierApIsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/paysecure_api_documentation_live/apis/cashier_ap_is_api.rb

Overview

CashierApIsApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from PaysecureApiDocumentationLive::BaseApi

Instance Method Details

#check_status_payinApiResponse

This endpoint retrieves the details of a session identified by the provided session ID.

Note that this API only respond once the SessionURL, received in the response for session API, is clicked.

Once the SessionURL is clicked and the user has selected a payment method and click on "Pay" button, a purchase is created on our backend. If you call this API before that, you will get an error.

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'lib/paysecure_api_documentation_live/apis/cashier_ap_is_api.rb', line 423

def check_status_payin
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/v1/purchases/{Session ID}',
                                 Server::SERVER_3)
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(M202Success.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             M400BadRequestException)
                .local_error('401',
                             'Unauthorized',
                             M401UnauthorizedException))
    .execute
end

#check_status_payoutApiResponse

This API tells you about all the details of a Payout, including its history

Mandatory

you need to pass the payoutId or session id in the API URL

Possible Value of Status

Status Notes
paid Transaction Successful
payout_in_process payout is under Processing.
error Transaction has Failed.

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/paysecure_api_documentation_live/apis/cashier_ap_is_api.rb', line 453

def check_status_payout
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/v1/getpayout/{Session ID}',
                                 Server::SERVER_3)
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Success29.method(:from_hash))
                .is_api_response(true))
    .execute
end

#customer(brand_id, body) ⇒ ApiResponse

OVERIEW The createCustomer API allows merchants to create a customer profile on PaySecure when a user visits their website, facilitating a seamless payment experience by pre-filling the customer's details, on the PaySecure Cashier. The API takes in customer information and returns a unique customerID that can be passed in purchase payload, eliminating the need for customers to manually enter their details during transactions.

Parameter Type Required Description Example
merchantCustomerId String Yes unique customer ID provided by
merchant. This can be email, mobile or an alphanumeric string

[rahultestcustomer@paysecure.net](https://mailto:rahultestcustomer@paysecu re.net) | | fullName | String | Yes | Full name of the customer. | Rahul Agarwal | | emailId | String | Yes | Email address of the customer. | test@paysecure.net | | dateOfBirth | String | Optional | Customer's date of birth in YYYY-MM-DD format. | 1995-12-27 | | phoneNo | String | Yes | Customer's phone number. Preferred with the country code | +91 797639082 | | city | String | Optional | City of the customer. | Jaipur | | stateCode | String | Yes | State code of the customer. | RJ | | zipCode | String | Optional | Postal code of the customer's location. | 302018 | | address | String | Optional | Full address of the customer. | House Number 53, Vaishali Nagar, Jaipur | | country | String | Yes | Country code (ISO 3166-1 alpha-2). | IN | | custRegDate | Sting | Optional | Customer registration date on merchant site in YYYY-MM-DD format. | 2023-12-27 | | successTxn | String | Optional | Number of successful transactions customer has carried on merchant site. | 32 |

User Flow

  1. Customer visits merchant's website: The customer selects the product or service and proceeds to checkout page.

  2. Merchant calls the createCustomer API: The merchant sends a POST request to the Paysecure API with the customer's details.

  3. Customer ID generation: Paysecure processes the request and generates a unique customerId which is returned in the response.

  4. Payment Process: The merchant uses the customerId for subsequent session creation, ensuring the customer doesn’t need to re-enter their details for future payments.


Benefits

  • Seamless user experience: The customer does not have to enter their details manually for every purchase.

  • Faster Checkout: The merchant can use the customerId for faster payment processing.

  • Data Security: Customer details are stored securely and can be reused across transactions, reducing the chances of errors.

Implementing createCustomer on merchant site:

The createCustomer can be implemented on merchant site in one of two ways, depending on merchant’s integration flow: At Checkout: When a customer initiates the checkout process, your system should invoke the createCustomer API, before actually starting the session.

  • Call createCustomer: This API call generates a unique customer ID.

  • Use of Customer ID: Pass the returned customer ID in Session API, when creating a payment session.

Upon Customer Login: Alternatively, merchants may choose to call createCustomer at the time of customer login on their site.

  • Persistent Customer Profiles: This approach can help build or maintain a persistent customer profile, ensuring the customer ID is available for any subsequent payment sessions without needing to call createCustomer again.

  • Integration Flexibility: This is useful for merchants who want to initialize customer data early in the customer journey rather than during checkout.

The method you choose depends on your business requirements and how your system is architected. Regardless of when you call it, the resulting customer ID must be passed to the createSession API to initiate a payment session. here

Parameters:

  • brand_id (String)

    Required parameter: TODO: type description here

  • body (CustomerRequest)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paysecure_api_documentation_live/apis/cashier_ap_is_api.rb', line 97

def customer(brand_id,
             body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/v1/customer',
                                 Server::SERVER_3)
               .header_param(new_parameter(brand_id, key: 'BrandId')
                              .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Success19.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             FailureException)
                .local_error('401',
                             'Unauthorized',
                             ExistingCustomerException))
    .execute
end

#customer1(brand_id, accept) ⇒ ApiResponse

This endpoint makes an HTTP GET request to retrieve customer information from the Paysecure API.

Request

The request does not include any query parameters, but it uses a raw request body with the following parameter "merchantCustomerId", which will be the customer id on the merchant's side.

Response

The response of this request can be documented as a JSON schema.

Parameters:

  • brand_id (String)

    Required parameter: TODO: type description here

  • accept (String)

    Required parameter: TODO: type description here

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/paysecure_api_documentation_live/apis/cashier_ap_is_api.rb', line 134

def customer1(brand_id,
              accept)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/customer',
                                 Server::SERVER_2)
               .header_param(new_parameter(brand_id, key: 'BrandId')
                              .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(accept, key: 'Accept')
                              .is_required(true)))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Success19.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             InvalidCustomerException))
    .execute
end

#customer2(brand_id, accept, body, paysecure_customer_id) ⇒ ApiResponse

Whenever a customer or the merchant updates customer details on the merchant site, a PATCH request must be made to synchronize these changes with Paysecure. This API endpoint allows you to update the customer details using an HTTP PATCH request. The request should be sent to [https://api.paysecure.net/api/v1/customerId/patchCustomer](https://api. paysecure.net/api/v1/%7BcustomerId%7D/patchCustomer).

Request Body

The request body should be in raw format and include the following parameters:

  • fullName (string): The full name of the customer.

  • emailId (string): The email address of the customer.

  • dateOfBirth (string): The date of birth of the customer.

  • phoneNo (string): The phone number of the customer.

  • city (string): The city of the customer.

  • stateCode (string): The state code of the customer.

  • zipCode (string): The zip code of the customer.

  • address (string): The address of the customer.

  • country (string): The country of the customer.

  • createdOn (string): Time when the customer was created.

  • custRegDate (string): Customer registration date (Non-Mandatory).

  • successTxn (string): Success transaction details (Non-Mandatory).

  • lastActivity (string): Time of the last activity.

  • lastUpdated (string): Time when the last patch was called.

  • extraParam (object): Additional parameters including param1, param2, param3, param4 with their respective values.

Response

The response will contain the updated customer details or a success message upon successful update. here description here

Parameters:

  • brand_id (String)

    Required parameter: TODO: type description here

  • accept (String)

    Required parameter: TODO: type description here

  • body (CustomerRequest1)

    Required parameter: TODO: type description

  • paysecure_customer_id (String)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paysecure_api_documentation_live/apis/cashier_ap_is_api.rb', line 206

def customer2(brand_id,
              accept,
              body,
              paysecure_customer_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/api/v1/{PaysecureCustomerId}/patchCustomer',
                                 Server::SERVER_3)
               .header_param(new_parameter(brand_id, key: 'BrandId')
                              .is_required(true))
               .header_param(new_parameter(accept, key: 'Accept')
                              .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .template_param(new_parameter(paysecure_customer_id, key: 'PaysecureCustomerId')
                                .is_required(true)
                                .should_encode(true))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Success19.method(:from_hash))
                .is_api_response(true))
    .execute
end

#payout_session(brand_id, accept, body) ⇒ ApiResponse

This API is used to initiate a payout session for a customer. By passing the customerId (generated via the createCustomer API) and specifying "type": "payout", a payout session is started. A sessionURL is returned in the response, which can be used to redirect the customer to the payout cashier. The customer can then select the payout method, pass required parameters, and the payout will be processed.

Parameters:

Parameter Type Description
customerId string The unique ID of the customer for whom the

payout session is created. This ID is generated by the createCustomer API. | | currency | string | The currency of the payout session (e.g., USD). | | products | array | A list of products associated with the payout (e.g., name and price). | | totalAmount | string | The total payout amount (optional. calculated dynamically if value is not passed). | | tax_amount | string | The tax amount to be applied (optional). | | tax_percent | string | The tax percentage to be applied (optional). | | type | string | Should be set to "payout" to initiate a payout session. | | success_redirect | string | The URL where the customer will be redirected after a successful payout. | | pending_redirect | string | The URL where the customer will be redirected after a pending payout. | | failure_redirect | string | The URL where the customer will be redirected after a failed payout attempt. | | success_callback | string | The callback URL for successful payout. | | failure_callback | string | The callback URL for failed payout. | | extraParam | object | Contains additional parameters for the payout session. | | extraParam.showCryptoConversion | string | Set to "yes" to display cryptocurrency conversion. | | extraParam.cryptoCurrencies | string | A list of accepted cryptocurrencies (e.g., BTC, ETH, USDT). |

Request Headers:

  • BrandId: Your unique brand ID (required).

  • Content-Type: application/json (required).

Response:

The API will return a JSON object containing the sessionURL that can be used to redirect the customer to the payout cashier.

{
    "sessionUrl":
"https://api.paysecure.net/payoutSession/68341ad35f895955355d5452/",
    "brandId": "brand_id_value",
    "customerId": "67c9983fba18400ab6cceb8f",
    "sessionId": "68341ad35f895955355d5452",
    "expiryOn": 1748246103,
    "createdOn": 1748245203
}

description here

Parameters:

  • brand_id (String)

    Required parameter: TODO: type description here

  • accept (String)

    Required parameter: TODO: type description here

  • body (PayoutSessionRequest)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/paysecure_api_documentation_live/apis/cashier_ap_is_api.rb', line 392

def payout_session(brand_id,
                   accept,
                   body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/v1/createSession',
                                 Server::SERVER_3)
               .header_param(new_parameter(brand_id, key: 'BrandId')
                              .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(accept, key: 'Accept')
                              .is_required(true))
               .body_param(new_parameter(body)
                            .is_required(true))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PayoutSession.method(:from_hash))
                .is_api_response(true))
    .execute
end

#purchase_session(brand_id, accept, body) ⇒ ApiResponse

OVERIEW The createSession API is designed to initiate a payment session for a customer after their profile has been created via the createCustomer API. The session is automatically generated at the backend on the merchant’s checkout URL. This session allows the customer to continue with their transaction without having to manually interact with the session URL, and ensures the session remains active until the payment is completed or the session expires. This API improves the user experience by reducing transaction failures and enhancing the overall payment process, thus reducing transaction churn rates.

Mandatory Parameters

Parameter Type Description Example
customerId String The unique ID of the customer (generated from
createCustomer). 6731a609b6bb5a43ad66c4a6

Show Crypto Conversion

Additionally, there are some default extra parameters that you can pass for allowing Crypto Conversion on Paysecure's cashier itself.

Type Description Example
extraParam.showCryptoConversion String This optional parameter

allows customer to see crypto value equivelant to the Fiat amount the customer is planning to pay. | Yes | | extraParam.cryptoCurrencies | String | Pass here the allowed crypto tokens on the cashier, where customer can see the the conversion value | [\"BTC\",\"ETH\",\"USDT\",\"XRP\",\"LTC\",\"DOGE\",\"ETC\", \"BNB\",\"USDC\",\"SOL\",\"ADA\",\"BCH\",\"DASH\",\"BTG\",\
"ZEC\",\"DGB\",\"EOS\",\"XLM\",\"TRX\",\"QTUM\",\"POL\",\"SH IB\",\"LINK\",\"DAI\",\"TON\",\"AVAX\",\"FDUSD\",\"ARB\",\"O P\"] |

Usage Flow

  1. Customer completes the createCustomer API: Once the customer is created via the createCustomer API, the merchant proceeds to call the createSession API to generate a session.

  2. Merchant sends createSession request: The merchant sends a POST request to the createSession API with the customer’s customerId and the merchant’s brandId.

  3. Session created automatically on the checkout URL: PaySecure creates the session and associates it with the merchant’s checkout page. This session remains active on the backend, allowing the customer to continue the payment process without interruption.

  4. Customer proceeds to checkout: The customer is redirected to the checkout page as part of the merchant's payment flow, where the session is automatically validated. The session remains active for a set period, allowing the customer to complete the payment without needing to manually interact with the session URL.

  5. Session Expiry: The session expires after the set expiration time (expiryOn), ensuring the payment process is completed within the defined window. Default is 15 mins from the creation time.


Benefits

  • Seamless Checkout: The session URL is automatically generated and active at the backend, ensuring a smoother and uninterrupted customer experience.

  • Reduced Transaction Failures: By ensuring the session remains active during the payment process, the chances of transaction failures due to session timeouts are minimized.

  • Improved User Experience: The customer does not need to click on a session URL or navigate away from the page, leading to faster and more secure payment processing. description here

Parameters:

  • brand_id (String)

    Required parameter: TODO: type description here

  • accept (String)

    Required parameter: TODO: type description here

  • body (PurchaseSessionRequest)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/paysecure_api_documentation_live/apis/cashier_ap_is_api.rb', line 305

def purchase_session(brand_id,
                     accept,
                     body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/v1/createSession',
                                 Server::SERVER_3)
               .header_param(new_parameter(brand_id, key: 'BrandId')
                              .is_required(true))
               .header_param(new_parameter(accept, key: 'Accept')
                              .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Success14.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             InvalidSessionException))
    .execute
end