Closed simioluwatomi closed 4 years ago
Hi @simioluwatomi, You should add the metadata
key when initiating the transaction:
$metadata = new MetadataBuilder;
//Add metadata here
try {
$transaction = $paystack->transaction->initialize([
'amount' => (Cart::totalFloat() + 8000) * 100,
'email' => $request->input('email'),
'reference' => $orderCode,
'metadata' => $metadata->build()
]);
} catch (\Yabacon\Paystack\Exception\ApiException $e) {
return redirect()->back()->with('message', [
'status' => 'danger',
'body' => 'Failed to make request to payment provider. Please try again',
]);
}
Thanks @nwogu
Problem/Motivation
There is no full example of how to use the MetaBuilder when initiating a transaction. Though there are examples of how the metadata would be built, I'm confused as to when to build the metadata.
I have the code below when initiating a transaction
But when the transaction is verified, the metadata field is an empty string.
How should the builder be used when initiating a transaction? Where does the metadata go? How would the embedded metadata be retrieved from the transaction detail response?