UNPKG

square-connect

Version:

JavaScript client library for the Square Connect v2 API

323 lines (278 loc) 12.7 kB
/** * Square Connect API * Client library for accessing the Square Connect APIs * * OpenAPI spec version: 2.0 * Contact: developers@squareup.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * * Swagger Codegen version: 2.3.0-SNAPSHOT * */ var ApiClient = require('../ApiClient'); var Address = require('./Address'); var CardPaymentDetails = require('./CardPaymentDetails'); var Money = require('./Money'); var ProcessingFee = require('./ProcessingFee'); var RiskEvaluation = require('./RiskEvaluation'); /** * The Payment model module. * @module model/Payment */ /** * Constructs a new <code>Payment</code>. * Represents a payment processed by the Square API. * @alias module:model/Payment * @class */ var exports = function() { var _this = this; }; /** * Constructs a <code>Payment</code> from a plain JavaScript object, optionally creating a new instance. * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not. * @param {Object} data The plain JavaScript object bearing properties of interest. * @param {module:model/Payment} obj Optional instance to populate. * @return {module:model/Payment} The populated <code>Payment</code> instance. */ exports.constructFromObject = function(data, obj) { if (data) { obj = obj || new exports(); if (data.hasOwnProperty('id')) { obj['id'] = ApiClient.convertToType(data['id'], 'String'); } if (data.hasOwnProperty('created_at')) { obj['created_at'] = ApiClient.convertToType(data['created_at'], 'String'); } if (data.hasOwnProperty('updated_at')) { obj['updated_at'] = ApiClient.convertToType(data['updated_at'], 'String'); } if (data.hasOwnProperty('amount_money')) { obj['amount_money'] = Money.constructFromObject(data['amount_money']); } if (data.hasOwnProperty('tip_money')) { obj['tip_money'] = Money.constructFromObject(data['tip_money']); } if (data.hasOwnProperty('total_money')) { obj['total_money'] = Money.constructFromObject(data['total_money']); } if (data.hasOwnProperty('app_fee_money')) { obj['app_fee_money'] = Money.constructFromObject(data['app_fee_money']); } if (data.hasOwnProperty('processing_fee')) { obj['processing_fee'] = ApiClient.convertToType(data['processing_fee'], [ProcessingFee]); } if (data.hasOwnProperty('refunded_money')) { obj['refunded_money'] = Money.constructFromObject(data['refunded_money']); } if (data.hasOwnProperty('status')) { obj['status'] = ApiClient.convertToType(data['status'], 'String'); } if (data.hasOwnProperty('delay_duration')) { obj['delay_duration'] = ApiClient.convertToType(data['delay_duration'], 'String'); } if (data.hasOwnProperty('delay_action')) { obj['delay_action'] = ApiClient.convertToType(data['delay_action'], 'String'); } if (data.hasOwnProperty('delayed_until')) { obj['delayed_until'] = ApiClient.convertToType(data['delayed_until'], 'String'); } if (data.hasOwnProperty('source_type')) { obj['source_type'] = ApiClient.convertToType(data['source_type'], 'String'); } if (data.hasOwnProperty('card_details')) { obj['card_details'] = CardPaymentDetails.constructFromObject(data['card_details']); } if (data.hasOwnProperty('location_id')) { obj['location_id'] = ApiClient.convertToType(data['location_id'], 'String'); } if (data.hasOwnProperty('order_id')) { obj['order_id'] = ApiClient.convertToType(data['order_id'], 'String'); } if (data.hasOwnProperty('reference_id')) { obj['reference_id'] = ApiClient.convertToType(data['reference_id'], 'String'); } if (data.hasOwnProperty('customer_id')) { obj['customer_id'] = ApiClient.convertToType(data['customer_id'], 'String'); } if (data.hasOwnProperty('employee_id')) { obj['employee_id'] = ApiClient.convertToType(data['employee_id'], 'String'); } if (data.hasOwnProperty('refund_ids')) { obj['refund_ids'] = ApiClient.convertToType(data['refund_ids'], ['String']); } if (data.hasOwnProperty('risk_evaluation')) { obj['risk_evaluation'] = RiskEvaluation.constructFromObject(data['risk_evaluation']); } if (data.hasOwnProperty('buyer_email_address')) { obj['buyer_email_address'] = ApiClient.convertToType(data['buyer_email_address'], 'String'); } if (data.hasOwnProperty('billing_address')) { obj['billing_address'] = Address.constructFromObject(data['billing_address']); } if (data.hasOwnProperty('shipping_address')) { obj['shipping_address'] = Address.constructFromObject(data['shipping_address']); } if (data.hasOwnProperty('note')) { obj['note'] = ApiClient.convertToType(data['note'], 'String'); } if (data.hasOwnProperty('statement_description_identifier')) { obj['statement_description_identifier'] = ApiClient.convertToType(data['statement_description_identifier'], 'String'); } if (data.hasOwnProperty('receipt_number')) { obj['receipt_number'] = ApiClient.convertToType(data['receipt_number'], 'String'); } if (data.hasOwnProperty('receipt_url')) { obj['receipt_url'] = ApiClient.convertToType(data['receipt_url'], 'String'); } } return obj; } /** * A unique ID for the payment. * @member {String} id */ exports.prototype['id'] = undefined; /** * The timestamp of when the payment was created, in RFC 3339 format. * @member {String} created_at */ exports.prototype['created_at'] = undefined; /** * The timestamp of when the payment was last updated, in RFC 3339 format. * @member {String} updated_at */ exports.prototype['updated_at'] = undefined; /** * The amount processed for this payment, not including `tip_money`. The amount is specified in the smallest denomination of the applicable currency (for example, US dollar amounts are specified in cents). For more information, see [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). * @member {module:model/Money} amount_money */ exports.prototype['amount_money'] = undefined; /** * The amount designated as a tip. This amount is specified in the smallest denomination of the applicable currency (for example, US dollar amounts are specified in cents). For more information, see [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). * @member {module:model/Money} tip_money */ exports.prototype['tip_money'] = undefined; /** * The total amount for the payment, including `amount_money` and `tip_money`. This amount is specified in the smallest denomination of the applicable currency (for example, US dollar amounts are specified in cents). For more information, see [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). * @member {module:model/Money} total_money */ exports.prototype['total_money'] = undefined; /** * The amount the developer is taking as a fee for facilitating the payment on behalf of the seller. This amount is specified in the smallest denomination of the applicable currency (for example, US dollar amounts are specified in cents). For more information, see [Take Payments and Collect Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees). The amount cannot be more than 90% of the `total_money` value. * @member {module:model/Money} app_fee_money */ exports.prototype['app_fee_money'] = undefined; /** * The processing fees and fee adjustments assessed by Square for this payment. * @member {Array.<module:model/ProcessingFee>} processing_fee */ exports.prototype['processing_fee'] = undefined; /** * The total amount of the payment refunded to date. This amount is specified in the smallest denomination of the applicable currency (for example, US dollar amounts are specified in cents). * @member {module:model/Money} refunded_money */ exports.prototype['refunded_money'] = undefined; /** * Indicates whether the payment is APPROVED, COMPLETED, CANCELED, or FAILED. * @member {String} status */ exports.prototype['status'] = undefined; /** * The duration of time after the payment's creation when Square automatically applies the `delay_action` to the payment. This automatic `delay_action` applies only to payments that do not reach a terminal state (COMPLETED, CANCELED, or FAILED) before the `delay_duration` time period. This field is specified as a time duration, in RFC 3339 format. Notes: This feature is only supported for card payments. Default: - Card-present payments: \"PT36H\" (36 hours) from the creation time. - Card-not-present payments: \"P7D\" (7 days) from the creation time. * @member {String} delay_duration */ exports.prototype['delay_duration'] = undefined; /** * The action to be applied to the payment when the `delay_duration` has elapsed. This field is read-only. Current values include `CANCEL`. * @member {String} delay_action */ exports.prototype['delay_action'] = undefined; /** * The read-only timestamp of when the `delay_action` is automatically applied, in RFC 3339 format. Note that this field is calculated by summing the payment's `delay_duration` and `created_at` fields. The `created_at` field is generated by Square and might not exactly match the time on your local machine. * @member {String} delayed_until */ exports.prototype['delayed_until'] = undefined; /** * The source type for this payment. Current values include `CARD`. * @member {String} source_type */ exports.prototype['source_type'] = undefined; /** * Non-confidential details about the source. The details are only populated if the `source_type` is `CARD`. * @member {module:model/CardPaymentDetails} card_details */ exports.prototype['card_details'] = undefined; /** * The ID of the location associated with the payment. * @member {String} location_id */ exports.prototype['location_id'] = undefined; /** * The ID of the order associated with the payment. * @member {String} order_id */ exports.prototype['order_id'] = undefined; /** * An optional ID that associates the payment with an entity in another system. * @member {String} reference_id */ exports.prototype['reference_id'] = undefined; /** * The `Customer` ID of the customer associated with the payment. * @member {String} customer_id */ exports.prototype['customer_id'] = undefined; /** * An optional ID of the employee associated with taking the payment. * @member {String} employee_id */ exports.prototype['employee_id'] = undefined; /** * A list of `refund_id`s identifying refunds for the payment. * @member {Array.<String>} refund_ids */ exports.prototype['refund_ids'] = undefined; /** * Provides information about the risk associated with the payment, as determined by Square. This field is present for payments to sellers that have opted in to receive risk evaluations. * @member {module:model/RiskEvaluation} risk_evaluation */ exports.prototype['risk_evaluation'] = undefined; /** * The buyer's email address. * @member {String} buyer_email_address */ exports.prototype['buyer_email_address'] = undefined; /** * The buyer's billing address. * @member {module:model/Address} billing_address */ exports.prototype['billing_address'] = undefined; /** * The buyer's shipping address. * @member {module:model/Address} shipping_address */ exports.prototype['shipping_address'] = undefined; /** * An optional note to include when creating a payment. * @member {String} note */ exports.prototype['note'] = undefined; /** * Additional payment information that gets added to the customer's card statement as part of the statement description. Note that the `statement_description_identifier` might get truncated on the statement description to fit the required information including the Square identifier (SQ *) and the name of the seller taking the payment. * @member {String} statement_description_identifier */ exports.prototype['statement_description_identifier'] = undefined; /** * The payment's receipt number. The field is missing if a payment is canceled. * @member {String} receipt_number */ exports.prototype['receipt_number'] = undefined; /** * The URL for the payment's receipt. The field is only populated for COMPLETED payments. * @member {String} receipt_url */ exports.prototype['receipt_url'] = undefined; module.exports = exports;