Documentation

PA_Purchase
in package

The PuzzleAnywhere Purchase class. It allows for an easy way to display created, pending, completed, and refunded purchases.

Table of Contents

$account_purchase_token  : string
The account's purchase token.
$attachments  : array<string|int, array<string|int, PA_Attachment>>
File attachments associated with the purchase.
$base_item  : PA_PurchasableItem|null
The initial purchasable item for the purchase.
$base_item_price  : float|null
The initial purchasable item price for the purchase.
$buyer_user  : PA_USER|null
The user who made the purchase.
$created_at  : string
The datetime when the purchase was initialized.
$created_at_display  : string
A humanized datetime when the purchase was initialized.
$customer_email  : string|null
The purchaser's email address.
$download_url  : string
The URL to download a user's purchased items.
$external_payment_id  : string
The merchant payment ID for the purchase.
$external_payment_production_id  : string
The merchant payment production ID for the purchase.
$external_payment_sandbox_id  : string
The merchant payment sandbox ID for the purchase.
$fee  : float|null
The fee taken by the merchant.
$gift  : bool
Denotes whether the purchase is intended as a gift.
$gross  : float|null
The gross amount of the purchase.
$id  : int|null
The purchase ID.
$max_download_count  : int
The maximum download count for purchased items.
$net  : float|null
The net amount of the purchase.
$notes  : string|null
A note to be sent to the purchase recipient.
$purchasable_items  : array<string|int, array<string|int, PA_PurchasableItem>>
Purchasable items associated with the purchase.
$purchased_at  : string|null
The datetime when the purchase was completed.
$purchased_at_display  : string
A humanized datetime when the purchase was completed.
$recipient_email  : string|null
The purchase recipient's email address.
$recipient_user  : PA_User|null
The purchase recipient user.
$recurrs_at  : string|null
The datetime when the recurring purchase will recur.
$send_at  : string|null
The datetime when the purchase email confirmation should be sent.
$sent_at  : string|null
The datetime when the purchase email confirmation was sent.
$status  : string
The purchase status.
$subscriptions  : PA_Subscription
The subscriptions associated with the purchase.
__construct()  : null
Initialize a purchase.
base_item()  : PA_PurchasableItem
Get the base purchasable item for a purchase form.
base_item_price()  : float
Get the base item price.
bundles_url()  : string
Get the relative purchasable puzzle bundles url.
default_base_item()  : PA_PurchasableItem
Get the default base item based on standard criteria.
default_purchasable_item()  : PA_PurchasableItem
Get the default purchasable item for use in a purchase form.
execute_paypal_purchase()  : PA_Purchase|null
Sends a payment request to the PayPal merchant.
featured_renewal_url()  : string
Get the featured available subscription renewals url.
featured_subscription_url()  : string
Get the featured subscriptions url.
get_by_id()  : PA_Purchase
Get a purchase by ID lookup.
has_recurring_items()  : bool
Denotes whether the purchase includes a recurring purchasable item.
is_free()  : bool
Denotes whether the purchase required no merchant interaction.
is_pending()  : bool
Denotes whether the purchase is pending.
json_to_purchase()  : PA_Purchase
Takes a purchase returned by the API server and converts it to a proper `PA_Purchase` object.
paypal_url()  : string
The PayPal checkout merchant URL, dependent on the environment.
processPurchase()  : null
Sends purchase post data off to the API server to initialize purchase, then redirects to seller gateway.
purchase_process_url()  : string
Get the relative merchant processing url.
purchaseLbl()  : string
Get purchase label/input id with its `uuid`.
puzzles_url()  : string
Get the purchasable puzzles url.
set_base_item()  : null
Sets the initially selected purchase for checkout.
status_class()  : string
Gets the current status of the purchase and returns it as Bootstrap-accessible class name.
status_list_class()  : string
Convenience function to get status list classes for the purchase.
statusDisplay()  : string
Get a humanized version of the purchase status.
subscription_year_intv()  : int
Get the subscription year interval.
tip_jar_url()  : string
Get the relative tip jar url.
was_completed()  : bool
Denotes whether the purchase was completed.
was_gifted()  : bool
Denotes whether the purchase was intended as a gift.
was_purchased()  : bool
Denotes whether the purchase was purchased.

Properties

$base_item_price

The initial purchasable item price for the purchase.

public float|null $base_item_price

The initial purchasable item price for the purchase.

$created_at

The datetime when the purchase was initialized.

public string $created_at

The datetime when the purchase was initialized.

$created_at_display

A humanized datetime when the purchase was initialized.

public string $created_at_display

A humanized datetime when the purchase was initialized.

$download_url

The URL to download a user's purchased items.

public string $download_url

The URL to download a user's purchased items.

$external_payment_id

The merchant payment ID for the purchase.

public string $external_payment_id

The merchant payment ID for the purchase.

$external_payment_production_id

The merchant payment production ID for the purchase.

public string $external_payment_production_id

The merchant payment production ID for the purchase.

$external_payment_sandbox_id

The merchant payment sandbox ID for the purchase.

public string $external_payment_sandbox_id

The merchant payment sandbox ID for the purchase.

$gift

Denotes whether the purchase is intended as a gift.

public bool $gift

Denotes whether the purchase is intended as a gift.

