Skip to content

Commit fcd8430

Browse files
committed
fix: send login request as form-urlencoded to resolve HTTP 415
1 parent 98d0488 commit fcd8430

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

includes/class-mmg-api-client.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,17 @@ protected function ensure_token() {
9393
* @throws Exception If login fails.
9494
*/
9595
public function do_login() {
96-
$body = wp_json_encode(
96+
$body = http_build_query(
9797
array(
9898
'merchant_msisdn' => get_option( "mmg_{$this->mode}_merchant_id" ),
9999
'password' => get_option( "mmg_{$this->mode}_secret_key" ),
100100
)
101101
);
102-
$response = $this->http_post( $this->base_url . '/mwallet/v1/e-commerce-login/mer', array(), $body );
102+
$response = $this->http_post(
103+
$this->base_url . '/mwallet/v1/e-commerce-login/mer',
104+
array( 'Content-Type' => 'application/x-www-form-urlencoded' ),
105+
$body
106+
);
103107

104108
$code = wp_remote_retrieve_response_code( $response );
105109
if ( 200 !== $code ) {

0 commit comments

Comments
 (0)