/** * @test */ public function itShouldCreateWithCreditCard() { $order = Order::createWithCreditCard(6500, 'EUR', '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()); } }
/** * @test */ public function itShouldCreateWithCreditCard() { $customer = ['address' => "Radarweg 29 A-12 1043 NX Amsterdam", 'address_type' => "customer", 'country' => "NL", 'email_address' => "*****@*****.**", 'first_name' => "Firstname", 'last_name' => "Lastname", 'merchant_customer_id' => "2", 'phone_numbers' => ["0123456789"], 'postal_code' => "1043 NX", 'housenumber' => "29 A-12"]; $order = Order::createWithCreditCard(6500, 'EUR', '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()); } }
/** * Create a new credit card order. * * @param integer $amount Amount in cents. * @param string $currency A valid currency code. * @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. * * @return Order The newly created order. */ public function createCreditCardOrder($amount, $currency, $description = null, $merchantOrderId = null, $returnUrl = null, $expirationPeriod = null, $customer = null, $extra = null, $webhookUrl = null) { return $this->postOrder(Order::createWithCreditCard($amount, $currency, $description, $merchantOrderId, $returnUrl, $expirationPeriod, $customer, $extra, $webhookUrl)); }