/** * Make sure we record the actual amount charged, even if the donor has * opened a new window and screwed up their session data. */ function testReturnUpdatesAmount() { $init = $this->getDonorTestData('BR'); $init['amount'] = '22.55'; // junk session data from another banner click $session['Donor']['order_id'] = '123456789'; $this->setUpRequest($init, $session); $gateway = new TestingAstroPayAdapter(); $amount = $gateway->getData_Unstaged_Escaped('amount'); $this->assertEquals('22.55', $amount); // Next lines mimic AstroPay resultswitcher $gateway->setCurrentTransaction('ProcessReturn'); $response = array('result' => '9', 'x_amount' => '100.00', 'x_amount_usd' => '42.05', 'x_control' => 'DDF89085AC70C0B0628150C51D64419D8592769F2439E3936570E26D24881730', 'x_description' => 'Donation to the Wikimedia Foundation', 'x_document' => '32869', 'x_iduser' => '08feb2d12771bbcfeb86', 'x_invoice' => '123456789'); $gateway->processResponse($response); $amount = $gateway->getData_Unstaged_Escaped('amount'); $this->assertEquals('100.00', $amount, 'Not recording correct amount'); }
public function testResetSubmethodOnMethodSwitch() { // Donor thinks they want to make a bank transfer, submits form $init = $this->getDonorTestData('BR'); $init['payment_method'] = 'bt'; $init['payment_submethod'] = 'itau'; $firstRequest = $this->setUpRequest($init); $gateway = new TestingAstroPayAdapter(); $gateway->do_transaction('Donate'); $donorData = $firstRequest->getSessionData('Donor'); $this->assertEquals('itau', $donorData['payment_submethod'], 'Test setup failed.'); // Then they go back and decide they want to donate via credit card $init['payment_method'] = 'cc'; unset($init['payment_submethod']); $secondRequest = $this->setUpRequest($init, $firstRequest->getSessionArray()); $gateway = new TestingAstroPayAdapter(); $newMethod = $gateway->getData_Unstaged_Escaped('payment_method'); $newSubmethod = $gateway->getData_Unstaged_Escaped('payment_submethod'); $this->assertEquals('cc', $newMethod, 'Test setup failed'); $this->assertEquals('', $newSubmethod, 'Submethod was not blanked on method switch'); }