@@ -126,19 +126,31 @@ public function abort($payplug = null)
126126 /**
127127 * Captures a Payment.
128128 *
129- * @param Payplug\Payplug $payplug the client configuration
129+ * @param Payplug\Payplug|null $payplug the client configuration
130+ * @param array|null $hostFieldsPayload
130131 *
131- * @return null|Payment the captured payment or null on error
132+ * @return null|Payment the captured payment or null on error
132133 *
133- * @throws Payplug\Exception\ConfigurationNotSetException
134+ * @throws Payplug\Exception\ConfigurationNotSetException
134135 */
135- public function capture (Payplug \ Payplug $ payplug = null )
136+ public function capture ($ payplug = null , $ hostFieldsPayload = null )
136137 {
137138 if ($ payplug === null ) {
138139 $ payplug = Payplug \Payplug::getDefaultConfiguration ();
139140 }
140141
141142 $ httpClient = new Payplug \Core \HttpClient ($ payplug );
143+
144+ if ($ hostFieldsPayload !== null ) {
145+ $ response = $ httpClient ->post (
146+ Payplug \Core \APIRoutes::$ HOSTED_FIELDS_RESOURCE ,
147+ $ hostFieldsPayload ,
148+ false
149+ );
150+
151+ return $ response ['httpResponse ' ];
152+ }
153+
142154 $ response = $ httpClient ->patch (
143155 Payplug \Core \APIRoutes::getRoute (Payplug \Core \APIRoutes::PAYMENT_RESOURCE , $ this ->id ),
144156 array ('captured ' => true )
@@ -151,15 +163,15 @@ public function capture(Payplug\Payplug $payplug = null)
151163 * @description Authorize a Payment.
152164 * @param $data
153165 * @param Payplug\Payplug|null $payplug
154- * @param $is_hosted_field
166+ * @param bool $is_hosted_field
155167 * @return mixed|void
156168 * @throws Payplug\Exception\ConfigurationNotSetException
157169 * @throws Payplug\Exception\ConnectionException
158170 * @throws Payplug\Exception\HttpException
159171 * @throws Payplug\Exception\UndefinedAttributeException
160172 * @throws Payplug\Exception\UnexpectedAPIResponseException
161173 */
162- public static function authorize ($ data , Payplug \ Payplug $ payplug = null , $ is_hosted_field = false )
174+ public static function authorize ($ data , $ payplug = null , $ is_hosted_field = false )
163175 {
164176 if ($ payplug === null ) {
165177 $ payplug = Payplug \Payplug::getDefaultConfiguration ();
@@ -182,15 +194,15 @@ public static function authorize($data, Payplug\Payplug $payplug = null, $is_hos
182194 /**
183195 * @param $data
184196 * @param Payplug\Payplug|null $payplug
185- * @param $is_hosted_field
197+ * @param bool $is_hosted_field
186198 * @return array|Payment
187199 * @throws Payplug\Exception\ConfigurationNotSetException
188200 * @throws Payplug\Exception\ConnectionException
189201 * @throws Payplug\Exception\HttpException
190202 * @throws Payplug\Exception\UndefinedAttributeException
191203 * @throws Payplug\Exception\UnexpectedAPIResponseException
192204 */
193- public static function retrieve ($ data , Payplug \ Payplug $ payplug = null , $ is_hosted_field = false )
205+ public static function retrieve ($ data , $ payplug = null , $ is_hosted_field = false )
194206 {
195207 if ($ payplug === null ) {
196208 $ payplug = Payplug \Payplug::getDefaultConfiguration ();
0 commit comments