Пример #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
 /**
  * Transforms object to array and sends it to SveaWebPay Europe Web service API by php SoapClient
  * @return CreateOrderEuResponse
  * @throws \Svea\ValidationException
  */
 public function doRequest()
 {
     $object = $this->prepareRequest();
     $request = new WebServiceSoap\SveaDoRequest($this->order->conf, $this->orderType);
     $svea_req = $request->CreateOrderEu($object);
     $response = new \SveaResponse($svea_req, "");
     return $response->getResponse();
 }
 /**
  * Set up the soap client and perform the soap call, with the soap action and prepared request from the relevant subclass.
  * Returns the appropriate request response class, as determined by SveaResponse matching on request action.
  */
 public function doRequest($resendOrderWithFlippedPriceIncludingVat = false)
 {
     $requestObject = $this->prepareRequest($resendOrderWithFlippedPriceIncludingVat);
     $soapClient = new AdminSoap\SoapClient($this->orderBuilder->conf, \ConfigurationProvider::ADMIN_TYPE);
     $soapResponse = $soapClient->doSoapCall($this->action, $requestObject);
     $sveaResponse = new \SveaResponse($soapResponse, null, null, $this->action);
     $response = $sveaResponse->getResponse();
     // iff error 50036, flip priceIncludingVat and resend enforcing flipped value
     if ($response->resultcode == "50036") {
         if (property_exists($requestObject, 'OrderRows')) {
             $priceIncludingVat = $requestObject->OrderRows->enc_value->enc_value[0]->enc_value->PriceIncludingVat->enc_value;
         } elseif (property_exists($requestObject, 'UpdatedOrderRows')) {
             $priceIncludingVat = $requestObject->UpdatedOrderRows->enc_value->enc_value[0]->enc_value->PriceIncludingVat->enc_value;
         } else {
             $priceIncludingVat = $this->priceIncludingVat;
         }
         $this->priceIncludingVat = !$priceIncludingVat;
         return $this->doRequest(true);
     } else {
         return $sveaResponse->getResponse();
     }
 }
 * 
 * @author Kristian Grossman-madsen for Svea WebPay
 */
error_reporting(E_ALL);
ini_set('display_errors', 'On');
// Include Svea PHP integration package.
$svea_directory = "../../src/";
require_once $svea_directory . "Includes.php";
// get config object
$myConfig = Svea\SveaConfig::getTestConfig();
$countryCode = "SE";
// should match request countryCode
// the raw request response is posted to the returnurl (this page) from Svea.
$rawResponse = $_POST;
// decode the raw response by passing it through the SveaResponse class
$myResponse = new SveaResponse($rawResponse, $countryCode, $myConfig);
// abort if request failed
if ($myResponse->getResponse()->accepted == 0) {
    echo "<pre>Request failed. aborting";
    print_r($myResponse->getResponse());
    die;
}
// The decoded response is available through the ->getResponse() method.
// Check the response attribute 'accepted' for true to see if the request succeeded, if not, see the attributes resultcode and/or errormessage
echo "<pre>Your inital card order request response, including the the subscription id for use in future recur order requests:\n\n";
print_r($myResponse->getResponse());
// save the subscriptionid to a file, for use in recurorder.php
$mySubscriptionId = $myResponse->getResponse()->subscriptionId;
file_put_contents("subscription.txt", $mySubscriptionId);
$recurorderUrl = "http://localhost/" . getPath() . "/recurorder.php";
echo "\nFollow the link to place a recur card order using subscriptionId {$mySubscriptionId}:\n";
Пример #5
0
<?php

/**
 * example file, how to handle a card order request response
 * 
 * @author Kristian Grossman-madsen for Svea WebPay
 */
error_reporting(E_ALL);
ini_set('display_errors', 'On');
// Include Svea PHP integration package.
$svea_directory = "../../src/";
require_once $svea_directory . "Includes.php";
// get config object
$myConfig = Svea\SveaConfig::getTestConfig();
$countryCode = "SE";
// should match request countryCode
// the raw request response is posted to the returnurl (this page) from Svea.
$rawResponse = $_POST;
// decode the raw response by passing it through the SveaResponse class
$myResponse = new SveaResponse($rawResponse, $countryCode, $myConfig);
// The decoded response is available through the ->getResponse() method.
// Check the response attribute 'accepted' for true to see if the request succeeded, if not, see the attributes resultcode and/or errormessage
echo "<pre>Your request response:\n\n";
print_r($myResponse->getResponse());
echo "\n</pre><font color='blue'><pre>\n\n\n\nAn example of a successful request response. The 'accepted' attribute is true (1), and resultcode/errormessage is not set.\n\nSvea\\HostedPaymentResponse Object\n(\n    [transactionId] => 582827\n    [clientOrderNumber] => order #20140519-374\n    [paymentMethod] => KORTCERT\n    [merchantId] => 1130\n    [amount] => 23.74\n    [currency] => SEK\n    [accepted] => 1\n    [resultcode] => \n    [cardType] => VISA\n    [maskedCardNumber] => 444433xxxxxx1100\n    [expiryMonth] => 02\n    [expiryYear] => 15\n    [authCode] => 941033\n)";
echo "\n</pre><font color='red'><pre>\n\n\n\nAn example of a rejected request response -- 'accepted' is false (0) and resultcode/errormessage indicates that the clientOrderNumber above has been reused, which is prohibited.   \n\nSvea\\HostedPaymentResponse Object\n(\n    [transactionId] => 582828\n    [clientOrderNumber] => order #20140519-374.err\n    [paymentMethod] => KORTCERT\n    [merchantId] => 1130\n    [amount] => 23.74\n    [currency] => SEK\n    [accepted] => 0\n    [resultcode] => 127 (CUSTOMERREFNO_ALREADY_USED)\n    [errormessage] => Customer reference number already used in another transaction.\n)";
 * 
 * @author Kristian Grossman-madsen for Svea WebPay
 */
error_reporting(E_ALL);
ini_set('display_errors', 'On');
// Include Svea PHP integration package.
$svea_directory = "../../src/";
require_once $svea_directory . "Includes.php";
// get config object
$myConfig = Svea\SveaConfig::getTestConfig();
$countryCode = "SE";
// should match request countryCode
// the raw request response is posted to the returnurl (this page) from Svea.
$rawResponse = $_POST;
// decode the raw response by passing it through the SveaResponse class
$myResponse = new SveaResponse($rawResponse, $countryCode, $myConfig);
// abort if request failed
if ($myResponse->getResponse()->accepted == 0) {
    echo "<pre>Request failed. aborting";
    print_r($myResponse->getResponse());
    die;
}
// The decoded response is available through the ->getResponse() method.
// Check the response attribute 'accepted' for true to see if the request succeeded, if not, see the attributes resultcode and/or errormessage
echo "<pre>Your card order request response, this is the transaction to be credited in the next step:\n\n";
print_r($myResponse->getResponse());
// save the subscriptionid to a file, for use in recurorder.php
$myTransactionId = $myResponse->getResponse()->transactionId;
file_put_contents("transactionid.txt", $myTransactionId);
$creditorderrowsUrl = "http://localhost/" . getPath() . "/creditorderrows.php";
echo "\nFollow the link to credit all rows in this order ({$myTransactionId}):\n";