@@ -736,4 +736,75 @@ A transaction of this type can be performed with the following code (JSP) :
736736 }
737737 }
738738 %>
739- ````
739+ ````
740+
741+ Test Code - Apple Pay
742+ ==============================================
743+ ** Enables you to pass Apple Pay payment data to Authorize.Net.**
744+
745+ Apple Pay support is available through the SDK using our new model
746+ and code samples.
747+
748+ ###Create a Apple Pay Transaction
749+ Use this function to create an Authorize.Net payment transaction request
750+ using Apple Pay Opaque data in place of card data.
751+
752+ ** _ DataDescriptor (Apple Pay Blob) is one-time use value._ **
753+
754+ A transaction of this type can be performed with the following code (JSP) :
755+
756+ ```` jsp
757+ <%@ page import = "java.math.BigDecimal" %>
758+ <%@ page import = "java.util.Map" %>
759+ <%@ page import = "net.authorize.Environment" %>
760+ <%@ page import = "net.authorize.api.contract.v1.*" %>
761+ <%@ page import = "net.authorize.api.controller.base.ApiOperationBase" %>
762+ <%@ page import = "net.authorize.api.controller.CreateTransactionController" %>
763+
764+ <%
765+ MerchantAuthenticationType appleMerchAuthenticationType = new MerchantAuthenticationType();
766+ appleMerchAuthenticationType.setName("YOUR_API_LOGIN_ID");
767+ appleMerchAuthenticationType.setTransactionKey("YOUR_TRANSACTION_KEY");
768+
769+ ApiOperationBase.setEnvironment(Environment.SANDBOX);
770+ ApiOperationBase.setMerchantAuthentication(appleMerchAuthenticationType);
771+
772+ PaymentType paymentType = new PaymentType();
773+ OpaqueDataType op = new OpaqueDataType();
774+ op.setDataDescriptor("YOUR_APPLE_PAY_BLOB_HERE");
775+ paymentType.setOpaqueData(op);
776+
777+
778+ TransactionRequestType txnRequest = new TransactionRequestType();
779+ txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value());
780+ txnRequest.setPayment(paymentType);
781+ txnRequest.setAmount(new BigDecimal(System.currentTimeMillis() % 100));
782+
783+ CreateTransactionRequest apiRequest = new CreateTransactionRequest();
784+ apiRequest.setTransactionRequest(txnRequest);
785+
786+ CreateTransactionController controller = new CreateTransactionController(apiRequest);
787+ controller.execute();
788+ CreateTransactionResponse apiResponse = controller.getApiResponse();
789+
790+ if (apiResponse!=null) {
791+
792+ TransactionResponse result = apiResponse.getTransactionResponse();
793+
794+ if (result.getResponseCode().equals("1")) {
795+ out.println(result.getResponseCode());
796+ out.println("Successful ApplePay Transaction ");
797+ out.println("Auht Code : "+result.getAuthCode());
798+ out.println("Transaction ID: "+result.getTransId());
799+ }
800+ else
801+ {
802+ out.println("Failed Transaction. <br/> Result Code : " + apiResponse.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " <br/> "+ apiResponse.getTransactionResponse().getErrors().getError().get(0).getErrorText());
803+ }
804+ }
805+ else{
806+ out.println("Error processing the Transaction ..");
807+ }
808+
809+ %>
810+ ````
0 commit comments