Пример #1
0
 /**
  * @covers            \JohnConde\Authnet\AuthnetJsonRequest::process()
  * @uses              \JohnConde\Authnet\AuthnetApiFactory::getJsonApiHandler
  * @uses              \JohnConde\Authnet\AuthnetApiFactory::getWebServiceURL
  */
 public function testGetHostedProfilePageRequest()
 {
     $requestJson = array('customerProfileId' => '31390172', 'hostedProfileSettings' => array('setting' => array('settingName' => 'hostedProfileReturnUrl', 'settingValue' => 'https://blah.com/blah/'), 'setting' => array('settingName' => 'hostedProfileReturnUrlText', 'settingValue' => 'Continue to blah.'), 'setting' => array('settingName' => 'hostedProfilePageBorderVisible', 'settingValue' => 'true')));
     $responseJson = '{
        "token":"Mvwo9mTx2vS332eCFY3rFzh/x1x64henm7rppLYQxd2cOzNpw+bfp1ZTVKvu98XSIvL9VIEB65mCFtzchN/pFKBdBA0daBukS27pWYxZuo6QpBUpz2p6zLENX8qH9wCcAw6EJr0MZkNttPW6b+Iw9eKfcBtJayq6kdNm9m1ywANHsg9xME4qUccBXnY2cCf3kLaaLNJhhiNxJmcboKNlDn5HtIQ/wcRnxB4YbqddTN8=",
        "messages":{
           "resultCode":"Ok",
           "message":[
              {
                 "code":"I00001",
                 "text":"Successful."
              }
           ]
        }
     }';
     $this->http->expects($this->once())->method('process')->will($this->returnValue($responseJson));
     $request = AuthnetApiFactory::getJsonApiHandler($this->login, $this->transactionKey, $this->server);
     $request->setProcessHandler($this->http);
     $response = $request->getHostedProfilePageRequest($requestJson);
     $this->assertEquals('Ok', $response->messages->resultCode);
     $this->assertTrue($response->isSuccessful());
     $this->assertFalse($response->isError());
     $this->assertEquals('I00001', $response->messages->message[0]->code);
     $this->assertEquals('Successful.', $response->messages->message[0]->text);
     $this->assertEquals('Mvwo9mTx2vS332eCFY3rFzh/x1x64henm7rppLYQxd2cOzNpw+bfp1ZTVKvu98XSIvL9VIEB65mCFtzchN/pFKBdBA0daBukS27pWYxZuo6QpBUpz2p6zLENX8qH9wCcAw6EJr0MZkNttPW6b+Iw9eKfcBtJayq6kdNm9m1ywANHsg9xME4qUccBXnY2cCf3kLaaLNJhhiNxJmcboKNlDn5HtIQ/wcRnxB4YbqddTN8=', $response->token);
 }
        "resultCode": "Ok",
        "message": [
            {
                "code": "I00001",
                "text": "Successful."
            }
        ]
    }
}

*************************************************************************************************/
namespace JohnConde\Authnet;

require '../../config.inc.php';
require '../../src/autoload.php';
$request = AuthnetApiFactory::getJsonApiHandler(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetApiFactory::USE_DEVELOPMENT_SERVER);
$response = $request->createTransactionRequest(array("transactionRequest" => array("transactionType" => "voidTransaction", "refTransId" => "138")));
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>AIM :: Paypal :: Void</title>
        <style type="text/css">
            table
            {
                border: 1px solid #cccccc;
                margin: auto;
                border-collapse: collapse;
                max-width: 90%;
            }
Пример #3
0
 *
 * (c) John Conde <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/*************************************************************************************************

Use the SIM tools to create a SIM transaction form

*************************************************************************************************/
namespace JohnConde\Authnet;

require '../../config.inc.php';
require '../../src/autoload.php';
$sim = AuthnetApiFactory::getSimHandler(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetApiFactory::USE_DEVELOPMENT_SERVER);
$amount = 10.0;
$login = $sim->getLogin();
$url = $sim->getEndpoint();
$fingerprint = $sim->getFingerprint($amount);
$sequence = $sim->getSequence();
$timestamp = $sim->getTimestamp();
?>

<!DOCTYPE html>
<html>
<html lang="en">
    <head>
        <title>SIM </title>
    </head>
    <body>
Пример #4
0
 /**
  * @covers            \JohnConde\Authnet\AuthnetApiFactory::getSimURL
  * @expectedException \JohnConde\Authnet\AuthnetInvalidServerException
  */
 public function testExceptionIsRaisedForAuthnetInvalidSimServer()
 {
     $authnet = AuthnetApiFactory::getSimHandler($this->login, $this->transactionKey, null);
 }
 /**
  * @covers            \JohnConde\Authnet\AuthnetJsonRequest::process()
  * @uses              \JohnConde\Authnet\AuthnetApiFactory::getJsonApiHandler
  * @uses              \JohnConde\Authnet\AuthnetApiFactory::getWebServiceURL
  */
 public function testCreateTransactionRequestRefundError()
 {
     $requestJson = array("transactionRequest" => array("transactionType" => "refundTransaction", "refTransId" => "138"));
     $responseJson = '{
         "transactionResponse": {
             "responseCode": "3",
             "transId": "0",
             "refTransID": "2149186775",
             "transHash": "D6C9036F443BADE785D57DA2B44CD190",
             "testRequest": "0",
             "accountType": "PayPal",
             "errors": [
                 {
                     "errorCode": "54",
                     "errorText": "The referenced transaction does not meet the criteria for issuing a credit."
                 }
             ]
         },
         "refId": "123456",
         "messages": {
             "resultCode": "Error",
             "message": [
                 {
                     "code": "E00027",
                     "text": "The transaction was unsuccessful."
                 }
             ]
         }
     }';
     $this->http->expects($this->once())->method('process')->will($this->returnValue($responseJson));
     $request = AuthnetApiFactory::getJsonApiHandler($this->login, $this->transactionKey, $this->server);
     $request->setProcessHandler($this->http);
     $response = $request->createTransactionRequest($requestJson);
     $this->assertEquals('Error', $response->messages->resultCode);
     $this->assertFalse($response->isSuccessful());
     $this->assertTrue($response->isError());
     $this->assertEquals(AuthnetJsonResponse::STATUS_ERROR, $response->transactionResponse->responseCode);
     $this->assertEquals('PayPal', $response->transactionResponse->accountType);
     $this->assertEquals('54', $response->transactionResponse->errors[0]->errorCode);
     $this->assertEquals('The referenced transaction does not meet the criteria for issuing a credit.', $response->transactionResponse->errors[0]->errorText);
 }
 /**
  * @covers            \JohnConde\Authnet\AuthnetJsonRequest::getRawRequest()
  */
 public function testGetRawRequest()
 {
     $requestJson = array('refId' => '94564789', 'transactionRequest' => array('transactionType' => 'authCaptureTransaction', 'amount' => 5, 'payment' => array('creditCard' => array('cardNumber' => '4111111111111111', 'expirationDate' => '122016', 'cardCode' => '999'))));
     $apiLogin = '******';
     $apiTransKey = 'apiTransKey';
     $http = $this->getMockBuilder('\\JohnConde\\Authnet\\CurlWrapper')->disableOriginalConstructor()->getMock();
     $http->expects($this->once())->method('process')->will($this->returnValue('{}'));
     $request = AuthnetApiFactory::getJsonApiHandler($apiLogin, $apiTransKey, AuthnetApiFactory::USE_DEVELOPMENT_SERVER);
     $request->setProcessHandler($http);
     $request->deleteCustomerProfileRequest($requestJson);
     $response = '{"deleteCustomerProfileRequest":{"merchantAuthentication":{"name":"apiLogin","transactionKey":"apiTransKey"},"refId":"94564789","transactionRequest":{"transactionType":"authCaptureTransaction","amount":5,"payment":{"creditCard":{"cardNumber":"4111111111111111","expirationDate":"122016","cardCode":"999"}}}}}';
     $this->assertSame($response, $request->getRawRequest());
 }
Пример #7
0
 /**
  * @covers            \JohnConde\Authnet\AuthnetJsonRequest::process()
  * @uses              \JohnConde\Authnet\AuthnetApiFactory::getJsonApiHandler
  * @uses              \JohnConde\Authnet\AuthnetApiFactory::getWebServiceURL
  */
 public function testARBUpdateSubscriptionRequestError()
 {
     $requestJson = array('refId' => 'Sample', 'subscriptionId' => '2342682', 'subscription' => array('payment' => array('creditCard' => array('cardNumber' => '6011000000000012', 'expirationDate' => '2016-08'))));
     $responseJson = '{
        "refId":"Sample",
        "messages":{
           "resultCode":"Error",
           "message":[
              {
                 "code":"E00037",
                 "text":"Subscriptions that are canceled cannot be updated."
              }
           ]
        }
     }';
     $this->http->expects($this->once())->method('process')->will($this->returnValue($responseJson));
     $request = AuthnetApiFactory::getJsonApiHandler($this->login, $this->transactionKey, $this->server);
     $request->setProcessHandler($this->http);
     $response = $request->ARBGetSubscriptionStatusRequest($requestJson);
     $this->assertEquals('Error', $response->messages->resultCode);
     $this->assertEquals('Sample', $response->refId);
     $this->assertEquals('E00037', $response->messages->message[0]->code);
     $this->assertEquals('Subscriptions that are canceled cannot be updated.', $response->messages->message[0]->text);
 }
