Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Grab customer_id when creating new subscription #5

Open
darylalexjohnson opened this issue Sep 7, 2012 · 0 comments
Open

Grab customer_id when creating new subscription #5

darylalexjohnson opened this issue Sep 7, 2012 · 0 comments

Comments

@darylalexjohnson
Copy link

I am using the following from your example in my application:

$customer = new ChargifyCustomer(NULL, CHARGIFY_TEST_MODE);

        // Create a ChargifyProduct object in test mode.
        $customer->email = $_POST['email'];
        $customer->first_name = $_POST['first_name'];
        $customer->last_name = $_POST['last_name'];


    $product = new ChargifyProduct(NULL, $CHARGIFY_TEST_MODE);
    $product->id = FREE_BUSINESS;

    $subscription = new ChargifySubscription(NULL, $CHARGIFY_TEST_MODE);
    $subscription->customer_attributes = $customer;

    // Uses the first exising product. Replace with a product handle string.
    $f_products = $product->getByID();

    $subscription->product_handle = $f_products->handle;
    // $subscription->customer_id = $cust_id->id;
    try {
      $new_subscription = $subscription->create();
      // $subscription_id = 
    } catch (ChargifyValidationException $cve) {
      // Error handling code.
      echo $cve->getMessage();
    }

I have been attempting several solutions to populate the $customer->id with the id created by Chargify. However anytime I attempt $customer->getByID() I am returned a fatal error from the ChargifyConnector.php. How can I get the customer ID of this newly created subscription?

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant