Example #1
0
 public function testCreateForBitcoinViaCharge()
 {
     self::authorizeFromEnv();
     $receiver = $this->createTestBitcoinReceiver("*****@*****.**");
     $charge = Charge::create(array('amount' => $receiver->amount, 'currency' => $receiver->currency, 'description' => $receiver->description, 'source' => $receiver->id));
     $ref = $charge->refunds->create(array('amount' => $receiver->amount, 'refund_address' => 'ABCDEF'));
     $this->assertSame($receiver->amount, $ref->amount);
     $this->assertNotNull($ref->id);
 }
 public function testBadData()
 {
     self::authorizeFromEnv();
     try {
         Charge::create();
     } catch (Error\InvalidRequest $e) {
         $this->assertSame(400, $e->getHttpStatus());
     }
 }
Example #3
0
 public function markAsSafe()
 {
     self::authorizeFromEnv();
     $card = array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => date('Y') + 1);
     $charge = Charge::create(array('amount' => 100, 'currency' => 'usd', 'card' => $card));
     $charge->markAsSafe();
     $updatedCharge = Charge::retrieve($charge->id);
     $this->assertSame('safe', $updatedCharge['fraud_details']['user_report']);
 }
Example #4
0
 public function testDeleteWithCustomer()
 {
     self::authorizeFromEnv();
     $receiver = $this->createTestBitcoinReceiver("*****@*****.**");
     $customer = Customer::create(array("source" => $receiver->id));
     $charge = Charge::create(array("customer" => $customer->id, "amount" => $receiver->amount, "currency" => $receiver->currency));
     $receiver = BitcoinReceiver::retrieve($receiver->id);
     $response = $receiver->delete();
     $this->assertTrue($response->deleted);
 }
 /**
  * Store a newly created resource in storage.
  * POST /chares
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('type' => 'required', 'amount' => 'required'));
     if ($v->passes()) {
         Charge::create($input);
         return Redirect::intended('admin/charge');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
Example #6
0
 public function testExpiredCard()
 {
     self::authorizeFromEnv();
     $card = array('number' => '4242424242424242', 'exp_month' => '3', 'exp_year' => '2010');
     $charge = array('amount' => 100, 'currency' => 'usd', 'card' => $card);
     try {
         Charge::create($charge);
     } catch (Error\Card $e) {
         $this->assertSame(402, $e->getHttpStatus());
     }
 }
Example #7
0
 public function testDecline()
 {
     self::authorizeFromEnv();
     $card = array('number' => '4000000000000002', 'exp_month' => '3', 'exp_year' => '2020');
     $charge = array('amount' => 100, 'currency' => 'usd', 'card' => $card);
     try {
         Charge::create($charge);
     } catch (Error\Card $e) {
         $this->assertSame(402, $e->getHttpStatus());
         $actual = $e->getJsonBody();
         $this->assertSame(array('error' => array('message' => 'Your card was declined.', 'type' => 'card_error', 'code' => 'card_declined', 'charge' => $actual['error']['charge'])), $actual);
     }
 }
 private function createDisputedCharge()
 {
     $card = array('number' => '4000000000000259', 'exp_month' => 5, 'exp_year' => date('Y') + 1);
     $c = Charge::create(array('amount' => 100, 'currency' => 'usd', 'card' => $card));
     $c = Charge::retrieve($c->id);
     $attempts = 0;
     while ($c->dispute === null) {
         if ($attempts > 5) {
             throw new \Exception("Charge is taking too long to be disputed");
         }
         sleep(1);
         $c = Charge::retrieve($c->id);
         $attempts += 1;
     }
     return $c;
 }
Example #9
0
 /**
  * Create a valid test charge.
  */
 protected static function createTestCharge(array $attributes = array())
 {
     self::authorizeFromEnv();
     return Charge::create($attributes + array('amount' => 2000, 'currency' => 'usd', 'description' => 'Charge for test@example.com', 'card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => date('Y') + 3)));
 }
      <div class="row setup-content" id="step-3">
        <div class="col-xs-12">
          <div class="col-xs-4">
            <h3> Step 3</h3>
            <div class="display-td" >

              <p><label>We Accept:</label><img class="img-responsive pull-right" src="http://i76.imgup.net/accepted_c22e0.png"><p>
              </div>
              <br>
              <div>
                <?php 
require_once 'stripe/lib/Stripe.php';
$stripe = array("secret_key" => "sk_test_iPRnWiX1PBNTy46dddBxvel2", "publishable_key" => "pk_test_WJiLHtgmyGmBfRE0VmywzjS9");
\Stripe\Stripe::setApiKey($stripe['secret_key']);
if ($_POST) {
    $charge = Stripe / Charge::create(array('card' => $_POST['stripeToken'], 'amount' => 5000, 'currency' => 'usd'));
    echo '<h1>Successfully charged <?=$total?>!</h1>';
}
?>
                <form action="/products/product_page" method="post">
                  <script src="https://button.stripe.com/v1/button.js" class="stripe-button"
                  data-key="<?php 
echo $stripe['publishable_key'];
?>
"
                  data-description="Secure Purchase";
                  data-amount="",
                  data-locale="auto"></script>
                </form>
              </div>
            </div>
Example #11
0
    $fournisseur = GETPOST("fournisseur");
    $nouveau_fournisseur = GETPOST("nouveau_fournisseur");
    if (!empty($nouveau_fournisseur)) {
        $charge->fournisseur = $nouveau_fournisseur;
    } elseif (!empty($fournisseur)) {
        $charge->fournisseur = $fournisseur;
    }
    $charge->local_id = GETPOST("local_id");
    $charge->type = GETPOST("type");
    $charge->montant_ttc = GETPOST("montant_ttc");
    $charge->date_acq = $dateacq;
    $charge->periode_du = $datedu;
    $charge->periode_au = $dateau;
    $charge->proprietaire_id = GETPOST("proprietaire_id");
    $e_charge = $charge;
    $res = $charge->create($user);
    if ($res == 0) {
    } else {
        if ($res == -3) {
            $_error = 1;
            $action = "create";
        }
        if ($res == -4) {
            $_error = 2;
            $action = "create";
        }
    }
    Header("Location: " . DOL_URL_ROOT . "/immobilier/charges.php");
} elseif (GETPOST("action") == 'maj') {
    $error = 0;
    $dateacq = @dol_mktime($_POST["acqhour"], $_POST["acqmin"], $_POST["acqsec"], $_POST["acqmonth"], $_POST["acqday"], $_POST["acqyear"]);
Example #12
0
 public function testCustomerChargeAll()
 {
     $planID = 'gold-' . self::randomString();
     self::retrieveOrCreatePlan($planID);
     $customer = self::createTestCustomer();
     $charge = Charge::create(array('amount' => 1000, 'currency' => self::CURRENCY, 'customer' => $customer->id));
     $charges = $customer->charges();
     $this->assertSame(1, count($charges['data']));
     $this->assertSame($charge->id, $charges['data'][0]->id);
     $charge_2 = Charge::create(array('amount' => 1500, 'currency' => self::CURRENCY, 'customer' => $customer->id));
     $charges_2 = $customer->charges();
     $this->assertSame(2, count($charges_2['data']));
     $this->assertSame($charge_2->id, $charges_2['data'][0]->id);
     $this->assertSame($charge->id, $charges_2['data'][1]->id);
 }
Example #13
0
 public function testUnavailableCvcTest()
 {
     self::authorizeFromEnv();
     $card = array('number' => '4000000000000150', 'exp_month' => '05', 'exp_year' => date('Y') + 1 . "");
     $ch = Charge::create(array('amount' => 100, 'currency' => self::CURRENCY, 'card' => $card));
     $this->assertSame("unavailable", $ch->card->cvc_check);
 }