Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Latest commit

 

History

History
319 lines (214 loc) · 13.1 KB

PaymentsApi.md

File metadata and controls

319 lines (214 loc) · 13.1 KB

SquareConnect.PaymentsApi

All URIs are relative to https://connect.squareup.com

Method HTTP request Description
cancelPayment POST /v2/payments/{payment_id}/cancel CancelPayment
cancelPaymentByIdempotencyKey POST /v2/payments/cancel CancelPaymentByIdempotencyKey
completePayment POST /v2/payments/{payment_id}/complete CompletePayment
createPayment POST /v2/payments CreatePayment
getPayment GET /v2/payments/{payment_id} GetPayment
listPayments GET /v2/payments ListPayments

cancelPayment

CancelPaymentResponse cancelPayment(paymentId)

CancelPayment

Cancels (voids) a payment. If you set `autocomplete` to `false` when creating a payment, you can cancel the payment using this endpoint.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.PaymentsApi();

var paymentId = SquareConnect.PaymentsApi.constructFromObject({}); // String | The `payment_id` identifying the payment to be canceled.

apiInstance.cancelPayment(paymentId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
paymentId String The `payment_id` identifying the payment to be canceled.

Return type

CancelPaymentResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

cancelPaymentByIdempotencyKey

CancelPaymentByIdempotencyKeyResponse cancelPaymentByIdempotencyKey(body)

CancelPaymentByIdempotencyKey

Cancels (voids) a payment identified by the idempotency key that is specified in the request. Use this method when the status of a `CreatePayment` request is unknown (for example, after you send a `CreatePayment` request, a network error occurs and you do not get a response). In this case, you can direct Square to cancel the payment using this endpoint. In the request, you provide the same idempotency key that you provided in your `CreatePayment` request that you want to cancel. After canceling the payment, you can submit your `CreatePayment` request again. Note that if no payment with the specified idempotency key is found, no action is taken and the endpoint returns successfully.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.PaymentsApi();

var body = SquareConnect.PaymentsApi.constructFromObject({}); // CancelPaymentByIdempotencyKeyRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.cancelPaymentByIdempotencyKey(body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
body CancelPaymentByIdempotencyKeyRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

CancelPaymentByIdempotencyKeyResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

completePayment

CompletePaymentResponse completePayment(paymentId)

CompletePayment

Completes (captures) a payment. By default, payments are set to complete immediately after they are created. If you set `autocomplete` to `false` when creating a payment, you can complete (capture) the payment using this endpoint.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.PaymentsApi();

var paymentId = SquareConnect.PaymentsApi.constructFromObject({}); // String | The unique ID identifying the payment to be completed.

apiInstance.completePayment(paymentId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
paymentId String The unique ID identifying the payment to be completed.

Return type

CompletePaymentResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

createPayment

CreatePaymentResponse createPayment(body)

CreatePayment

Charges a payment source (for example, a card represented by customer's card on file or a card nonce). In addition to the payment source, the request must include the amount to accept for the payment. There are several optional parameters that you can include in the request (for example, tip money, whether to autocomplete the payment, or a reference ID to correlate this payment with another system). The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required to enable application fees.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.PaymentsApi();

var body = SquareConnect.PaymentsApi.constructFromObject({}); // CreatePaymentRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.createPayment(body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
body CreatePaymentRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

CreatePaymentResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

getPayment

GetPaymentResponse getPayment(paymentId)

GetPayment

Retrieves details for a specific payment.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.PaymentsApi();

var paymentId = SquareConnect.PaymentsApi.constructFromObject({}); // String | A unique ID for the desired payment.

apiInstance.getPayment(paymentId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
paymentId String A unique ID for the desired payment.

Return type

GetPaymentResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

listPayments

ListPaymentsResponse listPayments(opts)

ListPayments

Retrieves a list of payments taken by the account making the request. The maximum results per page is 100.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.PaymentsApi();

var opts = { 
  'beginTime': SquareConnect.PaymentsApi.constructFromObject({});, // String | The timestamp for the beginning of the reporting period, in RFC 3339 format. Inclusive. Default: The current time minus one year.
  'endTime': SquareConnect.PaymentsApi.constructFromObject({});, // String | The timestamp for the end of the reporting period, in RFC 3339 format.  Default: The current time.
  'sortOrder': SquareConnect.PaymentsApi.constructFromObject({});, // String | The order in which results are listed: - `ASC` - Oldest to newest. - `DESC` - Newest to oldest (default).
  'cursor': SquareConnect.PaymentsApi.constructFromObject({});, // String | A pagination cursor returned by a previous call to this endpoint. Provide this cursor to retrieve the next set of results for the original query.  For more information, see [Pagination](https://developer.squareup.com/docs/basics/api101/pagination).
  'locationId': SquareConnect.PaymentsApi.constructFromObject({});, // String | Limit results to the location supplied. By default, results are returned for the default (main) location associated with the seller.
  'total': SquareConnect.PaymentsApi.constructFromObject({});, // Number | The exact amount in the `total_money` for a payment.
  'last4': SquareConnect.PaymentsApi.constructFromObject({});, // String | The last four digits of a payment card.
  'cardBrand': SquareConnect.PaymentsApi.constructFromObject({});, // String | The brand of the payment card (for example, VISA).
  'limit': SquareConnect.PaymentsApi.constructFromObject({}); // Number | The maximum number of results to be returned in a single page. It is possible to receive fewer results than the specified limit on a given page.  The default value of 100 is also the maximum allowed value. If the provided value is  greater than 100, it is ignored and the default value is used instead.  Default: `100`
};
apiInstance.listPayments(opts).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
beginTime String The timestamp for the beginning of the reporting period, in RFC 3339 format. Inclusive. Default: The current time minus one year. [optional]
endTime String The timestamp for the end of the reporting period, in RFC 3339 format. Default: The current time. [optional]
sortOrder String The order in which results are listed: - `ASC` - Oldest to newest. - `DESC` - Newest to oldest (default). [optional]
cursor String A pagination cursor returned by a previous call to this endpoint. Provide this cursor to retrieve the next set of results for the original query. For more information, see Pagination. [optional]
locationId String Limit results to the location supplied. By default, results are returned for the default (main) location associated with the seller. [optional]
total Number The exact amount in the `total_money` for a payment. [optional]
last4 String The last four digits of a payment card. [optional]
cardBrand String The brand of the payment card (for example, VISA). [optional]
limit Number The maximum number of results to be returned in a single page. It is possible to receive fewer results than the specified limit on a given page. The default value of 100 is also the maximum allowed value. If the provided value is greater than 100, it is ignored and the default value is used instead. Default: `100` [optional]

Return type

ListPaymentsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json