The DirectBillingTransaction class is responsible for storing information about a direct billing transaction. It implements the RequestInterface which means it has a method toArray() that returns an array representation of the direct billing transaction.
$amount: a private property that holds an instance of theAmountclass representing the amount of the transaction.$amountType: a private property that holds an optional instance of theAmountTypeclass representing the type of the amount of the transaction.$description: a private property that holds an optional instance of theDescriptionclass representing the description of the transaction.$control: a private property that holds an optional instance of theControlclass representing the control data of the transaction.$phoneNumber: a private property that holds an optional instance of thePhoneNumberclass representing the phone number of the customer.$streamId: a private property that holds an optional instance of theStreamIdclass representing the stream ID of the transaction.$returns: a private property that holds an optional instance of theCallbackReturnUrlclass representing the return URL of the transaction.
__construct(Amount $amount, ?AmountType $amountType = null, ?Description $description = null, ?Control $control = null, ?CallbackReturnUrl $returns = null, ?PhoneNumber $phoneNumber = null, ?StreamId $steamId = null): a constructor that takes the following parameters:$amount: an instance of theAmountclass representing the amount of the transaction.$amountType: an optional instance of theAmountTypeclass representing the type of the amount of the transaction. Default value isnull.$description: an optional instance of theDescriptionclass representing the description of the transaction. Default value isnull.$control: an optional instance of theControlclass representing the control data of the transaction. Default value isnull.$returns: an optional instance of theCallbackReturnUrlclass representing the return URL of the transaction. Default value isnull.$phoneNumber: an optional instance of thePhoneNumberclass representing the phone number of the customer. Default value isnull.$steamId: an optional instance of theStreamIdclass representing the stream ID of the transaction. Default value isnull.
toArray(): array: a method that returns an array representation of the direct billing transaction. The returned array is a merge of all the arrays returned by thetoArray()methods of the properties of the class that are notnull.
// Create a new instance of the DirectBillingTransaction class with amount 10.50 PLN
$amount = new Amount(10.50, new Currency('PLN'));
$transaction = new DirectBillingTransaction($amount);
// Get the array representation of the transaction
$array = $transaction->toArray();
// Output the array
print_r($array);