Skip to content

Commit cea6b4a

Browse files
authored
Add support string payload to button element (#50)
1 parent 8e2a578 commit cea6b4a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Components/Button.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,18 @@ public function phone(string $phone): self
122122
}
123123

124124
/**
125-
* @param array $postback
125+
* @param $postback
126126
*
127-
* @throws CouldNotCreateButton
128127
* @return $this
128+
* @throws CouldNotCreateButton|\JsonException
129129
*/
130-
public function postback(array $postback): self
130+
public function postback($postback): self
131131
{
132132
if (blank($postback)) {
133133
throw CouldNotCreateButton::postbackNotProvided();
134134
}
135135

136-
$this->payload['payload'] = json_encode($postback);
136+
$this->payload['payload'] = is_string($postback) ? $postback : json_encode($postback, JSON_THROW_ON_ERROR);
137137
$this->isTypePostback();
138138

139139
return $this;

0 commit comments

Comments
 (0)