Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 3dee9fa

Browse files
committed
Fixing installments of checkout preferences
1 parent 2fdc090 commit 3dee9fa

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Resource/Orders.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ protected function initialize()
118118
$this->data->receivers = [];
119119
$this->data->checkoutPreferences = new stdClass();
120120
$this->data->checkoutPreferences->redirectUrls = new stdClass();
121+
$this->data->checkoutPreferences->installments = [];
121122
}
122123

123124
/**
@@ -609,12 +610,14 @@ public function setUrlFailure($urlFailure = '')
609610
*
610611
* @return $this
611612
*/
612-
public function setInstallmentCheckoutPreferences($quantity, $discountValue = 0, $additionalValue = 0)
613+
public function addInstallmentCheckoutPreferences($quantity, $discountValue = 0, $additionalValue = 0)
613614
{
614-
$this->data->checkoutPreferences->installments = new stdClass();
615-
$this->data->checkoutPreferences->installments->quantity = $quantity;
616-
$this->data->checkoutPreferences->installments->discount = $discountValue;
617-
$this->data->checkoutPreferences->installments->addition = $additionalValue;
615+
$installmentCheckoutPreferences = new stdClass();
616+
$installmentCheckoutPreferences->quantity = $quantity;
617+
$installmentCheckoutPreferences->discount = $discountValue;
618+
$installmentCheckoutPreferences->addition = $additionalValue;
619+
620+
$this->data->checkoutPreferences->installments[] = $installmentCheckoutPreferences;
618621

619622
return $this;
620623
}

tests/Resource/OrdersTest.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,16 @@ public function testCreateOrderWithInstallmentPreferences()
120120
$quantity = [1, 6];
121121
$discount = 0;
122122
$additional = 100;
123-
$order = $this->createOrder()->setInstallmentCheckoutPreferences($quantity, $discount, $additional);
123+
$order = $this->createOrder()->addInstallmentCheckoutPreferences($quantity, $discount, $additional);
124124
$returned_order = $this->executeOrder($order);
125-
126125
$this->assertNotEmpty($returned_order->getId());
127-
$this->assertEquals([1, 6], $returned_order->getCheckoutPreferences()->installments->quantity);
126+
$this->assertEquals([1, 6], $returned_order->getCheckoutPreferences()->installments[0]->quantity);
128127
}
129128

130129
public function testCreateOrderAddingReceiverNoAmount()
131130
{
132131
$order = $this->createOrder()->addReceiver('MPA-7ED9D2D0BC81', 'PRIMARY');
133-
$returned_order = $this->executeOrder($order);
134-
$this->assertNotEmpty($returned_order->getId());
135-
$receivers = $returned_order->getReceiverIterator();
132+
$receivers = $order->getReceiverIterator();
136133
$this->assertEquals('MPA-7ED9D2D0BC81', $receivers[0]->moipAccount->id);
137134
}
138135

0 commit comments

Comments
 (0)