Skip to content

Latest commit

 

History

History
263 lines (192 loc) · 15.7 KB

File metadata and controls

263 lines (192 loc) · 15.7 KB

PaymentMethods

Overview

Available Operations

  • list - List all payment methods
  • create - Create payment method
  • get - Get payment method
  • delete - Delete payment method

list

List all stored payment method.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Gr4vy;

$sdk = Gr4vy\SDK::builder()
    ->setMerchantAccountId('default')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Gr4vy\ListPaymentMethodsRequest(
    cursor: 'ZXhhbXBsZTE',
    buyerId: 'fe26475d-ec3e-4884-9553-f7356683f7f9',
    buyerExternalIdentifier: 'buyer-12345',
    externalIdentifier: 'payment-method-12345',
);

$responses = $sdk->paymentMethods->list(
    request: $request
);


foreach ($responses as $response) {
    if ($response->statusCode === 200) {
        // handle response
    }
}

Parameters

Parameter Type Required Description
$request Gr4vy\ListPaymentMethodsRequest ✔️ The request object to use for the request.

Response

?ListPaymentMethodsResponse

Errors

Error Type Status Code Content Type
Errors\Error400 400 application/json
Errors\Error401 401 application/json
Errors\Error403 403 application/json
Errors\Error404 404 application/json
Errors\Error405 405 application/json
Errors\Error409 409 application/json
Errors\HTTPValidationError 422 application/json
Errors\Error425 425 application/json
Errors\Error429 429 application/json
Errors\Error500 500 application/json
Errors\Error502 502 application/json
Errors\Error504 504 application/json
errors\APIException 4XX, 5XX */*

create

Store a new payment method.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Gr4vy;

$sdk = Gr4vy\SDK::builder()
    ->setMerchantAccountId('default')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->paymentMethods->create(
    requestBody: new Gr4vy\CheckoutSessionPaymentMethodCreate(
        id: '4137b1cf-39ac-42a8-bad6-1c680d5dab6b',
    )
);

if ($response->paymentMethod !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
requestBody CardPaymentMethodCreate|RedirectPaymentMethodCreate|CheckoutSessionPaymentMethodCreate|PlaidPaymentMethodCreate|ACHBankPaymentMethodCreate|BACSBankPaymentMethodCreate|SEPABankPaymentMethodCreate ✔️ N/A
merchantAccountId ?string The ID of the merchant account to use for this request. default

Response

?CreatePaymentMethodResponse

Errors

Error Type Status Code Content Type
Errors\Error400 400 application/json
Errors\Error401 401 application/json
Errors\Error403 403 application/json
Errors\Error404 404 application/json
Errors\Error405 405 application/json
Errors\Error409 409 application/json
Errors\HTTPValidationError 422 application/json
Errors\Error425 425 application/json
Errors\Error429 429 application/json
Errors\Error500 500 application/json
Errors\Error502 502 application/json
Errors\Error504 504 application/json
errors\APIException 4XX, 5XX */*

get

Retrieve a payment method.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Gr4vy;

$sdk = Gr4vy\SDK::builder()
    ->setMerchantAccountId('default')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->paymentMethods->get(
    paymentMethodId: 'ef9496d8-53a5-4aad-8ca2-00eb68334389'
);

if ($response->paymentMethod !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
paymentMethodId string ✔️ The ID of the payment method ef9496d8-53a5-4aad-8ca2-00eb68334389
merchantAccountId ?string The ID of the merchant account to use for this request. default

Response

?GetPaymentMethodResponse

Errors

Error Type Status Code Content Type
Errors\Error400 400 application/json
Errors\Error401 401 application/json
Errors\Error403 403 application/json
Errors\Error404 404 application/json
Errors\Error405 405 application/json
Errors\Error409 409 application/json
Errors\HTTPValidationError 422 application/json
Errors\Error425 425 application/json
Errors\Error429 429 application/json
Errors\Error500 500 application/json
Errors\Error502 502 application/json
Errors\Error504 504 application/json
errors\APIException 4XX, 5XX */*

delete

Delete a payment method.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Gr4vy;

$sdk = Gr4vy\SDK::builder()
    ->setMerchantAccountId('default')
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->paymentMethods->delete(
    paymentMethodId: 'ef9496d8-53a5-4aad-8ca2-00eb68334389'
);

if ($response->statusCode === 200) {
    // handle response
}

Parameters

Parameter Type Required Description Example
paymentMethodId string ✔️ The ID of the payment method ef9496d8-53a5-4aad-8ca2-00eb68334389
merchantAccountId ?string The ID of the merchant account to use for this request. default

Response

?DeletePaymentMethodResponse

Errors

Error Type Status Code Content Type
Errors\Error400 400 application/json
Errors\Error401 401 application/json
Errors\Error403 403 application/json
Errors\Error404 404 application/json
Errors\Error405 405 application/json
Errors\Error409 409 application/json
Errors\HTTPValidationError 422 application/json
Errors\Error425 425 application/json
Errors\Error429 429 application/json
Errors\Error500 500 application/json
Errors\Error502 502 application/json
Errors\Error504 504 application/json
errors\APIException 4XX, 5XX */*