Alex914 Posted February 15, 2015 Share Posted February 15, 2015 Hello,How generate an invoice with IPS 4 on a page outside IPS Commerce? Is that possible? Like IPS 3: https://www.invisionpower.com/support/guides/_/advanced-and-developers/ipnexus/how-to-interact-with-purchases-r113 Link to comment Share on other sites More sharing options...
Mark Posted February 16, 2015 Share Posted February 16, 2015 $invoice = new \IPS\nexus\Invoice; $invoice->member = \IPS\nexus\Customer::load( 1 ); // Pass customer ID number $item = new \IPS\nexus\extensions\nexus\Item\MiscellaneousCharge( "Example", new \IPS\nexus\Money( 10, 'USD' ) ); // Object of the type of item you want. For example, files in IP.Downloads are \IPS\downloads\extensions\nexus\Item\File, normal packages are \IPS\nexus\extensions\nexus\Item\Package // Set other properties like $item->tax, $item->renewalTerm, $item->quantity, etc. All optional. Some examples: $item->quantity = 2; $item->id = 1; // If required depending on item type $item->tax = \IPS\nexus\Tax::load( 1 ); $item->paymentMethodIds = array( 1, 2, 3 ); // Acceptable payment method IDs $item->details = array( 'Color' => 'Red' ); // If required depending on item type // These only available for subclasses of \IPS\nexus\Invoice\Item\Purchase: $item->renewalTerm = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( 1, 'USD' ), new \DateInterval('P1M') ); $item->expireDate = new \IPS\DateTime( ... ); // Will be set automatically if renewalTerm is provided $item->parent = \IPS\nexus\Purchase::load( 1 ); // Pass ID number of parent purchase // These required for physical items... $item->physical = TRUE; $item->weight = new \IPS\nexus\Shipping\Weight( 5 ); $item->length = new \IPS\nexus\Shipping\Length( 1 ); $item->width = new \IPS\nexus\Shipping\Length( 1 ); $item->height = new \IPS\nexus\Shipping\Length( 1 ); // These for giving commission to other members (like for Downloads files): $item->payTo = \IPS\Member::load( 2 ); // Pass member ID $item->commission = 20; // % $item->fee = new \IPS\nexus\Money( 1, 'USD' ); $invoice->addItem( $item ); // Repeat for any other items $invoice->save(); \IPS\Output::i()->redirect( $invoice->checkoutUrl() ); Link to comment Share on other sites More sharing options...
Alex914 Posted February 16, 2015 Author Share Posted February 16, 2015 Thanks so much! Link to comment Share on other sites More sharing options...
CodingJungle Posted March 11, 2015 Share Posted March 11, 2015 yep thanks @Mark Link to comment Share on other sites More sharing options...
CodingJungle Posted March 11, 2015 Share Posted March 11, 2015 you need to pass one more property to invoice or it errors out:$invoice->currency = "USD";and if you want it to generate a purchase too:$invoice->markPaid();after $invoice->save(); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.