public static function chargeInvoiceArbitraryAmount($contactId, $invoiceId, $cardId, $amount, $merchantAccountId, $invoiceNotes = 'API Arbitrary Payment')
 {
     //Create a new order (InvoiceService.blankOrder...
     $dummyInvoiceId = Infusionsoft_InvoiceService::createBlankOrder($contactId, $invoiceNotes . " Invoice: " . $amount, date('Ymd\\TH:i:s'));
     try {
         //Add an order item that is the correct amount you want to charge...
         Infusionsoft_InvoiceService::addOrderItem($dummyInvoiceId, 0, 3, $amount, 1, $invoiceNotes . " order", "");
         //Set orders custom field "_ChargeStatus" to "Pending"
         $invoice = new Infusionsoft_Invoice($dummyInvoiceId);
         $dummyOrder = new Infusionsoft_Job($invoice->JobId);
         $dummyOrder->OrderStatus = "Pending";
         $dummyOrder->save();
         //Try to charge the invoice
         $result = Infusionsoft_InvoiceService::chargeInvoice($dummyInvoiceId, $invoiceNotes . " payment", $cardId, $merchantAccountId, false);
     } catch (Exception $e) {
         Infusionsoft_InvoiceService::deleteInvoice($dummyInvoiceId);
         throw new Exception("Failed to charge partial payment. Infusionsoft says: " . $e->getMessage());
     }
     //Update order status "_ChargeStatus" to "Failed", or "Succeeded"
     if ($result['Successful']) {
         //add a credit to the order
         Infusionsoft_InvoiceService::addManualPayment($invoiceId, $amount, date('Ymd\\TH:i:s'), "Credit Card", $invoiceNotes . " partial payment", false);
         $dummyOrder->OrderStatus = "Successful";
         $dummyOrder->save();
     } else {
         //erase the invoice
         Infusionsoft_InvoiceService::deleteInvoice($dummyInvoiceId);
     }
     return $result;
     //Update order status to "Applied"
 }
 public function save($app = null)
 {
     if ($this->Id == '') {
         $invoiceId = Infusionsoft_InvoiceService::createBlankOrder($this->ContactId, $this->JobNotes, date('Ymd\\TH:i:s', strtotime($this->StartDate)), 0, 0, $app);
         $invoice = new Infusionsoft_Invoice($invoiceId);
         $this->Id = $invoice->JobId;
     }
     $result = parent::save($app);
     return $result;
 }
예제 #3
0
 public function save($app = null)
 {
     if ($this->Id == '') {
         $invoiceId = Infusionsoft_InvoiceService::createBlankOrder($this->ContactId, $this->JobNotes, $this->DateCreated);
         $invoice = new Infusionsoft_Invoice($invoiceId);
         $this->Id = $invoice->JobId;
     }
     $result = parent::save($app);
     return $result;
 }
}
?>
"><br/>
            orderDate: <input type="text" name="orderDate" value="<?php 
if (isset($_REQUEST['orderDate'])) {
    echo htmlspecialchars($_REQUEST['orderDate']);
}
?>
"><br/>
            leadAffiliateId: <input type="text" name="leadAffiliateId" value="<?php 
if (isset($_REQUEST['leadAffiliateId'])) {
    echo htmlspecialchars($_REQUEST['leadAffiliateId']);
}
?>
"><br/>
            saleAffiliateId: <input type="text" name="saleAffiliateId" value="<?php 
if (isset($_REQUEST['saleAffiliateId'])) {
    echo htmlspecialchars($_REQUEST['saleAffiliateId']);
}
?>
"><br/>
    <input type="submit">
<input type="hidden" name="go">
</form>
<?php 
include '../infusionsoft.php';
include 'testUtils.php';
if (isset($_REQUEST['go'])) {
    $out = Infusionsoft_InvoiceService::createBlankOrder($_REQUEST['contactId'], $_REQUEST['description'], $_REQUEST['orderDate'], $_REQUEST['leadAffiliateId'], $_REQUEST['saleAffiliateId']);
    var_dump($out);
}