Skip to content

Instantly share code, notes, and snippets.

@ChrisFlannagan
Last active May 11, 2016 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisFlannagan/c7cb218f192a4f36fc1eda4cb159c3bc to your computer and use it in GitHub Desktop.
Save ChrisFlannagan/c7cb218f192a4f36fc1eda4cb159c3bc to your computer and use it in GitHub Desktop.
<?php
//PayPal wants an array of InvoiceItem() objects
$items = array()
$cnt = 0;
foreach( $order['items'] as $item ) {
$items[ $cnt ] = new InvoiceItem();
$items[ $cnt ]
->setName( $item['outfit'] . '-' . $item['size'] )
->setQuantity( 1 )
->setUnitPrice( new Currency() );
$items[ $cnt ]->getUnitPrice()
->setCurrency( "USD" )
->setValue( $anitem['total'] );
if( $anorder['res'] == 'yes' ) {
$tax = new \PayPal\Api\Tax();
$tax->setPercent( 4 )->setName( "Local Tax" );
$items[ $cnt ]->setTax( $tax );
}
$cnt++;
}
$invoice->setItems( $items );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment