public function testCreateTransactionApplePay() { $merchantAuthentication = new apiContract\MerchantAuthenticationType(); $merchantAuthentication->setName(self::$LoginName); $merchantAuthentication->setTransactionKey(self::$TransactionKey); $OpaqueData = new apiContract\OpaqueDataType(); $OpaqueData->setDataDescriptor("COMMON.APPLE.INAPP.PAYMENT"); $OpaqueData->setDataValue("eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1Ii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Z1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0="); $paymentType = new apiContract\PaymentType(); $paymentType->setOpaqueData($OpaqueData); //create a transaction $transactionRequestType = new apiContract\TransactionRequestType(); $transactionRequestType->setTransactionType("authCaptureTransaction"); // TODO Change to Enum $transactionRequestType->setAmount($this->setValidAmount($this->counter)); $transactionRequestType->setPayment($paymentType); $request = new apiContract\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setTransactionRequest($transactionRequestType); $controller = new apiController\CreateTransactionController($request); $response = $controller->executeWithApiResponse(self::$TestEnvironment); // Handle the response. $this->assertNotNull($response, "null response"); $this->assertNotNull($response->getMessages()); self::displayMessages($response); if ("Ok" != $response->getMessages()->getResultCode()) { $this->displayTransactionMessages($response); //Ignore assertion for now //$this->assertTrue( false, "Should not reach here."); } else { $this->assertEquals("Ok", $response->getMessages()->getResultCode()); $this->assertTrue(0 < count($response->getMessages())); foreach ($response->getMessages() as $message) { $this->assertEquals("I00001", $message->getCode()); $this->assertEquals("Successful.", $response->getText()); } } }
<?php require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); // Common setup for API credentials $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName("5KP3u95bQpv"); $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); $refId = 'ref' . time(); // Create the payment data from a Visa Checkout blob $op = new AnetAPI\OpaqueDataType(); $op->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT"); $op->setDataValue("4Ng5pzJ6DXfAvLSzVauN9KTufx5lTHhFlnuIr248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50+3zZf3RpWlxZoYjm5SJ9VIWabocO/Ef26G38lKottW1XsSQUan7myYFFyeyon2hnufzMuxpyXTJ7TLekXCi2gLYbGjldgiRmGShPXzSar+hC2"); $op->setDataKey("JxAB39A9yUsf6wMD0jwGKCuY7mmzWaeEj85MH02AfKGUxOkJ00JK+o8vGG55cUF9voYU4QQ1Jec4p6nKmsxXmTREEaJwmQErotD4fpcFOyoqWTLMZfslrkHgiqbwru/V"); //create a decrypt request $decryptRequest = new AnetAPI\DecryptPaymentDataRequest(); $decryptRequest->setRefId($refId); $decryptRequest->setMerchantAuthentication($merchantAuthentication); $decryptRequest->setOpaqueData($op); $decryptRequest->setCallId("9004180129978687101"); $controller = new AnetController\DecryptPaymentDataController($decryptRequest); $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); if ($response != null) { if ($response->getMessages()->getResultCode() == "Ok") { echo "Card Number : " . $response->getCardInfo()->getCardNumber() . "\n"; echo "Amount : " . $response->getPaymentDetails()->getAmount() . "\n"; } }