$max_download_count

The maximum download count for purchased items.

public int $max_download_count

The maximum download count for purchased items.

$purchased_at

The datetime when the purchase was completed.

public string|null $purchased_at

The datetime when the purchase was completed.

$purchased_at_display

A humanized datetime when the purchase was completed.

public string $purchased_at_display

A humanized datetime when the purchase was completed.

$recipient_email

The purchase recipient's email address.

public string|null $recipient_email

The purchase recipient's email address.

$recurrs_at

The datetime when the recurring purchase will recur.

public string|null $recurrs_at

The datetime when the recurring purchase will recur.

$send_at

The datetime when the purchase email confirmation should be sent.

public string|null $send_at

The datetime when the purchase email confirmation should be sent.

$sent_at

The datetime when the purchase email confirmation was sent.

public string|null $sent_at

The datetime when the purchase email confirmation was sent.

$status

The purchase status.

public string $status

The purchase status. [created|pending|send_confirmation|completed|canceled|expired|lapsed|refunded]

Methods

__construct()

Initialize a purchase.

public __construct([array<string|int, PA_PurchasableItem$items = [] ][, object $attrs = [] ]) : null
Parameters
$items : array<string|int, PA_PurchasableItem> = []

Items to include in the purchase.

$attrs : object = []

Attributes to set for the purchase. See PA_Purchase properties.

Return values
null

bundles_url()

Get the relative purchasable puzzle bundles url.

public bundles_url() : string
Return values
string

Returns the purchasable puzzle bundles url.

execute_paypal_purchase()

Sends a payment request to the PayPal merchant.

public static execute_paypal_purchase(int|string $paymentId) : PA_Purchase|null
Parameters
$paymentId : int|string

The payment ID.

Return values
PA_Purchase|null

Get the featured available subscription renewals url.

public featured_renewal_url(string|null $token) : string
Parameters
$token : string|null

The prior user subscription token.

Tags
todo

Add token support

Return values
string

The featured subscription renewals url.

Get the featured subscriptions url.

public featured_subscription_url() : string
Return values
string

The featured subscriptions url.

has_recurring_items()

Denotes whether the purchase includes a recurring purchasable item.

public has_recurring_items() : bool
Return values
bool

Returns true if the purchase includes a recurring purchasable item.

is_free()

Denotes whether the purchase required no merchant interaction.

public is_free() : bool
Return values
bool

Returns true if the purchase required no merchant interaction.

is_pending()

Denotes whether the purchase is pending.

public is_pending() : bool
Return values
bool

Returns true if the purchase is pending.

json_to_purchase()

Takes a purchase returned by the API server and converts it to a proper `PA_Purchase` object.

public static json_to_purchase(array<string|int, mixed>|object $json) : PA_Purchase
Parameters
$json : array<string|int, mixed>|object

The purchase JSON

Return values
PA_Purchase

The parsed purchase.

paypal_url()

The PayPal checkout merchant URL, dependent on the environment.

public paypal_url() : string
Return values
string

The computed PayPal checkout merchant URL.

processPurchase()

Sends purchase post data off to the API server to initialize purchase, then redirects to seller gateway.

public processPurchase(object $postdata, string $token) : null
Parameters
$postdata : object

Received postdata from the merchant.

$token : string

The recaptcha token to validate that the purchase was made by a human. This prevents against bots and free trials.

Return values
null

purchase_process_url()

Get the relative merchant processing url.

public purchase_process_url() : string
Return values
string

Returns the relative merchant processing url.

purchaseLbl()

Get purchase label/input id with its `uuid`.

public purchaseLbl(mixed $lbl) : string
Parameters
$lbl : mixed
Return values
string

The assembled label/input id.

puzzles_url()

Get the purchasable puzzles url.

public puzzles_url() : string
Return values
string

Returns the purchasable puzzles url.

status_class()

Gets the current status of the purchase and returns it as Bootstrap-accessible class name.

public status_class([bool $list = false ]) : string
Parameters
$list : bool = false

Denotes whether this is part of a list.

Tags
see
Bootstrap

alert documentation.

Return values
string

The purchase status class name.

status_list_class()

Convenience function to get status list classes for the purchase.

public status_list_class() : string
Tags
see
Bootstrap

alert documentation.

Return values
string

The status list class.

statusDisplay()

Get a humanized version of the purchase status.

public statusDisplay() : string
Return values
string

A humanized version of the purchase status.

subscription_year_intv()

Get the subscription year interval.

public subscription_year_intv(string $intv) : int
Parameters
$intv : string

The subscription year interval.

Return values
int

The subscription interval

tip_jar_url()

Get the relative tip jar url.

public tip_jar_url() : string
Return values
string

Returns the relative tip jar url.

was_completed()

Denotes whether the purchase was completed.

public was_completed() : bool

Completed means that the purchase was processed and a confirmation email was sent.

Return values
bool

Returns true if the purchase was completed.

was_gifted()

Denotes whether the purchase was intended as a gift.

public was_gifted(int $uid) : bool
Parameters
$uid : int

The recipient user ID.

Return values
bool

Returns true if the purchase was intended as a gift.

was_purchased()

Denotes whether the purchase was purchased.

public was_purchased() : bool
Return values
bool

Returns true if the purchase was purchased.

Search results