コード例 #1
0
 /**
  * Investigation of github php-integration issue #39.
  *
  * Also, an example of how to parse a HostedPaymentRequest response, i.e. at
  * the WebPay::createOrder()->..->useCardPayment->getPaymentForm() returnurl
  * by passing the response post data through SveaResponse() to get a response
  * object matching the original payment request.
  */
 public function test_successful_test_card_order_has_accepted_non_zero()
 {
     // getSingleCountryConfig fetches a SveaConfigurationProvider object that implements ConfigurationProvider
     // as we don't set any parameters, the object contains only default values, i.e. the merchantid used is 1130
     $config = SveaConfig::getSingleCountryConfig(null, null, null, null, null, null, null, null, null, false);
     // $message, $mac and $merchantid below was taken from server logs for a test card transaction to the merchant 1130
     $message = "PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz48cmVzcG9uc2U+PHRyYW5zYWN0aW9uIGlkPSI1ODEzODAiPjxwYXltZW50bWV0aG9kPktPUlRDRVJUPC9wYXltZW50bWV0aG9kPjxtZXJjaGFudGlkPjExMzA8L21lcmNoYW50aWQ+PGN1c3RvbWVycmVmbm8+MzY8L2N1c3RvbWVycmVmbm8+PGFtb3VudD4xODU3ODwvYW1vdW50PjxjdXJyZW5jeT5TRUs8L2N1cnJlbmN5PjxjYXJkdHlwZT5WSVNBPC9jYXJkdHlwZT48bWFza2VkY2FyZG5vPjQ0NDQzM3h4eHh4eDExMDA8L21hc2tlZGNhcmRubz48ZXhwaXJ5bW9udGg+MDE8L2V4cGlyeW1vbnRoPjxleHBpcnl5ZWFyPjE1PC9leHBpcnl5ZWFyPjxhdXRoY29kZT40NTM2MjY8L2F1dGhjb2RlPjxjdXN0b21lcj48Zmlyc3RuYW1lLz48bGFzdG5hbWUvPjxpbml0aWFscy8+PGVtYWlsPnRlc3RAdGltLWludGVybmF0aW9uYWwubmV0PC9lbWFpbD48c3NuPjwvc3NuPjxhZGRyZXNzPktsb2NrYXJnYXRhbiA1QzwvYWRkcmVzcz48YWRkcmVzczIvPjxjaXR5PlbDpHN0ZXLDpXM8L2NpdHk+PGNvdW50cnk+U0U8L2NvdW50cnk+PHppcD43MjM0NDwvemlwPjxwaG9uZT40NjcwNDE2MDA5MDwvcGhvbmU+PHZhdG51bWJlci8+PGhvdXNlbnVtYmVyPjU8L2hvdXNlbnVtYmVyPjxjb21wYW55bmFtZS8+PGZ1bGxuYW1lLz48L2N1c3RvbWVyPjwvdHJhbnNhY3Rpb24+PHN0YXR1c2NvZGU+MDwvc3RhdHVzY29kZT48L3Jlc3BvbnNlPg==";
     $mac = "0411ed66739c251308b70c642fc5f7282f89050421408b74bdd909fb0c13c37c4c2efd6da3593dc388dd28952478aeb1ce5259caf33fd68d364fc4f82914e055";
     $merchantId = $config->getMerchantId(\ConfigurationProvider::HOSTED_TYPE, "SE");
     // the $rawresponse is similar to what we get posted back to our return url following a CardPayment post to i.e. the certitrade payment page
     $rawresponse = array();
     $rawresponse['response'] = $message;
     $rawresponse['mac'] = $mac;
     $rawresponse['merchantId'] = $merchantId;
     // $rawresponse is then put into the SveaResponse constructor along with the country and config object
     $sveaResponse = new \SveaResponse($rawresponse, "SE", $config);
     // the resulting $response HostedPaymentResponse object contains all relevant information about the payment
     $response = $sveaResponse->getResponse();
     // uncomment the following to see the resulting response
     //        //print_r( $response ); // accepted is show as having value of 1
     //        var_dump( $response );  // note that var_dump lists accepted as 'int(1)' meaning an int with value 1 (in contrast to 'string(3) "SEK"')
     //
     //        if( empty($response->accepted) ) { //print_r( "test accepted is empty" ); }
     //        if( !empty($response->accepted) ) { //print_r( "test accepted not empty" ); }
     $this->assertInstanceOf('Svea\\HostedService\\HostedPaymentResponse', $response);
     $this->assertEquals(1, $response->accepted);
 }
コード例 #2
0
 /**
  * @expectedException Svea\InvalidCountryException
  */
 public function test_getSveaSingleCountryConfig_throws_InvalidCountryException_for_invalid_country()
 {
     $config = SveaConfig::getSingleCountryConfig(null, null, null, null, null, null, null, null, null, null);
     $config->getUsername(\ConfigurationProvider::INVOICE_TYPE, "NO");
 }