public function __construct(Order $order) { if (!$order) { dd('vantar pöntun'); } $this->order = $order; $this->testing = false; if (env('BORGUN_TEST') == true) { $this->site = 'https://test.borgun.is/SecurePay/default.aspx'; $this->testing = true; $this->PaymentGatewayId = '16'; $this->MerchantId = '9275444'; $this->SecretKey = '99887766'; } else { $this->site = 'https://securepay.borgun.is/securepay/default.aspx'; $this->PaymentGatewayId = env('BORGUN_PAYMENTGATEWAYID'); $this->MerchantId = env('BORGUN_MERCHANTID'); $this->SecretKey = env('BORGUN_SECRETKEY'); } $this->ReturnUrlSuccess = \Request::root() . '/payment/borgun/success'; $this->ReturnUrlSuccessServer = \Request::root() . '/payment/borgun/successserver'; $this->ReturnUrlCancel = \Request::root() . '/payment/borgun/cancel'; $this->ReturnUrlError = ''; $this->OrderId = $order->reference; $this->Amount = $order->total(); $this->Currency = 'ISK'; $this->Language = 'IS'; }
function test_an_order_is_discounted_by_a_percentage_when_a_percent_off_coupon_is_applied() { $books = collect([new Book(['price' => 2000]), new Book(['price' => 3000]), new Book(['price' => 4000])]); $coupon = new Coupon(['value' => 30, 'is_percent' => true]); $order = new Order($books); $order->applyCoupon($coupon); $this->assertEquals(6300, $order->total()); }
/** @test */ function an_order_can_determine_the_total_cost_of_all_its_products() { $order = new Order(); $product = new Product('Fallout 4', 59); $product2 = new Product('pillowcase', 7); $order->add($product); $order->add($product2); $this->assertEquals(66, $order->total()); }