UNPKG

square-connect

Version:

JavaScript client library for the Square Connect v2 API

224 lines (193 loc) 12.9 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 Money = require('./Money'); /** * The CreatePaymentRequest model module. * @module model/CreatePaymentRequest */ /** * Constructs a new <code>CreatePaymentRequest</code>. * Creates a payment from a provided source (such as a nonce or a card on file). The &#x60;PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS&#x60; OAuth permission is required to enable application fees. For more information, see [Payments and Refunds APIs Overview](/payments-api/overview). For information about application fees in a payment, see [Take Payments and Collect Fees](/payments-api/take-payments-and-collect-fees). * @alias module:model/CreatePaymentRequest * @class * @param sourceId {String} The ID for the source of funds for this payment. This can be a nonce generated by the Square payment form or a card on file made with the Customers API. * @param idempotencyKey {String} A unique string that identifies this `CreatePayment` request. Keys can be any valid string but must be unique for every `CreatePayment` request. Max: 45 characters Note: The number of allowed characters might be less than the stated maximum, if multi-byte characters are used. For more information, see [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). * @param amountMoney {module:model/Money} The amount of money to accept for this payment, not including `tip_money`. The amount must be 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). The currency code must match the currency associated with the business that is accepting the payment. */ var exports = function(sourceId, idempotencyKey, amountMoney) { var _this = this; _this['source_id'] = sourceId; _this['idempotency_key'] = idempotencyKey; _this['amount_money'] = amountMoney; }; /** * Constructs a <code>CreatePaymentRequest</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/CreatePaymentRequest} obj Optional instance to populate. * @return {module:model/CreatePaymentRequest} The populated <code>CreatePaymentRequest</code> instance. */ exports.constructFromObject = function(data, obj) { if (data) { obj = obj || new exports(); if (data.hasOwnProperty('source_id')) { obj['source_id'] = ApiClient.convertToType(data['source_id'], 'String'); } if (data.hasOwnProperty('idempotency_key')) { obj['idempotency_key'] = ApiClient.convertToType(data['idempotency_key'], '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('app_fee_money')) { obj['app_fee_money'] = Money.constructFromObject(data['app_fee_money']); } if (data.hasOwnProperty('delay_duration')) { obj['delay_duration'] = ApiClient.convertToType(data['delay_duration'], 'String'); } if (data.hasOwnProperty('autocomplete')) { obj['autocomplete'] = ApiClient.convertToType(data['autocomplete'], 'Boolean'); } if (data.hasOwnProperty('order_id')) { obj['order_id'] = ApiClient.convertToType(data['order_id'], 'String'); } if (data.hasOwnProperty('customer_id')) { obj['customer_id'] = ApiClient.convertToType(data['customer_id'], 'String'); } if (data.hasOwnProperty('location_id')) { obj['location_id'] = ApiClient.convertToType(data['location_id'], 'String'); } if (data.hasOwnProperty('reference_id')) { obj['reference_id'] = ApiClient.convertToType(data['reference_id'], 'String'); } if (data.hasOwnProperty('verification_token')) { obj['verification_token'] = ApiClient.convertToType(data['verification_token'], 'String'); } if (data.hasOwnProperty('accept_partial_authorization')) { obj['accept_partial_authorization'] = ApiClient.convertToType(data['accept_partial_authorization'], 'Boolean'); } 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'); } } return obj; } /** * The ID for the source of funds for this payment. This can be a nonce generated by the Square payment form or a card on file made with the Customers API. * @member {String} source_id */ exports.prototype['source_id'] = undefined; /** * A unique string that identifies this `CreatePayment` request. Keys can be any valid string but must be unique for every `CreatePayment` request. Max: 45 characters Note: The number of allowed characters might be less than the stated maximum, if multi-byte characters are used. For more information, see [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). * @member {String} idempotency_key */ exports.prototype['idempotency_key'] = undefined; /** * The amount of money to accept for this payment, not including `tip_money`. The amount must be 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). The currency code must match the currency associated with the business that is accepting the payment. * @member {module:model/Money} amount_money */ exports.prototype['amount_money'] = undefined; /** * The amount designated as a tip, in addition to `amount_money`. The amount must be 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). The currency code must match the currency associated with the business that is accepting the payment. * @member {module:model/Money} tip_money */ exports.prototype['tip_money'] = undefined; /** * The amount of money that the developer is taking as a fee for facilitating the payment on behalf of the seller. The amount cannot be more than 90% of the total amount of the payment. The amount must be 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). The fee currency code must match the currency associated with the seller that is accepting the payment. The application must be from a developer account in the same country and using the same currency code as the seller. For more information about the application fee scenario, see [Take Payments and Collect Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees). * @member {module:model/Money} app_fee_money */ exports.prototype['app_fee_money'] = undefined; /** * The duration of time after the payment's creation when Square automatically cancels the payment. This automatic cancellation applies only to payments that do not reach a terminal state (COMPLETED, CANCELED, or FAILED) before the `delay_duration` time period. This parameter should be specified as a time duration, in RFC 3339 format, with a minimum value of 1 minute. Note: This feature is only supported for card payments. This parameter can only be set for a delayed capture payment (`autocomplete=false`). 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; /** * If set to `true`, this payment will be completed when possible. If set to `false`, this payment is held in an approved state until either explicitly completed (captured) or canceled (voided). For more information, see [Delayed capture](https://developer.squareup.com/docs/payments-api/take-payments#delayed-payments). Default: true * @member {Boolean} autocomplete */ exports.prototype['autocomplete'] = undefined; /** * Associates a previously created order with this payment. * @member {String} order_id */ exports.prototype['order_id'] = undefined; /** * The `Customer` ID of the customer associated with the payment. This is required if the `source_id` refers to a card on file created using the Customers API. * @member {String} customer_id */ exports.prototype['customer_id'] = undefined; /** * The location ID to associate with the payment. If not specified, the default location is used. * @member {String} location_id */ exports.prototype['location_id'] = undefined; /** * A user-defined ID to associate with the payment. You can use this field to associate the payment to an entity in an external system (for example, you might specify an order ID that is generated by a third-party shopping cart). Limit 40 characters. * @member {String} reference_id */ exports.prototype['reference_id'] = undefined; /** * An identifying token generated by `SqPaymentForm.verifyBuyer()`. Verification tokens encapsulate customer device information and 3-D Secure challenge results to indicate that Square has verified the buyer identity. For more information, see [SCA Overview](https://developer.squareup.com/docs/sca-overview). * @member {String} verification_token */ exports.prototype['verification_token'] = undefined; /** * If set to `true` and charging a Square Gift Card, a payment might be returned with `amount_money` equal to less than what was requested. For example, a request for $20 when charging a Square Gift Card with a balance of $5 results in an APPROVED payment of $5. You might choose to prompt the buyer for an additional payment to cover the remainder or cancel the Gift Card payment. This field cannot be `true` when `autocomplete = true`. For more information, see [Partial amount with Square Gift Cards](https://developer.squareup.com/docs/payments-api/take-payments#partial-payment-gift-card). Default: false * @member {Boolean} accept_partial_authorization */ exports.prototype['accept_partial_authorization'] = 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 be entered by the developer when creating a payment. Limit 500 characters. * @member {String} note */ exports.prototype['note'] = undefined; /** * Optional additional payment information to include on the customer's card statement as part of the statement description. This can be, for example, an invoice number, ticket number, or short description that uniquely identifies the purchase. Note that the `statement_description_identifier` might get truncated on the statement description to fit the required information including the Square identifier (SQ *) and name of the seller taking the payment. * @member {String} statement_description_identifier */ exports.prototype['statement_description_identifier'] = undefined; module.exports = exports;