Jump to content

[Commerce] nexusApi ?


Alex914

Recommended Posts

Posted
$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() );

 

  • 4 weeks later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...