How to pass json object using PHP in Wepay API -


i have integrated wepay payment gateway. have facing problem pass json object wepay. shows incorrect json format. please @ below code.

$forca_a = array(   'debit_opt_in'=>true ); $forca = json_encode($forca_a,json_force_object); $wepay_create_array = array(   'name' =>"xxxx",   'description' => "xxxxxxxxx xxxx",   'callback_uri' => "xxxxxxx",   'country' => "ca",   'currencies' => array('cad'),   'country_options' => $forca,   'rbits'=> array(                array(                   'receive_time'=>strtotime("now"),                   'type' =>'website_uri',                   'source' => 'partner_database',                   'properties'=> array('uri'=>xxxxx)                )             ) ); 

if won't pass country_options, seems working if pass parameter, give me error says "incorrect json format".

i sent email wepay center. told me that, passing string "country_options":"{"debit_opt_in":true}" <--- string instead of "country_options":{"debit_opt_in":true} <--- json object. i'm confused. have no idea how pass json object. there way , json_encode($object).

hey use below code proper json

<?php $forca_a = array(                   'debit_opt_in'=>true            );     // $forca = json_encode($forca_a);     $wepay_create_array = array(                   'name' =>"xxxx",                   'description' => "xxxxxxxxx xxxx",                   'callback_uri' => "xxxxxxx",                   'country' => "ca",                   'currencies' => array('cad'),                   'country_options' => $forca_a,                   'rbits'=> array(                                array(                                   'receive_time'=>strtotime("now"),                                   'type' =>'website_uri',                                   'source' => 'partner_database',                                   'properties'=> array('uri'=>'xxxxx')                                )                             )                   );   print_r(json_encode($wepay_create_array));                   ?> 

this code give following json output

{         "name": "xxxx",         "description": "xxxxxxxxx xxxx",         "callback_uri": "xxxxxxx",         "country": "ca",         "currencies": ["cad"],         "country_options": {             "debit_opt_in": true         },         "rbits": [{             "receive_time": 1461561030,             "type": "website_uri",             "source": "partner_database",             "properties": {                 "uri": "xxxxx"             }         }]     } 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -