Skip to content

Latest commit

 

History

History
317 lines (212 loc) · 12.2 KB

File metadata and controls

317 lines (212 loc) · 12.2 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. For more information, see Delayed Payments.

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 = "paymentId_example"; // String | `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 `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 status of a CreatePayment request is unknown. For example, after you send a CreatePayment request a network error occurs and you don't 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 you want to cancel. After cancelling 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, the end point 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 = new SquareConnect.CancelPaymentByIdempotencyKeyRequest(); // 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. For more information, see Delayed Payments.

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 = "paymentId_example"; // String | 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 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 also 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. For more information about these payment options, see Take Payments. 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 = new SquareConnect.CreatePaymentRequest(); // 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 = "paymentId_example"; // String | 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 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. Max results per page: 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': "beginTime_example", // String | Timestamp for the beginning of the reporting period, in RFC 3339 format. Inclusive. Default: The current time minus one year.
  'endTime': "endTime_example", // String | Timestamp for the end of the requested reporting period, in RFC 3339 format.  Default: The current time.
  'sortOrder': "sortOrder_example", // String | The order in which results are listed. - `ASC` - oldest to newest - `DESC` - newest to oldest (default).
  'cursor': "cursor_example", // String | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query.  See [Pagination](https://developer.squareup.com/docs/basics/api101/pagination) for more information.
  'locationId': "locationId_example", // String | Limit results to the location supplied. By default, results are returned for all locations associated with the merchant.
  'total': 789, // Number | The exact amount in the total_money for a `Payment`.
  'last4': "last4_example", // String | The last 4 digits of `Payment` card.
  'cardBrand': "cardBrand_example" // String | The brand of `Payment` card. For example, `VISA`
};
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 Timestamp for the beginning of the reporting period, in RFC 3339 format. Inclusive. Default: The current time minus one year. [optional]
endTime String Timestamp for the end of the requested 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 to retrieve the next set of results for the original query. See Pagination for more information. [optional]
locationId String Limit results to the location supplied. By default, results are returned for all locations associated with the merchant. [optional]
total Number The exact amount in the total_money for a `Payment`. [optional]
last4 String The last 4 digits of `Payment` card. [optional]
cardBrand String The brand of `Payment` card. For example, `VISA` [optional]

Return type

ListPaymentsResponse

Authorization

oauth2

HTTP request headers

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