Skip to content

Commit 2c03c1a

Browse files
authored
Merge pull request #1 from AmirMehrabi/master
Add ability to process metadata
2 parents fc7254c + 656871c commit 2c03c1a

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ $response =
7878
->setCallbackUrl('http://michaelakanji.com') // to override/set callback_url, it can also be set on your dashboard
7979
->setEmail( '[email protected]' )
8080
->setAmount( 75000 ) // amount is treated in Naira while using this method
81+
->setMetadata(['custom_field1' => 'value1', 'custom_field2' => 'value2'])
8182
->initialize();
8283
```
8384
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

src/Transaction.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Transaction extends Base
2222
$amount = 0,
2323
$email = null,
2424
$reference = null,
25+
$metadata = null,
2526
$transactionResponse =
2627
[
2728
'verify' => null,
@@ -82,6 +83,12 @@ public function initialize( array $data = [], $rawResponse = false )
8283
$this->email = $data['email'];
8384
}
8485

86+
87+
// add metadata if provided
88+
if ( ! is_null( $this->metadata ) ) {
89+
$data['metadata'] = $this->metadata;
90+
}
91+
8592
$this->transactionResponse['initialize'] =
8693
$this
8794
->setAction( 'initialize' )
@@ -284,4 +291,19 @@ public function setCallbackUrl( $callbackUrl )
284291
return $this;
285292
}
286293

287-
}
294+
295+
/**
296+
* Sets the metadata
297+
*
298+
* @param array $metadata
299+
*
300+
* @return $this
301+
*/
302+
public function setMetadata( $metadata )
303+
{
304+
$this->metadata = $metadata;
305+
306+
return $this;
307+
}
308+
309+
}

0 commit comments

Comments
 (0)