Пример #8
0
 /**
  * @covers            \JohnConde\Authnet\AuthnetJsonRequest::process()
  * @uses              \JohnConde\Authnet\AuthnetApiFactory::getJsonApiHandler
  * @uses              \JohnConde\Authnet\AuthnetApiFactory::getWebServiceURL
  */
 public function testDecryptPaymentDataRequestError()
 {
     $requestJson = array("opaqueData" => array("dataDescriptor" => "COMMON.VCO.ONLINE.PAYMENT", "dataValue" => "2BceaAHSHwTc0oA8RTqXfqpqDQk+e0thusXG/SAy3EuyksOis8aEMkxuVZDRUpbZVOFh6JnmUl/LS3s+GuoPFJbR8+OBfwJRBNGSuFIgYFhZooXYQbH0pkO6jY3WCMTwiYymGz359T9M6WEdCA2oIMRKOw8PhRpZLvaoqlxZ+oILMq6+NCckdBd2LJeFNOHzUlBvYdVmUX1K1IhJVB0+nxCjFijYQQQVlxx5sacg+9A0YWWhxNnEk8HzeCghnU9twR1P/JGI5LlT+AaPmP0wj6LupH0mNFDIYzLIoA6eReIrTqn63OwJdCwYZ7qQ2hWVhPyLZty22NycWjVCdl2hdrNhWyOySXJqKDFGIq0yrnD3Hh1Y71hbg4GjsObhxtq3IsGT1JgoL9t6Q393Yw2K4sdzjgSJgetxrh2aElgLs9mEtQfWYUo71KpesMmDPxZYlf+NToIXpgz5yrQ/FT29YCSbGUICO9ems9buhb0iwcuhhamUcg336bLjL2K54+s1cpOGNEuqUi0cSMvng9T9IKZgWO+jMvQmJzRsIB5KD3FooCnDwxadp61eWfc+Bl+e0b0oQXSxJt12vyghZBgHvhEQcXU+YGBihbyYuI1JOPtt+A3smz7Emfd2+ktGF4lp82RVQNXlG9ENtKr26Utntc/xfj+y1UX2NUtsn22rW+Kahb20/4hHXA8DLcmfeHMDvrupePIcCKj02+Feofc2RMnVQLS9bsXXzbxzYGm6kHtmaXteNTnpB67U0z3igD17bYFOZurNQUBEHLXntCAMqCL7kkBT8Qx8yaSA3uhzJVhLSWU9ovu2uM1AGIauJki5TxdjSyrcj56Hi8sVB7FNxWcsZhGb67wwNRVwwyurU+YFVXB8fJna3FW686qPfo+UnyVUxwOXP4g+wC661VcrkMPPwZySzVaM7vH2n2VENkECCpm3bBYBitRifHwhRlYFF6z0GNhJQ2JLy2+YJZrlNWUMtzvYjcKojgA6YsCkSr1tFCv2c+oLAfkC720G9IvfCNQyv4o2dH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FsTf39PfJUhB7b0+7+zFwtriJn02WcW1Z9pX78wSs0AxwYCMbNtxzK5fFZZcdOt2HOsIHw==", "dataKey" => "k5qdgh6t5BnvuBz3Xs0f+iraXB0tXO+6WewMUVTBsqYN3G16HHYwlz8To602G/pZ+Sng0mjTAy3mwhpOb/5nJktiCTpKL4wvn0exJxGt9GIAODBYz4PFbxuenmuQE9O5"), "callId" => "4859677641513545101");
     $responseJson = '{
        "messages":{
           "resultCode":"Error",
           "message":[
              {
                 "code":"E00001",
                 "text":"Unable to process decryption"
              }
           ]
        }
     }';
     $this->http->expects($this->once())->method('process')->will($this->returnValue($responseJson));
     $request = AuthnetApiFactory::getJsonApiHandler($this->login, $this->transactionKey, $this->server);
     $request->setProcessHandler($this->http);
     $response = $request->createTransactionRequest($requestJson);
     $this->assertEquals('Error', $response->messages->resultCode);
     $this->assertFalse($response->isSuccessful());
     $this->assertTrue($response->isError());
     $this->assertEquals('Unable to process decryption', $response->messages->message[0]->text);
 }
Пример #9
0
 /**
  * @covers            \JohnConde\Authnet\AuthnetSim::resetParameters()
  */
 public function testResetParameters()
 {
     $sim = AuthnetApiFactory::getSimHandler($this->login, $this->transactionKey, $this->server);
     $sequence = $sim->getSequence();
     $timestamp = $sim->getTimestamp();
     sleep(1);
     $sim->resetParameters();
     $reflectionOfRequest = new \ReflectionObject($sim);
     $timestampReflection = $reflectionOfRequest->getProperty('timestamp');
     $timestampReflection->setAccessible(true);
     $sequenceReflection = $reflectionOfRequest->getProperty('sequence');
     $sequenceReflection->setAccessible(true);
     $this->assertNotEquals($timestamp, $timestampReflection->getValue($sim));
     $this->assertNotEquals($timestamp, $sequenceReflection->getValue($sim));
 }