/** * Get params from Svea API * * @throws Mage_Core_Exception If 'client_country' paymentplan config option isn't set * * @return type response or error */ public function getPaymentPlanParams($id = null, $scope = null) { switch ($scope) { case 'store': $paymentMethodConfig = Mage::getStoreConfig('payment/svea_paymentplan', $id); break; case 'website': $paymentMethodConfig = Mage::app()->getWebsite($id)->getConfig('payment/svea_paymentplan'); break; default: $paymentMethodConfig = Mage::getStoreConfig('payment/svea_paymentplan'); break; } if (!array_key_exists('client_country', $paymentMethodConfig)) { throw new Mage_Core_Exception("Error: Client Country not set."); } $conf = new SveaMageConfigProvider($paymentMethodConfig); $sveaObject = WebPay::getPaymentPlanParams($conf); $response = $sveaObject->setCountryCode($paymentMethodConfig['client_country'])->doRequest(); if ($response->accepted == 1) { return $this->formatResponse($response); } else { return $response->resultcode . " : " . $response->errormessage; } }
/** * Use to get paymentPlanParams to be able to test PaymentPlanRequest * @return type */ public function getGetPaymentPlanParamsForTesting() { $config = Svea\SveaConfig::getDefaultConfig(); $addressRequest = WebPay::getPaymentPlanParams($config); $response = $addressRequest->setCountryCode("SE")->doRequest(); return $response->campaignCodes[0]->campaignCode; }
public function test_paymentPlanPricePerMonth_returns_PaymentPlanPricePerMonth() { $campaigns = WebPay::getPaymentPlanParams(\Svea\SveaConfig::getDefaultConfig())->setCountryCode("SE")->doRequest(); $this->assertTrue($campaigns->accepted); $pricesPerMonth = \Svea\Helper::paymentPlanPricePerMonth(2000, $campaigns, true); $this->assertInstanceOf("Svea\\WebService\\PaymentPlanPricePerMonth", $pricesPerMonth); // $this->assertEquals(213060, $pricesPerMonth->values[0]['campaignCode']);//don't test to be flexible $this->assertEquals(2029, $pricesPerMonth->values[0]['pricePerMonth']); }
public function testBuildRequest() { $config = Svea\SveaConfig::getDefaultConfig(); $addressRequest = WebPay::getPaymentPlanParams($config); $request = $addressRequest->setCountryCode("SE")->prepareRequest(); $this->assertEquals(59999, $request->request->Auth->ClientNumber); //Check all in identity $this->assertEquals("sverigetest", $request->request->Auth->Username); //Check all in identity $this->assertEquals("sverigetest", $request->request->Auth->Password); //Check all in identity }
public function test_getPaymentPlanParams_returns_GetPaymentPlanParams() { $request = WebPay::getPaymentPlanParams(Svea\SveaConfig::getDefaultConfig()); $this->assertInstanceOf("Svea\\WebService\\GetPaymentPlanParams", $request); }
/** * @expectedException Exception * @expectedExceptionMessage * -missing parameter: This method requires an ConfigurationProvider object as parameter. Create a class that implements class ConfigurationProvider. Set returnvalues to configuration values. Create an object from that class. Alternative use static function from class SveaConfig e.g. SveaConfig::getDefaultConfig(). You can replace the default config values to return your own config values in the method. */ public function testFailOnMissingCofigurationProviderGetPaymentPlanParams() { $object = \WebPay::getPaymentPlanParams(); }