我尝试创建一个帐户作为以下代码段(使用http://docs.recurly.com/api/accounts#create-account),帐户已创建,但无法在帐户中包含地址信息。
$account = new Recurly_Account('1');
$account->email = $_POST['emailaddress'];
$account->first_name = $_POST['firstname'];
$account->last_name = $_POST['lastname'];
$address = new Recurly_Address();
$address->address1 = $_POST['address'];
$address->country = $_POST['country'];
$address->city = $_POST['city'];
$address->phone = $_POST['phone'];
$address->state = $_POST['state'];
$address->zip = $_POST['zipcode'];
$account->address = $address;
$check = $account->create();
答案 0 :(得分:1)
您的语法和其他所有内容都可以。我能够使用你的代码(略有修改):
$account = new Recurly_Account('1');
$account->email = 'emailaddress@email.com';
$account->first_name = 'firstname';
$account->last_name = 'lastname';
$address = new Recurly_Address();
$address->address1 = 'address';
$address->country = 'country';
$address->city = 'city';
$address->phone = 'phone';
$address->state = 'state';
$address->zip = 'zipcode';
$account->address = $address;
$account->create();
创建一个带有地址信息的帐户。也许对于每个地址字段,$ _POST ['字段']评估为'' (空字符串)?唯一必填字段是您在调用Recurly_Account时指定的帐户代码,因此在这种情况下将创建帐户,但其所有参数都将为空。
答案 1 :(得分:0)
您是否尝试过发布数组,因为它在地址中表示嵌套值。
$ _ POST ['address'] = array('country','city');
答案 2 :(得分:0)
您还应该设置" account_code"为地址:
$address->account_code = '1';