Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ $response =
->setCallbackUrl('http://michaelakanji.com') // to override/set callback_url, it can also be set on your dashboard
->setEmail( 'matscode@gmail.com' )
->setAmount( 75000 ) // amount is treated in Naira while using this method
->setMetadata(['custom_field1' => 'value1', 'custom_field2' => 'value2'])
->initialize();
```
If you want to get the 200OK raw Object as it is sent by Paystack, Set the 2nd argument of the `initialize()` to `true`, example below
Expand Down
24 changes: 23 additions & 1 deletion src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Transaction extends Base
$amount = 0,
$email = null,
$reference = null,
$metadata = null,
$transactionResponse =
[
'verify' => null,
Expand Down Expand Up @@ -82,6 +83,12 @@ public function initialize( array $data = [], $rawResponse = false )
$this->email = $data['email'];
}


// add metadata if provided
if ( ! is_null( $this->metadata ) ) {
$data['metadata'] = $this->metadata;
}

$this->transactionResponse['initialize'] =
$this
->setAction( 'initialize' )
Expand Down Expand Up @@ -284,4 +291,19 @@ public function setCallbackUrl( $callbackUrl )
return $this;
}

}

/**
* Sets the metadata
*
* @param array $metadata
*
* @return $this
*/
public function setMetadata( $metadata )
{
$this->metadata = $metadata;

return $this;
}

}