Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing account_acquisition to writable attributes #377

Merged
merged 2 commits into from
Oct 23, 2018
Merged

Added missing account_acquisition to writable attributes #377

merged 2 commits into from
Oct 23, 2018

Conversation

emycakes
Copy link

As per documentation in https://dev.recurly.com/docs/create-an-account account_acquisition parameter is missing in writeable attribute array.

Additional note: there seems to be a mismatch between the client and the documentation concerning shipping_address attribute, not sure which is correct.

@aaron-junot
Copy link

Hey there @mickpaliokas, thank you so much for your contribution! I tried it out, it works great. Per our CONTRIBUTING.md file, it would be super awesome if you could add a test for this.

You could, for example, add the following lines to the testXml() function of the Account_Test.php

    // Account Acquisition
    $account->account_acquisition = new Recurly_AccountAcquisition();
    $account->account_acquisition->cost_in_cents = 123;
    $account->account_acquisition->currency = 'USD';

And then just update the XML to add in the extra data. For my example above, it would look like this:

<account_acquisition><cost_in_cents>123</cost_in_cents><currency>USD</currency></account_acquisition>

Once we get that test in, I'll be happy to merge this!

As for the note about the shipping_address attribute, could you go into a bit more detail about the mismatch you're seeing?

@emycakes
Copy link
Author

Updated PR with a test

@emycakes
Copy link
Author

emycakes commented Oct 23, 2018

As for the other issue in the Create Account section of the Recurly API documentation, shipping address attribute is referred to as shipping_address while in lib/account.php(106) the attribute is referred to as shipping_addresses.

If I were to include shipping_address attribute while creating an account, the value would be ignored.

@aaron-junot
Copy link

Right, that is correct. There can be multiple shipping addresses on an account, so the attribute is actually shipping_addresses which is an array of shipping addresses. I agree that the docs don't do a great job of explaining this, I'm going to put in a ticket to clarify that. The XML examples do show the correct information.

<account>
  <account_code>1</account_code>
  <email>verena@example.com</email>
  <first_name>Verena</first_name>
  <last_name>Example</last_name>
  <username>verena1234</username>
  <cc_emails>bob@example.com,susan@example.com</cc_emails>
  <company_name>Recurly Inc</company_name>
  <preferred_locale>en-US</preferred_locale>
  <address>
    <address1>123 Main St.</address1>
    <city>San Francisco</city>
    <state>CA</state>
    <zip>94105</zip>
    <country>US</country>
  </address>
  <shipping_addresses>
    <shipping_address>
      <nickname>Work</nickname>
      <first_name>Verena</first_name>
      <last_name>Example</last_name>
      <company>Recurly Inc</company>
      <phone>555-222-1212</phone>
      <email>verena@example.com</email>
      <address1>123 Main St.</address1>
      <address2>Suite 101</address2>
      <city>San Francisco</city>
      <state>CA</state>
      <zip>94105</zip>
      <country>US</country>
    </shipping_address>
    <shipping_address>
      <nickname>Home</nickname>
      <first_name>Verena</first_name>
      <last_name>Example</last_name>
      <phone>555-867-5309</phone>
      <email>verena@example.com</email>
      <address1>123 Fourth St.</address1>
      <address2>Apt. 101</address2>
      <city>San Francisco</city>
      <state>CA</state>
      <zip>94105</zip>
      <country>US</country>
    </shipping_address>
  </shipping_addresses>
</account>

This is an example of the request. In the response, it will be a tag with a link to the shipping addresses data, like so:

<shipping_addresses href="https://your-subdomain.recurly.com/v2/accounts/1/shipping_addresses"/>

So when you create a shipping address, you actually create an array of shipping addresses, and push each Recurly_ShippingAddress into that array.

    // work shipping address
    $shad1 = new Recurly_ShippingAddress();
    $shad1->nickname = "Work";
    $shad1->first_name = "Verena";
    $shad1->last_name = "Example";
    $shad1->company = "Recurly Inc.";
    $shad1->phone = "555-555-5555";
    $shad1->email = "verena@example.com";
    $shad1->address1 = "123 Main St.";
    $shad1->city = "San Francisco";
    $shad1->state = "CA";
    $shad1->zip = "94110";
    $shad1->country = "US";

    // home shipping address
    $shad2 = new Recurly_ShippingAddress();
    $shad2->nickname = "Home";
    $shad2->first_name = "Verena";
    $shad2->last_name = "Example";
    $shad2->phone = "555-555-5555";
    $shad2->email = "verena@example.com";
    $shad2->address1 = "123 Dolores St.";
    $shad2->city = "San Francisco";
    $shad2->state = "CA";
    $shad2->zip = "94110";
    $shad2->country = "US";

    $account->shipping_addresses = array($shad1, $shad2);

@aaron-junot aaron-junot merged commit 00c00ca into recurly:master Oct 23, 2018
@aaron-junot
Copy link

I added the above example of shipping_addresses to the PHP example on the dev docs for v2.16. Thanks for pointing out the confusion, I'm sure this will help others trying to set up an integration using the PHP library

@bhelx bhelx added the V2 V2 Client label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants