print "The customer: " . $customer->uri . "\n"; // Add Card to Customer $customer->addCard($card->uri); // Hold some funds print "Create a Hold for some funds, \$15\n"; $hold = $marketplace->holds->create(array("amount" => 1500, "description" => "Some descriptive text for the debit in the dashboard", "source_uri" => $card->uri)); // Capture the hold print "Capture the Hold (for the full amount)\n"; $debit = $hold->capture(); // Check escrow for new funds from debit $marketplace = Balanced\Marketplace::mine(); if ($marketplace->in_escrow != 1500) { throw new Exception("1500 is not in escrow! This is wrong"); } print "Escrow amount: " . $marketplace->in_escrow . " \n"; print "Refund the full amount\n"; $refund = $debit->refund(); // Create a bank account $bank_account = new \Balanced\BankAccount(array("account_number" => "9900000001", "name" => "Johann Bernoulli", "routing_number" => "121000358", "type" => "checking")); $bank_account->save(); // Create a Customer who is the seller $seller = new \Balanced\Customer(array("name" => "Billy Jones", "email" => "*****@*****.**", "street_address" => "801 High St", "postal_code" => "94301", "country" => "USA", "dob" => "1979-02")); $seller->save(); // Add bank account to seller $seller->addBankAccount($bank_account->uri); print "Debit the customer for \$130\n"; $debit = $customer->debit(13000, "MARKETPLACE.COM"); print "Credit the seller \$110\n"; $credit = $seller->credit(11000, "Buyer purchased something on Marketplace.com"); print "The marketplace charges 15%, so it earned \$20\n"; $mp_credit = $marketplace->owner_customer->credit(2000, "Commission from MARKETPLACE.COM");