Kind of... actually the "allowFundingSources" needs to be OUTSIDE the "purchaseOrder" array so that it looks like this (note the bold and where it is, otherwise it will not show the right screen in dwolla):
$dwollaJson = array(
'key' => MODULE_PAYMENT_DWOLLA_API_KEY,
'secret' => MODULE_PAYMENT_DWOLLA_API_CODE,
//'callback' => zen_href_link('dwolla_main_handler.php', '', 'SSL',false,false,true),
'redirect' => zen_href_link(FILENAME_CHECKOUT_PROCESS, 'referer=dwolla', 'SSL'),
'callback' => 'put your callback url here: we do not have a handler yet, but this is where it will go',
//sending custid,sendto, billto, and zenSessionid as orderid. Will split this up in dwolla_main_handler.php (our future callback file)
'orderId' => $_SESSION['customer_id']. '::' . $_SESSION['billto'] . '::' . $_SESSION['sendto'] . '::' . zen_session_id(),
'test' => (MODULE_PAYMENT_DWOLLA_SERVER == 'Test') ? 'true' : 'false',
'allowFundingSources' => 'true',
'purchaseOrder' => array(
'destinationId' => MODULE_PAYMENT_DWOLLA_DESTINATION_ID,
'discount' => $discount,
'shipping' => $shipping,
'tax' => $tax,
'total' => $total - $dwolladiscount,
'orderItems' => $items,
'notes' => 'Order from ZenCart. Session Name ' . zen_session_name() . ' / ID #' . zen_session_id()
)
);
Additionally, about the discounts, in the dwolla.php file, you will see the $dwolladiscount var. You can use one of the following two ways (note that the one for a percentage is commented out)
// This can be discounts, low order fees, etc
// When the value is negative, it means that
// theres a discount(s) applied.
// When the value is positive, there's a
// fee applied.
//The following is for no discount on an exact money amount:
$dwolladiscount = 0.00;
// Or use this for a percentage of say 1.5% fpr using dwolla:
// $dwolladiscount = $total * 0.015
$discount -= $dwolladiscount;
if($discount > 0) {
$items[] = array(
'Description' => 'Extra Merchant Fees',
'Name' => 'Fee',
'Price' => $discount,
'Quantity' => 1
);
} else {
}
What we could do is wrap that whole section up into an if condition and get environment information from settings in the modules configuration to use either the percentage or the dollar amount dynamically. I am still working on the callback feature so that this thing works pretty much like a paypal version so the orders are handled via server to server calls. I am looking to see how to move the orders from the customer basket table to the orders table without losing anything, and whether that needs to be done via the ZENID or the CustomerId. One of the two will need to be passed to dwolla and then it will be returned both as a server to server call AND as url parameters when the user is redirected back to the site. Clearly we would rather the server to server handle that as we do not know the user will always land back on the site.
I will keep you posted. In the meantime, if you know anything about how to handle the movement of baskets to orders, let me know. And if you have any questions about the other stuff, let me know that too :-)
Cheers
Bookmarks