Class: PaysecureApiDocumentationLive::MPaypalWalletApi

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

Overview

MPaypalWalletApi

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

#purchase(body) ⇒ ApiResponse

To Initiate a payment, the very first call to make is /purchases with the required data in the request body. To generate a Purchase, you are required to provide the Brand ID (in the request body) and API key (in the header) Both can be located in the Dashboard section of your merchant account login. The request body structure is shown on the request body of the example request shown here. The following (see table below) are the mandatory parameters that are required to create a purchase request.

Mandatory parameters in the request body:

Parameter Notes
client.email The customer's email.
client.city The customer's city.
client.country ISO-3166 Country Code. Must be upper case. Example “SG”
(Alpha2)
client.stateCode Example “AL”, “XZ”. Must be in upper case.
Client.street_address The customer's address.
client.zip_code The customer's ZIP or postal code. If country=US, zip
format must be NNNNN or NNNNN-NNNN.
purchase.currency ISO 4217 code for currency you want to send the

transaction in.

Please note, the currency has to be enabled by the account manager for your account. | | purchase.products | An object which contains the list of products which the customer is buying. | | purchase.products.name | The name of the product. | | purchase.products.price | Price in decimal format.
example 1:
EUR 5 , should be sent as 5.00

example 2:
USD 10 and 37 cents , should be sent as 10.37 | | brand_id | Obtain from Dashboard section of your merchant account login. | | success_redirect | URL to send the user if the transactions is successful. | | pending_redirect | URL to send the user if the transactions is in pending. | | failure_redirect | URL to send the user if the transactions is unsuccessful. |

Essential Optional Parameters

merchantRef

The merchantRef parameter, although not mandatory, is strongly advised for merchants to specify. Its inclusion offers two significant advantages for the merchant:

  1. Prevention of Duplicate Requests: When a merchantRef is utilized, it acts as a unique identifier. This means that if a second purchase request is made using the same merchantRef (reference number), the system will recognize it and prevent duplicate transactions from occurring. This prevents unintended or duplicate purchases.

  2. Facilitation of Transaction Retrieval: In situations where the response from the initial purchase request times out or the 'purchaseId' isn't received, having the merchantRef allows the merchant to retrieve detailed transaction information. This ensures they can track and access the specific purchase details related to that reference, even if the immediate response was not received.

However, if the merchant does not specify the 'merchantRef' parameter, the platform will automatically assign and use an internal 'purchaseId' as a reference for that transaction. Upon successul create on a Purchase you'd get a "purchaseId" . Use this ID for the next step in Server to server call by calling p/{purchaseId}/?s2s=true .

paymentMethod

The paymentMethod parameter identifies which payment solution merchant wants to use to perform a transaction. If parameter is provided, than Paysecure will perform direct payment with the selected payment method instead of loading Paysecure URL.

Errors

If there are any errors then it'll be in the format of :

{
    "message": "descriptive error message",
    "code": "error_code"
}

Possible Error Messages

| Error Messages | | --- | | Allowed Limit for this card for particular time period has been consumed | | some Mandatory Parameter are missing | | Invalid format of Date_of_Birth [allowed format: yyyy-mm-dd] | | Invalid Email Format | | Please submit Valid Alpha2 Country Code Ex:(AF,IN) in \"country\" parameter | | Please pass Valid State Code | | Please pass valid street address in \"street_address\" parameter | | Please pass valid city name in \"city\" parameter | | Please pass valid postal Code name in \"zip_code\" parameter | | You are not Allowed for Live Transaction | | Merchant Limit is not set | | Minimum amount is not set for this merchant | | Brand not found ! | | Your charges setting is incomplete .Plese Contact to Administrator. | | Only {currencyCode} currency is allowed. | | Transaction amount must be equal or greater to minimum trans amount | | Invalid_Parameter
You'd usually get it when one or more mandatory parameters are not present in the request. | here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/paysecure_api_documentation_live/apis/m_paypal_wallet_api.rb', line 109

def purchase(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/v1/purchases',
                                 Server::SERVER_3)
               .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(:deserialize_primitive_types))
                .deserialize_into(proc do |response| response&.to_s end)
                .is_api_response(true)
                .is_primitive_response(true))
    .execute
end