Skip to content
Shabab Haider Siddique edited this page May 12, 2023 · 1 revision

PaymentLink

class PaymentLink extends ResultObject

PaymentLink object contains all relevant information about a single payment link. API method PaymentLink\Create will generate a PaymentLink obj.

Properties

Name Modifier & Type Description
id private string Unique ID of payment link
url private string URL of the payment link
amount private float Amount charged
currency private string Three letter ISO currency code
country private string Country of customer. ISO 3166-2 alpha-2 country code.
description private string Maximum 255 characters
expiration_date private string Payment creation time as defined in RFC 3339 Section 5.6. UTC timezone.
multiple_use private boolean
enabled private boolean

Methods

Name Return Type Description
getId() public string Returns payment ID
getAmount() public double Returns Amount
getCurrency() public double Returns currency of payment
getEnabled() public boolean Return true if payment link is enabled. False if disabled
getMultipleUse() public boolean True when multiple use allowed, default to false
getExpirationDate() public string Gets when the payment link expires, by default 7 days from creation
getDescription() public string Get payment link description
getCountry() public string Gets country property
getUrl() public string Gets the payment link URL

Example

Below example creates a Client and executes the PaymentLink/Create method

Create client

<?php

use Cardinity\Client;
use Cardinity\Method\PaymentLink;
use Cardinity\Exception;

$client = Client::create([
    'consumerKey' => 'YOUR_CONSUMER_KEY',
    'consumerSecret' => 'YOUR_CONSUMER_SECRET',
]);

Create the payment link

$method = new PaymentLink\Create([
    'amount' => 50.00,
    'currency' => "USD",
    'description' => "Short description for the payment link",

    'country' => "LT", // ISO 3166-1 alpha-2 country code.
    'expiration_date' => "2023-01-06T15:26:03.702Z", //ISO 8601 datetime in UTC
    'multiple_use' => true, //bool
]);
// again use same try ... catch block
try {
    $paymentLink = $client->call($method);
}
// same catch blocks ...
// ...

Update existing payment link

$method = new PaymentLink\Update(
    $payment_link_id,
    [
        'expiration_date' => "2023-01-06T15:26:03.702Z", //ISO 8601 datetime in UTC
        'enabled' => true,  // true or false
    ]
);
// again use same try ... catch block
try {
    $updatedPaymentLink = $client->call($method);
}
// same catch blocks ...
// ...

Clone this wiki locally