Esempio n. 1
0
 /**
  * @test
  */
 public function itShouldCreateAnIdealOrder()
 {
     $order = Order::create(1234, 'EUR', 'ideal', ['issuer_id' => 'ABNANL2A'], 'A nice description', 'my-order-id', 'http://www.example.com', 'PT10M');
     $this->httpClient->shouldReceive('post')->once()->with('orders/', m::on(function (array $options) use($order) {
         $this->assertEquals(3, $options['timeout']);
         $this->assertEquals('application/json', $options['headers']['Content-Type']);
         $this->assertEquals(ArrayFunctions::withoutNullValues($order->toArray()), json_decode($options['body'], true));
         return true;
     }))->andReturn($this->httpResponse);
     $this->httpResponse->shouldReceive('json')->once()->andReturn(ArrayFunctions::withoutNullValues($order->toArray()));
     $this->assertInstanceOf('GingerPayments\\Payment\\Order', $this->client->createIdealOrder(1234, 'EUR', 'ABNANL2A', 'A nice description', 'my-order-id', 'http://www.example.com', 'PT10M'));
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function itShouldCreate()
 {
     $order = Order::create(6500, 'EUR', 'credit-card', [], 'My description', 'my-order-id', 'http://www.example.com', 'P0Y0M0DT1H0M0S');
     $this->assertEquals(6500, $order->amount()->toInteger());
     $this->assertEquals('EUR', (string) $order->currency());
     $this->assertEquals('My description', (string) $order->description());
     $this->assertEquals('my-order-id', (string) $order->merchantOrderId());
     $this->assertEquals('http://www.example.com', (string) $order->returnUrl());
     $this->assertEquals('P0Y0M0DT1H0M0S', $order->expirationPeriod()->format('P%yY%mM%dDT%hH%iM%sS'));
     /** @var Transaction $transaction */
     foreach ($order->transactions() as $transaction) {
         $this->assertEquals('credit-card', (string) $transaction->paymentMethod());
         $this->assertEquals([], $transaction->paymentMethodDetails()->toArray());
     }
 }
Esempio n. 3
0
 /**
  * @test
  */
 public function itShouldCreate()
 {
     $customer = ['address' => "Radarweg 29 A-12 1043 NX Amsterdam", 'address_type' => "customer", 'country' => "NL", 'email_address' => "*****@*****.**", 'first_name' => "Name", 'last_name' => "Lastname", 'merchant_customer_id' => "2", 'phone_numbers' => ["01234567890"], 'postal_code' => "1043 NX", 'housenumber' => "29 A-12"];
     $order = Order::create(6500, 'EUR', 'credit-card', [], 'My description', 'my-order-id', 'http://www.example.com', 'P0Y0M0DT1H0M0S', $customer);
     $this->assertEquals(6500, $order->amount()->toInteger());
     $this->assertEquals('EUR', (string) $order->currency());
     $this->assertEquals('My description', (string) $order->description());
     $this->assertEquals('my-order-id', (string) $order->merchantOrderId());
     $this->assertEquals('http://www.example.com', (string) $order->returnUrl());
     $this->assertEquals('P0Y0M0DT1H0M0S', $order->expirationPeriod()->format('P%yY%mM%dDT%hH%iM%sS'));
     /** @var Transaction $transaction */
     foreach ($order->transactions() as $transaction) {
         $this->assertEquals('credit-card', (string) $transaction->paymentMethod());
         $this->assertEquals([], $transaction->paymentMethodDetails()->toArray());
     }
 }
Esempio n. 4
0
 /**
  * Create a new order.
  *
  * @param integer $amount Amount in cents.
  * @param string $currency A valid currency code.
  * @param string $paymentMethod The payment method to use.
  * @param array $paymentMethodDetails An array of extra payment method details.
  * @param string $description A description of the order.
  * @param string $merchantOrderId A merchant-defined order identifier.
  * @param string $returnUrl The return URL.
  * @param string $expirationPeriod The expiration period as an ISO 8601 duration
  * @param array $customer Customer information.
  * @param array $extra Extra information.
  * @param string $webhookUrl The webhook URL.
  *
  * @return Order The newly created order.
  */
 public function createOrder($amount, $currency, $paymentMethod, array $paymentMethodDetails = [], $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null)
 {
     return $this->postOrder(Order::create($amount, $currency, $paymentMethod, $paymentMethodDetails, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl));
 }