Skip to content

Latest commit

 

History

History
263 lines (192 loc) · 7.96 KB

payments.md

File metadata and controls

263 lines (192 loc) · 7.96 KB

Payments

IPaymentsApi paymentsApi = client.PaymentsApi;

Class Name

PaymentsApi

Methods

List Payments

Retrieves a list of payments taken by the account making the request.

Max results per page: 100

ListPaymentsAsync(
    string beginTime = null,
    string endTime = null,
    string sortOrder = null,
    string cursor = null,
    string locationId = null,
    long? total = null,
    string last4 = null,
    string cardBrand = null)

Parameters

Parameter Type Tags Description
beginTime string Query, Optional Timestamp for the beginning of the reporting period, in RFC 3339 format.
Inclusive. Default: The current time minus one year.
endTime string Query, Optional Timestamp for the end of the requested reporting period, in RFC 3339 format.

Default: The current time.
sortOrder string Query, Optional The order in which results are listed.
- ASC - oldest to newest
- DESC - newest to oldest (default).
cursor string Query, Optional 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.
locationId string Query, Optional Limit results to the location supplied. By default, results are returned
for all locations associated with the merchant.
total long? Query, Optional The exact amount in the total_money for a Payment.
last4 string Query, Optional The last 4 digits of Payment card.
cardBrand string Query, Optional The brand of Payment card. For example, VISA

Response Type

Task<Models.ListPaymentsResponse>

Example Usage

try
{
    ListPaymentsResponse result = await paymentsApi.ListPaymentsAsync(null, null, null, null, null, null, null, null);
}
catch (ApiException e){};

Create Payment

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.

CreatePaymentAsync(Models.CreatePaymentRequest body)

Parameters

Parameter Type Tags Description
body Models.CreatePaymentRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

Task<Models.CreatePaymentResponse>

Example Usage

var bodyAmountMoney = new Money.Builder()
    .Amount(200L)
    .Currency("USD")
    .Build();
var bodyAppFeeMoney = new Money.Builder()
    .Amount(10L)
    .Currency("USD")
    .Build();
var body = new CreatePaymentRequest.Builder(
        "ccof:uIbfJXhXETSP197M3GB",
        "4935a656-a929-4792-b97c-8848be85c27c",
        bodyAmountMoney)
    .AppFeeMoney(bodyAppFeeMoney)
    .Autocomplete(true)
    .CustomerId("VDKXEEKPJN48QDG3BGGFAK05P8")
    .LocationId("XK3DBG77NJBFX")
    .ReferenceId("123456")
    .Note("Brief description")
    .Build();

try
{
    CreatePaymentResponse result = await paymentsApi.CreatePaymentAsync(body);
}
catch (ApiException e){};

Cancel Payment by Idempotency Key

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.

CancelPaymentByIdempotencyKeyAsync(Models.CancelPaymentByIdempotencyKeyRequest body)

Parameters

Parameter Type Tags Description
body Models.CancelPaymentByIdempotencyKeyRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

Task<Models.CancelPaymentByIdempotencyKeyResponse>

Example Usage

var body = new CancelPaymentByIdempotencyKeyRequest.Builder(
        "a7e36d40-d24b-11e8-b568-0800200c9a66")
    .Build();

try
{
    CancelPaymentByIdempotencyKeyResponse result = await paymentsApi.CancelPaymentByIdempotencyKeyAsync(body);
}
catch (ApiException e){};

Get Payment

Retrieves details for a specific Payment.

GetPaymentAsync(string paymentId)

Parameters

Parameter Type Tags Description
paymentId string Template, Required Unique ID for the desired Payment.

Response Type

Task<Models.GetPaymentResponse>

Example Usage

string paymentId = "payment_id0";

try
{
    GetPaymentResponse result = await paymentsApi.GetPaymentAsync(paymentId);
}
catch (ApiException e){};

Cancel Payment

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.

CancelPaymentAsync(string paymentId)

Parameters

Parameter Type Tags Description
paymentId string Template, Required payment_id identifying the payment to be canceled.

Response Type

Task<Models.CancelPaymentResponse>

Example Usage

string paymentId = "payment_id0";

try
{
    CancelPaymentResponse result = await paymentsApi.CancelPaymentAsync(paymentId);
}
catch (ApiException e){};

Complete Payment

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.

CompletePaymentAsync(string paymentId)

Parameters

Parameter Type Tags Description
paymentId string Template, Required Unique ID identifying the payment to be completed.

Response Type

Task<Models.CompletePaymentResponse>

Example Usage

string paymentId = "payment_id0";

try
{
    CompletePaymentResponse result = await paymentsApi.CompletePaymentAsync(paymentId);
}
catch (ApiException e){};