CyberSource ios SDK for Apple Pay



Similar documents
Korean Cyber Payment Services

CyberSource Global Payment Service

PayPal Express Checkout Services

Getting Started with Visa Checkout

Recurring Billing. Using the Simple Order API. October CyberSource Corporation HQ P.O. Box 8999 San Francisco, CA Phone:

Getting Started with Fraud Alert

AliPay International Services

Electronic Check Services

Recurring Billing. Using the Simple Order API for CyberSource Essentials. March 2016

PINless Debit Card Services

AliPay International Services

Electronic Check Services

Recurring Billing. Using the SCMP API. October CyberSource Corporation HQ P.O. Box 8999 San Francisco, CA Phone:

Recurring Billing. Using the Business Center. May CyberSource Corporation HQ P.O. Box 8999 San Francisco, CA Phone:

CyberSource PayPal Services Implementation Guide

Getting Started with CyberSource Advanced

Merchant Account Reports

CyberSource Payer Authentication

Title Page. Credit Card Services. User Guide. August CyberSource Corporation HQ P.O. Box 8999 San Francisco, CA Phone:

CyberSource Secure Acceptance Web/Mobile

CyberSource Verification Services

Getting Started with Apple Pay on the Authorize.Net Platform

CyberSource Simple Order API Client

Universal Management Portal

User s Guide Simple Order API Version 1.14 May 2005

CyberSource Business Center Simple Order API

Tax Calculation Service

How To Understand And Understand The Bank Account In European Credit Card Transactions

Merchant Management Service

Authorize.Net Mobile Application

CyberSource Merchant Account Guide. March 2008

Merchant Web Services API

Merchant Web Services API

Star Micronics Cloud Services ios SDK User's Manual

ipayment Gateway API (IPG API)

Merchant Web Services API

Web Services Credit Card Errors A Troubleshooter

CyberSource Business Center

Merchant Integration Guide

Web Services Credit Card Errors A Troubleshooter

Qualtrics Single Sign-On Specification

BAM Checkout Mobile Implementation Guide for ios

Praktikum Entwicklung von Mediensystemen mit ios

Magensa Services. Administrative Account Services API Documentation for Informational Purposes Only. September Manual Part Number:

Level II and Level III Processing Using the Simple Order API

CA Nimsoft Service Desk

Web Services Credit Card Errors A Troubleshooter

etrust Audit Using the Recorder for Check Point FireWall-1 1.5

Merchant Web Services API

Oracle Fusion Middleware Oracle API Gateway OAuth User Guide 11g Release 2 ( )

Java Web Services SDK

Authorize.Net Mobile Application

Tag Specification Document

Card-Present Processing Using the SCMP API

MONETA.Assistant API Reference

IBM Client Security Solutions. Client Security User's Guide

Axway API Gateway. Version 7.4.1

CA Clarity Project & Portfolio Manager

Merchant Integration Guide

Credomatic Integration Resources. Browser Redirect API Documentation June 2007

SPARROW Gateway. Developer API. Version 2.00

Centrify Mobile Authentication Services

Address Phone & Fax Internet

Customize Mobile Apps with MicroStrategy SDK: Custom Security, Plugins, and Extensions

DIGIPASS CertiID. Getting Started 3.1.0

CA Mobile Device Management. How to Create Custom-Signed CA MDM Client App

Credit Card Processing

Salesforce Mobile Push Notifications Implementation Guide

New Features for Sybase Mobile SDK and Runtime. Sybase Unwired Platform 2.1 ESD #2

Network Merchants Inc (NMI) Integration Resources. Direct Post API Documentation April 2010

Programming Autodesk PLM 360 Using REST. Doug Redmond Software Engineer, Autodesk

Online signature API. Terms used in this document. The API in brief. Version 0.20,

Card-Present Processing Using the Simple Order API

Payvision Payment Processor. Technical Integration

CA Mobile Device Management 2014 Q1 Getting Started

ivvy Events Software API

PROCESS TRANSACTION API

Fairsail REST API: Guide for Developers

CA Nimsoft Service Desk

White Paper March 1, Integrating AR System with Single Sign-On (SSO) authentication systems

Chapter 1: How to Register a UNIX Host in a One-Way Trust Domain Environment 3

Cisco UCS Director Payment Gateway Integration Guide, Release 4.1

Event Kit Programming Guide

MasterCard In tern et Gateway Service (MIGS)

Technical Certificates Overview

CyberSource Merchant Account: Examples of Best Practice Business Policies

Process Transaction API

CA Performance Center

Payment Processor Errors A Troubleshooter

fåíéêåéí=péêîéê=^çãáåáëíê~íçêûë=dìáçé

Emerald. Cisco IVR - Prepaid Voice Version 1.1. Emerald Management Suite IEA Software, Inc.

EdgeCast Networks Inc. Token-Based Authentication Administration Guide

Gateway Direct Post API

Identikey Server Getting Started Guide 3.1

Microsoft Dynamics GP. Extender User s Guide

MasterCard In tern et Gatew ay Service (MIGS)

API Documentation. Version 2.0

TestFlight FAQ Apple Inc.

Transaction Details Guide

Credit Card Processing with Element Payment Services. Release 8.7.9

Transcription:

Title Page CyberSource ios SDK for Apple Pay Developer Guide March 2015 CyberSource Corporation HQ P.O. Box 8999 San Francisco, CA 94128-8999 Phone: 800-530-9095

CyberSource Contact Information For general information about our company, products, and services, go to http://www.cybersource.com. For sales questions about any CyberSource Service, email sales@cybersource.com or call 650-432-7350 or 888-330-2300 (toll free in the United States). For support information about any CyberSource Service, visit the Support Center at http://www.cybersource.com/support. Copyright 2015 CyberSource Corporation. All rights reserved. CyberSource Corporation ("CyberSource") furnishes this document and the software described in this document under the applicable agreement between the reader of this document ("You") and CyberSource ("Agreement"). You may use this document and/or software only in accordance with the terms of the Agreement. Except as expressly set forth in the Agreement, the information contained in this document is subject to change without notice and therefore should not be interpreted in any way as a guarantee or warranty by CyberSource. CyberSource assumes no responsibility or liability for any errors that may appear in this document. The copyrighted software that accompanies this document is licensed to You for use only in strict accordance with the Agreement. You should read the Agreement carefully before using the software. Except as permitted by the Agreement, You may not reproduce any part of this document, store this document in a retrieval system, or transmit this document, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written consent of CyberSource. Restricted Rights Legends For Government or defense agencies. Use, duplication, or disclosure by the Government or defense agencies is subject to restrictions as set forth the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 and in similar clauses in the FAR and NASA FAR Supplement. For civilian agencies. Use, reproduction, or disclosure is subject to restrictions set forth in subparagraphs (a) through (d) of the Commercial Computer Software Restricted Rights clause at 52.227-19 and the limitations set forth in CyberSource Corporation's standard commercial agreement for this software. Unpublished rights reserved under the copyright laws of the United States. Trademarks CyberSource, The Power of Payment, CyberSource Payment Manager, CyberSource Risk Manager, CyberSource Decision Manager, CyberSource Connect, Authorize.Net, and echeck.net are trademarks and/or service marks of CyberSource Corporation. All other brands and product names are trademarks or registered trademarks of their respective owners. 2

Contents CONTENTS Recent Revisions to This Document 5 About This Guide 6 Audience and Purpose 6 Conventions 6 Note, Important, and Warning Statements 6 Text and Command Conventions 7 Related Documents 7 Customer Support 7 Chapter 1 Working with CyberSource ios SDK for Apple Pay 8 Introduction 8 Requirements 8 How Apple Pay Works 9 Payment Processing with Apple Pay 10 Generating a Unique Transaction Signature 14 Appendix A Methods 17 authorizationfinishedwithgatewayresponse 17 Syntax 17 Input Parameters 17 Output Parameters 17 Return Value 17 initsessionwithusername 18 Syntax 18 Input Parameters 18 Output Parameters 18 Return Value 18 CyberSource ios SDK for Apple Pay Developer Guide March 2015 3

Contents performauthorizationwithtransaction 19 Syntax 19 Input Parameters 19 Output Parameters 19 Return Value 19 performsalewithtransaction 20 Syntax 20 Input Parameters 20 Output Parameters 20 Return Value 20 salefinishedwithgatewayresponse 21 Syntax 21 Input Parameters 21 Output Parameters 21 Return Value 21 Appendix B Objects and Properties 22 VMposAddress 22 Properties 22 VMposAuthenticationDelegate 23 VMposEncryptedPayment 23 Properties 23 VMposError 24 Properties 25 VMposGatewayDelegate 25 VMposGatewayResponse 26 Properties 26 VMposGatewayResponseDecisionType 27 VMposItem 28 Properties 28 VMposPurchaseDetails 28 Properties 28 VMposSettings 29 Properties 29 VMposTransactionObject 29 Properties 29 Appendix C Sample Code 31 CyberSource ios SDK for Apple Pay Developer Guide March 2015 4

Recent Revisions to This Document REVISIONS Release March 2015 February 2015 December 2014 September 10, 2014 September 9, 2014 September 5, 2014 Changes Changed all instances of card association to payment card company. This revision contains only editorial changes and no technical updates. This revision contains only editorial changes and no technical updates. Updated the link to the SDK in Step 1 in "Payment Processing with Apple Pay," page 10. Initial release. Second beta release. CyberSource ios SDK for Apple Pay Developer Guide March 2015 5

About This Guide ABOUT GUIDE Audience and Purpose This guide is written for application developers who want to use Apple Pay in an ios application and use information from Apple to process payments through CyberSource. Using the CyberSource ios SDK for Apple Pay requires software development skills. You must write code that uses the tools provided by the SDK to integrate payment processing functionality into an ios application. Conventions Note, Important, and Warning Statements Note A Note contains helpful suggestions or references to material not contained in the document. Important An Important statement contains information essential to successfully completing a task or learning a concept. CyberSource ios SDK for Apple Pay Developer Guide March 2015 6

About This Guide Text and Command Conventions Convention Usage bold Field and service names in text; for example: Include the ics_applications field. Items that you are instructed to act upon; for example: Click Save. italic Filenames and pathnames. For example: Add the filter definition and mapping to your web.xml file. Placeholder variables for which you supply particular values. monospace XML elements. Code examples and samples. Text that you enter in an API environment; for example: Set the davservice_run field to true. Related Documents CyberSource Document: Getting Started with Apple Pay on the CyberSource Platform Refer to the Support Center for complete CyberSource technical documentation: http://www.cybersource.com/support_center/support_documentation Apple Document: PassKit Framework Reference Customer Support For support information about any CyberSource service, visit the Support Center: http://www.cybersource.com/support CyberSource ios SDK for Apple Pay Developer Guide March 2015 7

Working with CyberSource ios SDK for Apple Pay CHAPTER 1 Introduction The CyberSource ios SDK for Apple Pay enables you to add payment processing functionality to your ios application. The CyberSource ios SDK for Apple Pay works in conjunction with the Apple PassKit Framework, which provides you with a binary large object (blob) of encrypted payment data during the checkout process. The CyberSource ios SDK for Apple Pay enables your ios application to: Securely send encrypted payment data to CyberSource. Complete the checkout process. Requirements You must establish secure communication channels between your ios application, Apple, and CyberSource by following these steps. Step 1 Step 2 Step 3 Meet the requirements described in Getting Started with Apple Pay on the CyberSource Platform. Enroll in Apple Pay and register with CyberSource as described in Getting Started with Apple Pay on the CyberSource Platform. Obtain an Apple Pay Certificate as described in the PassKit Framework Reference. These secure communication channels: Enable your ios application, Apple, and CyberSource to securely send and receive encrypted payment information. Protect you from exposure to sensitive payment information, which may alleviate your Payment Card Industry (PCI) burden. CyberSource ios SDK for Apple Pay Developer Guide March 2015 8

Chapter 1 Working with CyberSource ios SDK for Apple Pay How Apple Pay Works The following diagram shows how to use the CyberSource ios SDK for Apple Pay to integrate Apple Pay into your order management system. 1 Your ios application ( Merchant App ) uses the Apple PassKit Framework to request payment data from Apple. 2 Apple sends encrypted payment data to your ios application. The encrypted payment data includes a token instead of a primary account number (PAN). 3 Your ios application requests and receives a unique transaction signature from your secure server. 4 Your ios application uses the CyberSource ios SDK for Apple Pay to forward the encrypted payment data to CyberSource. 5 CyberSource decrypts the payment data and forwards the information to the payment network, including your processor and the relevant payment card company. CyberSource ios SDK for Apple Pay Developer Guide March 2015 9

Chapter 1 Working with CyberSource ios SDK for Apple Pay Payment Processing with Apple Pay Follow these steps to integrate Apple Pay into your order management system. Step 1 Obtain the CyberSource ios SDK for Apple Pay. a Download the file: http://www.cybersource.com/developers/integration_methods/apple_pay/ b c Run the sample application to become familiar with the SDK. Include the SDK in your ios application. Step 2 Step 3 Step 4 Step 5 As described in the PassKit Framework Reference, use the Apple PassKit Framework to integrate payment acceptance functionality into your ios application. Use the Apple PassKit Framework to retrieve the encrypted payment data for a transaction. Generate a unique transaction signature as described in "Generating a Unique Transaction Signature," page 14. Choose the credit card transaction type that is relevant to your business and supported by your processor. The CyberSource ios SDK for Apple Pay supports two types of credit card transactions: Authorization only Authorization and capture Note An authorization confirms that the customer's account has adequate funds for the purchase. A capture transfers funds from the customer's bank to your bank. If you do not know which transaction type to use, consult your merchant account provider. CyberSource ios SDK for Apple Pay Developer Guide March 2015 10

Chapter 1 Working with CyberSource ios SDK for Apple Pay Step 6 Set the mode for the CyberSource environment. Set the cybsenvironment property to ENV_LIVE or ENV_TEST to configure the CyberSource ios SDK for Apple Pay to communicate with either the CyberSource production environment or test environment. Example 1 Setting the Mode for the CyberSource Environment VMposGateway* gateway = [VMposGateway sharedinstance]; [gateway initsessionwithusername:merchantid withmerchantid:merchantid withfingerprint: fingerprint withdelegate:self]; [VMposSettings sharedinstance].cybsenvironment = ENV_TEST; CyberSource ios SDK for Apple Pay Developer Guide March 2015 11

Chapter 1 Working with CyberSource ios SDK for Apple Pay Step 7 Example 2 Create a transaction object and send it to CyberSource. Include the encrypted payment data and transaction signature in the transaction object. See Appendix B, "Objects and Properties," on page 22. Creating a Transaction Object and Sending It to CyberSource VMposItem *item = [[VMposItem alloc] init]; item.name = NSLocalizedString(@"Item no 1", nil); item.price = [NSDecimalNumber decimalnumberwithmantissa:12 exponent:0 isnegative:no]; VMposTransactionObject *transactionobject = [VMposTransactionObject createtransaction:vmpos_transaction_payment]; [transactionobject additem:item]; [transactionobject calculatetotals]; // TODO: The encrypted payment is created by the client application based on // specification from the SOAP toolkit API. The following values are place holders. VMposEncryptedPayment* payment = [VMposEncryptedPayment new]; payment.encodeddata = ksampleencrypteddataencodedvalue; payment.encodedmetadata = kmetadataencodedvalue; payment.paymentsolution = 001; // Purchase details. VMposPurchaseDetails* purchasedetails = [VMposPurchaseDetails new]; purchasedetails.partialindicator = NO; // Billing information. VMposAddress* billto = [VMposAddress new]; billto.firstname = @"John"; billto.lastname = @"Doe"; billto.email = @"john.doe@yahoo.com"; billto.street1 = @"1234 Pine St."; billto.city = @"Redmond"; billto.state = @"WA"; billto.postalcode = @"98052"; billto.country = @"US"; // Save transaction information. transactionobject.encryptedpayment = payment; transactionobject.purchasedetails = purchasedetails; transactionobject.transactioncode = @"ref_code_12345678"; transactionobject.billto = billto; // Get transaction signature from server. NSString* fingerprint = [getfingerprintwithtransaction:transactionobject withmerchantid:@"mpos_paymentech"]; // Communicate with CyberSource. VMposGateway* gateway = [VMposGateway sharedinstance]; [gateway initsessionwithusername:@"mpos_paymentech" withmerchantid:@"mpos_paymentech" withfingerprint: fingerprint withdelegate:self]; [gateway performauthorizationwithtransaction:transactionobject withdelegate:self]; CyberSource ios SDK for Apple Pay Developer Guide March 2015 12

Chapter 1 Working with CyberSource ios SDK for Apple Pay Step 8 Example 3 Process the transaction response from CyberSource. Processing the Transaction Response from CyberSource //! Provides feedback from completed authorization transaction request. /*! \param paramresponsedata gateway data retrieved from server (contains information about transaction status) \param paramerror an error if request failed */ - (void) authorizationfinishedwithgatewayresponse:(vmposgatewayresponse*) paramresponsedata witherror:(vmposerror*)paramerror self.authorized = YES; [self updatestatusmessagewithresponse:(vmposgatewayresponse*)paramresponsedata witherror: paramerror]; - (void) updatestatusmessagewithresponse:(vmposgatewayresponse*)paramresponsedata witherror: (NSError*) paramerror NSMutableString* s = [NSMutableString new]; if (paramresponsedata) [s appendstring: @"\ntransaction Details:"]; [s appendformat: @"\n * Accepted: %@", paramresponsedata.isaccepted? @"Yes" : @"No"]; [s appendformat: @"\n * Auth Amount: %@", paramresponsedata.authorizedamount.stringvalue]; if (paramerror) [s appendformat:@"\nerror: %@", paramerror.localizeddescription]; [self updatestatusmessage:s]; CyberSource ios SDK for Apple Pay Developer Guide March 2015 13

Chapter 1 Working with CyberSource ios SDK for Apple Pay Generating a Unique Transaction Signature Important You must generate the transaction signature on your secure server because it contains your SOAP toolkit API transaction security key, which cannot be stored on a device. Step 1 If you do not already have a SOAP toolkit API transaction security key for your CyberSource account, generate one. In the Business Center, under Account Management in the left navigation panel, select Transaction Security Keys. Follow the instructions for security keys for the SOAP toolkit API. When you send a transaction request to CyberSource, CyberSource uses the transaction key to create a transaction-specific signature for your server. CyberSource verifies the transaction-specific signature. These steps ensure that a transaction initiated in an ios application is verified by your server. Warning CyberSource stores a copy of the transaction key in the Business Center. You must keep your own copy of the transaction key in a safe place. You are responsible for maintaining adequate security and control of your transaction key. Do not store the transaction key in your ios application code on the device. If the transaction key is compromised, you must generate a new transaction key. Important SOAP toolkit API transaction security keys expire every three years. You must have a process for updating your transaction security keys. Step 2 Create a string by concatenating the following strings in the following order: SHA-1 hash of your SOAP toolkit API transaction security key. Your CyberSource merchant ID. Merchant reference code for the transaction. Use the same value as the merchant reference code that you will include in your payment request. Grand total amount. Use the same value as the grand total amount that you will include in your payment request. Timestamp in UTC format (YYYY-MM-DDThh:mm:ssZ). CyberSource ios SDK for Apple Pay Developer Guide March 2015 14

Chapter 1 Working with CyberSource ios SDK for Apple Pay Example 4 Creating a Concatenated String private static String getsha1(string soaptoolkittransactionkey) throws NoSuchAlgorithmException, UnsupportedEncodingException MessageDigest crypt = MessageDigest.getInstance("SHA-1"); crypt.reset(); crypt.update(soaptoolkittransactionkey.getbytes("utf-8")); byte[] bytes = crypt.digest(); StringBuffer hash = new StringBuffer(); for (int i = 0; i < bytes.length; i++) String hex = Integer.toHexString(0xFF & bytes[i]); if (hex.length() == 1) hash.append('0'); hash.append(hex); return hash.tostring(); String inputstringforpassword = sha1merchantsecurityid + merchantid + merchantreferencecode + grandtotalamounttmp + timestamputc; Example of concatenated string: 9661f7c395706c2bfd03099976f5a9f6de866f06merchant_idinvoice_id100.002014-08- 01T02:04:01Z Step 3 Example 5 Generate an HMAC-SHA256 value as shown in the following example. Use the concatenated string from Step 2 for both the key and message inputs for the HMAC function. Generating an HMAC-SHA256 Value private static String gethmacsha256(string inputstringforpassword) throws InvalidKeyException, NoSuchAlgorithmException, UnsupportedEncodingException SecretKeySpec key = new SecretKeySpec((inputStringForPassword).getBytes("UTF-8"), MAC_ALGORITHM_SHA256); Mac mac = Mac.getInstance(MAC_ALGORITHM_SHA256); mac.init(key); byte[] bytes = mac.dofinal(inputstringforpassword.getbytes("ascii")); StringBuffer hash = new StringBuffer(); for (int i = 0; i < bytes.length; i++) String hex = Integer.toHexString(0xFF & bytes[i]); if (hex.length() == 1) hash.append('0'); hash.append(hex); return hash.tostring(); CyberSource ios SDK for Apple Pay Developer Guide March 2015 15

Chapter 1 Working with CyberSource ios SDK for Apple Pay Example 6 Testing Your HMAC-256 Algorithm a b Use the following values as inputs for your HMAC-256 algorithm: Merchant Key: SAMPLE_MERCHANT_SOAP_TOOLKIT_TRANSACTION_KEY Merchant ID: SAMPLE_MERCHANT_ID Merchant Ref Code: ref_code_12345678 Total Amount: 0.23 Timestamp UTC: 2014-09-04T20:03:04Z Your HMAC-256 algorithm should produce the following value: 76d71942b3e41b9609710e292b972cbe9a2f9dbb8399dfa27a2f551fa5b24de9#2014-09- 04T20:03:04Z Step 4 Create a unique transaction signature by concatenating the following strings: a HMAC-SHA256 that you created in the previous step. b # c Timestamp from Step 2. Example of transaction signature: 74c853b76770168cb1f38b0708c619bb1b14384e7ac3679c411431a7c4fa6e14#2014-08- 01T02:04:01Z Example 7 Creating a Unique Transaction Signature String finalsignature = hashedsignature + "#" + timestamputc; CyberSource ios SDK for Apple Pay Developer Guide March 2015 16

Methods APPENDIX A authorizationfinishedwithgateway Response Callback method that provides response data about an authorization request. Syntax - (void) authorizationfinishedwithgatewayresponse: (VMposGatewayResponse*)paramResponseData witherror:(vmposerror*)paramerror; Input Parameters paramresponsedata Response data about an authorization request. See "VMposGatewayResponse," page 26. paramerror Error information. See "VMposError," page 24. Output Parameters None. Return Value None. CyberSource ios SDK for Apple Pay Developer Guide March 2015 17

Appendix A Methods initsessionwithusername Uses a user name, merchant ID, and transaction signature to initialize a CyberSource object for the transaction. You must initialize a session for every transaction. Syntax - (void) initsessionwithusername:(nsstring*)paramusername withmerchantid:(nsstring*)parammerchantid withfingerprint:(nsstring*)fingerprint withdelegate:(id<vmposauthenticationdelegate>)paramdelegate; Input Parameters paramusername Your user name. This value identifies a person. parammerchantid Your CyberSource merchant ID. This value identifies an organization or company. fingerprint Transaction signature as described in "Generating a Unique Transaction Signature," page 14. paramdelegate The paramdelegate delegate must conform to the VMposAuthenticationDelegate protocol. See "VMposAuthenticationDelegate," page 23. Output Parameters None. Return Value None. CyberSource ios SDK for Apple Pay Developer Guide March 2015 18

Appendix A Methods performauthorizationwithtransaction Authorizes a payment. You can authorize only one payment at a time. Syntax - (BOOL) performauthorizationwithtransaction: (VMposTransactionObject*) atransaction withdelegate:(id<vmposgatewaydelegate>)adelegate; Input Parameters atransaction The atransaction data must be complete for the payment to be authorized. See "VMposTransactionObject," page 29. adelegate The adelegate delegate must conform to the VMposGatewayDelegate protocol. See "VMposGatewayDelegate," page 25. Output Parameters None. Return Value YES: The payment was authorized. NO: The payment was not authorized. CyberSource ios SDK for Apple Pay Developer Guide March 2015 19

Appendix A Methods performsalewithtransaction Performs a sale transaction, which authorizes a payment and captures the authorization. You can request only one sale transaction at a time. Syntax - (BOOL) performsalewithtransaction:(vmpostransactionobject*) atransaction withdelegate:(id<vmposgatewaydelegate>)adelegate; Input Parameters atransaction The atransaction data must be complete for the payment to be authorized. See "VMposTransactionObject," page 29. adelegate The adelegate delegate must conform to the VMposGatewayDelegate protocol. See "VMposGatewayDelegate," page 25. Output Parameters None. Return Value YES: The payment was authorized and captured. NO: The payment was not authorized and captured. CyberSource ios SDK for Apple Pay Developer Guide March 2015 20

Appendix A Methods salefinishedwithgatewayresponse Callback method that provides response data about a sale request. A sale authorizes a payment and captures the authorization. Syntax - (void) salefinishedwithgatewayresponse: (VMposGatewayResponse*)paramResponseData witherror:(vmposerror*)paramerror; Input Parameters paramresponsedata Response data about an authorization request. See "VMposGatewayResponse," page 26. paramerror Error information. See "VMposError," page 24. Output Parameters None. Return Value None. CyberSource ios SDK for Apple Pay Developer Guide March 2015 21

Objects and Properties APPENDIX B VMposAddress @interface VMposAddress:NSObject <NSCopying, NSCoding> Details about an address. Use this object for all address types including billing addresses and shipping addresses. Properties city @property (nonatomic, copy) NSString *city; City. country @property (nonatomic, copy) NSString *country; Country. Use a 2-character code that is listed in ISO Standard Country Codes. email @property (nonatomic, copy) NSString *email; Email address for the person or business associated with the address. firstname @property (nonatomic, copy) NSString *firstname; First name of the person associated with the address. lastname @property (nonatomic, copy) NSString *lastname; Last name of the person associated with the address. phonenumber @property (nonatomic, copy) NSString *phonenumber; Phone number for the person or business associated with the address. CyberSource ios SDK for Apple Pay Developer Guide March 2015 22

Appendix B Objects and Properties postalcode @property (nonatomic, copy) NSString *postalcode; Postal code. This value must consist of 5 to 9 digits. If the billing country is the U.S., the 9-digit postal code must follow this format: [5 digits][dash][4 digits]. Example: 12345-6789. If the billing country is Canada, the 6-digit postal code must follow this format: [alpha][numeric][alpha][space][numeric][alpha][numeric]. Example: A1B 2C3. state @property (nonatomic, copy) NSString *state; State or province. Set this value to a 2-character state or province code. For possible values, see the State, Province, and Territory Codes for the United States and Canada. street1 @property (nonatomic, copy) NSString *street1; First line of the street address. Example: 100 Main St. street2 @property (nonatomic, copy) NSString *street2; Second line of the street address. Example: Suite 1234. VMposAuthenticationDelegate @protocol VMposAuthenticationDelegate <NSObject> Implement this protocol to retrieve the CyberSource authentication response. VMposEncryptedPayment @interface VMposEncryptedPayment:NSObject Encrypted payment data. For client-side encrypted payments, use this object instead of card payment data. Properties encodedmetadata @property (nonatomic, strong) NSString* encodedmetadata; Format of the encrypted payment data. Obtain this value from Apple. CyberSource ios SDK for Apple Pay Developer Guide March 2015 23

Appendix B Objects and Properties encodeddata @property (nonatomic, strong) NSString* encodeddata; Encrypted Apple Pay payment data. Obtain the encrypted payment data from Apple. paymentsolution @property (nonatomic, strong) NSString* paymentsolution; Type of payment solution that is being used for the transaction. The value for Apple Pay is 001. VMposError @interface VMposError:NSError Error information. This object derives from NSError and uses the NSError object properties. For descriptions of these errors, see reason codes in Credit Card Services Using the Simple Order API. Possible values: VMPOS_GATEWAY_ERROR_TYPE_UNKNOWN VMPOS_GATEWAY_ERROR_MISSING_FIELDS VMPOS_GATEWAY_ERROR_FIELDS_CONTAINS_INVALID_DATA VMPOS_GATEWAY_ERROR_ONLY_PARTIAL_APPROVED VMPOS_GATEWAY_ERROR_GENERAL_SYSTEM_FAILURE VMPOS_GATEWAY_ERROR_SERVER_TIMEOUT VMPOS_GATEWAY_ERROR_SERVICE_DID_NOT_FINISH VMPOS_GATEWAY_ERROR_DID_NOT_PASS_AVS VMPOS_GATEWAY_ERROR_ISSUING_BANK_HAS_QUESTIONS VMPOS_GATEWAY_ERROR_EXPIRED_CARD VMPOS_GATEWAY_ERROR_GENERAL_DECLINE VMPOS_GATEWAY_ERROR_INSUFFICIENT_FUNDS VMPOS_GATEWAY_ERROR_STOLEN_OR_LOST_CARD VMPOS_GATEWAY_ERROR_ISSUING_BANK_UNAVAILABLE VMPOS_GATEWAY_ERROR_INACTIVE_CARD VMPOS_GATEWAY_ERROR_CID_DID_NOT_MATCH VMPOS_GATEWAY_ERROR_CREDIT_LIMIT VMPOS_GATEWAY_ERROR_INVALID_CVN VMPOS_GATEWAY_ERROR_NEGATIVE_FILE VMPOS_GATEWAY_ERROR_DID_NOT_PASS_CVN_CHECK VMPOS_GATEWAY_ERROR_INVALID_ACCOUNT_NUMBER VMPOS_GATEWAY_ERROR_CARD_TYPE_NOT_EXPECTED CyberSource ios SDK for Apple Pay Developer Guide March 2015 24

Appendix B Objects and Properties VMPOS_GATEWAY_ERROR_GENERAL_DECLINE_BY_PROCESSOR VMPOS_GATEWAY_ERROR_PROBLEM_WITH_INFORMATION VMPOS_GATEWAY_ERROR_CAPTURE_AMOUNT_EXCEEDS VMPOS_GATEWAY_ERROR_PROCESSOR_FAILURE VMPOS_GATEWAY_ERROR_ALREADY_REVERSED VMPOS_GATEWAY_ERROR_ALREADY_CAPTURED VMPOS_GATEWAY_ERROR_TRANSACTION_AMOUNT_MUST_MATCH_PREVIOUS_ AMOUNT VMPOS_GATEWAY_ERROR_CARD_TYPE_INVALID VMPOS_GATEWAY_ERROR_REQUEST_ID_INVALID VMPOS_GATEWAY_ERROR_NO_CORRESPONDING VMPOS_GATEWAY_ERROR_TRANSACTION_SETTLED_OR_REVERSED VMPOS_GATEWAY_ERROR_NOT_VOIDABLE VMPOS_GATEWAY_ERROR_REQUEST_FOR_CAPTURE_THAT_WAS_VOIDED VMPOS_GATEWAY_ERROR_TIMEOUT_AT_PAYMENT_PROCESSOR VMPOS_GATEWAY_ERROR_STAND_ALONE_CREDITS_NOT_ALLOWED VMPOS_GATEWAY_ERROR_NETWORK_CONNECTION VMPOS_GATEWAY_ERROR_INVALID_TOKEN Properties extramessage @property (nonatomic, copy) NSString *extramessage; Extended message about the error. VMposGatewayDelegate @protocol VMposGatewayDelegate <NSObject> Implement this protocol to retrieve the CyberSource gateway response. CyberSource ios SDK for Apple Pay Developer Guide March 2015 25

Appendix B Objects and Properties VMposGatewayResponse @interface VMposGatewayResponse:NSObject <NSCopying> Response from CyberSource. Properties additionalparameters @property (nonatomic, strong) NSDictionary *additionalparameters; Response details that do not have an object property. For information about these parameters, see reply fields in Credit Card Services Using the Simple Order API. authcode @property (nonatomic, copy) NSString *authcode; Authorization code. Returned only when the processor returns this value. authorizedamount @property (nonatomic, strong) NSDecimalNumber *authorizedamount; Amount that was authorized. date @property (nonatomic, strong) NSDate *date; Date of authorization. decision @property (nonatomic, assign) VMposGatewayResponseDecisionType decision; Result of the request. See "VMposGatewayResponseDecisionType," page 27. isaccepted - (BOOL) isaccepted; Possible values: YES: CyberSource accepted the transaction. NO: CyberSource did not accept the transaction. requestid @property (nonatomic, strong) NSString *requestid; Identifier for the request. CyberSource ios SDK for Apple Pay Developer Guide March 2015 26

Appendix B Objects and Properties resultcode @property (nonatomic, strong) NSString *resultcode; Numeric value corresponding to the result of the request. For possible values and descriptions, see reason codes in Credit Card Services Using the Simple Order API. transactions @property (nonatomic, strong) NSArray *transactions; See "VMposTransactionObject," page 29. type @property (nonatomic, assign) VMposGatewayApiType type; Type of transaction. Possible values: VMPOS_GATEWAY_API_TYPE_AUTHORIZATION: Authorization only VMPOS_GATEWAY_API_TYPE_SALE: Authorization and capture VMposGatewayResponseDecision Type Result of the request. Possible values: VMPOS_GATEWAY_DECISION_TYPE_ACCEPT: Request was accepted. VMPOS_GATEWAY_DECISION_TYPE_ERROR: System error. VMPOS_GATEWAY_DECISION_TYPE_FAILED: Request failed. VMPOS_GATEWAY_DECISION_TYPE_REJECT: Request was declined. VMPOS_GATEWAY_DECISION_TYPE_UNKNOWN: Unknown error. CyberSource ios SDK for Apple Pay Developer Guide March 2015 27

Appendix B Objects and Properties VMposItem @interface VMposItem:NSObject Item that the customer is purchasing. Properties individualtax @property (nonatomic, copy) NSDecimalNumber *individualtax; Tax amount for one item. Up to 15 digits. This value cannot be negative. You can include a decimal point (.), but you cannot include any other special characters. Set this property to -1 if individualtax is not defined. name @property (nonatomic, copy) NSString *name; Name of the item. price @property (nonatomic, copy) NSDecimalNumber *price; Price of the item. Up to 15 digits. This value cannot be negative. You can include a decimal point (.), but you cannot include any other special characters. quantity @property (nonatomic) NSInteger quantity; Quantity of the item. VMposPurchaseDetails @interface VMposPurchaseDetails:NSObject <NSCopying> Details about the purchase. Properties currency @property (nonatomic, strong) NSString *currency; Currency used for the order. Set this value to a 3-character currency code. For the possible values, see the ISO Standard Currency Codes. CyberSource ios SDK for Apple Pay Developer Guide March 2015 28

Appendix B Objects and Properties partialindicator @property (nonatomic) BOOL partialindicator; You must set the value for the property to NO. VMposSettings @interface VMposSettings:NSObject <NSCoding> CyberSource environment setting. Properties cybsenvironment @property (nonatomic, assign) CYBS_ENVIRONMENT cybsenvironment; Setting for the CyberSource environment. Possible values: ENV_LIVE: Production environment. ENV_TEST: Test environment. VMposTransactionObject @interface VMposTransactionObject:NSObject All the information required to perform a transaction. Properties billto @property (atomic, strong) VMposAddress *billto; Billing address. See "VMposAddress," page 22. encryptedpayment @property (atomic, strong) VMposEncryptedPayment *encryptedpayment; Information about the encrypted payment data. See "VMposEncryptedPayment," page 23. CyberSource ios SDK for Apple Pay Developer Guide March 2015 29

Appendix B Objects and Properties gatewayresponse @property (atomic, strong) VMposGatewayResponse *gatewayresponse; Response from CyberSource. See "VMposGatewayResponse," page 26. items @property (atomic, strong, readonly) NSArray *items; Information about the items that the customer is purchasing. This value is read-only. Use the additem method to add items to this property. See "VMposItem," page 28. purchasedetails @property (atomic, strong) VMposPurchaseDetails *purchasedetails; Details about the purchase. See "VMposPurchaseDetails," page 28. shipto @property (atomic, strong) VMposAddress *shipto; Shipping address. See "VMposAddress," page 22. totalamount @property (atomic, strong) NSDecimalNumber *totalamount; Total transaction amount, including tax, shipping fees, tip, and any other charges. Up to 15 digits. This value cannot be negative. You can include a decimal point (.), but you cannot include any other special characters. transactioncode @property (atomic, copy) NSString *transactioncode; Transaction identifier. CyberSource ios SDK for Apple Pay Developer Guide March 2015 30

Sample Code APPENDIX C #import <CommonCrypto/CommonDigest.h> #import <CommonCrypto/CommonHMAC.h> #import <CYBSCoreSDK/CYBSCoreSDK.h> #import <CYBSCoreSDK/NSDecimalNumber+Utils.h> #import "MPDemoViewController.h" static NSString* kmetadataencodedvalue = @"RklEPUNPTU1PTi5MRy5JTkFQUC5QQVlNRU5U"; static NSString* const kpaymentsolutiondefaultvalue = @"001"; static NSString* const kenvtest = @"test"; static NSString* const kenvlive = @"live"; static NSString* const kkeymerchantid = @"merchantid"; static NSString* const kkeymerchantexternalid = @"merchantexternalid"; static NSString* const kkeytransactionkey = @"transactionkey"; static NSString* const kkeyencryptedblob = @"encryptedblob"; static NSString* const kkeyenv = @"env"; @interface MPDemoViewController () <VMposAuthenticationDelegate, VMposGatewayDelegate, UIPickerViewDataSource, UIPickerViewDelegate> @property (nonatomic, strong) VMposGateway* gateway; @property (nonatomic, assign) BOOL authorized; @property (nonatomic, weak) NSDictionary* selectedaccountdata; @property (nonatomic, strong) NSArray* configuredaccounts; @property (weak, nonatomic) IBOutlet UISegmentedControl *requesttypeselection; @property (weak, nonatomic) IBOutlet UIButton *paybutton; @property (weak, nonatomic) IBOutlet UITextView *statustext; @property (weak, nonatomic) IBOutlet UITextField *amounttextfield; @property (weak, nonatomic) IBOutlet UIPickerView *accountpicker; @end @implementation MPDemoViewController -(void) configureaccounts // This is sample static data that demonstrates how to call the API // to process transactions. For real transactions, data is generated // dynamically in code. CyberSource ios SDK for Apple Pay Developer Guide March 2015 31

Appendix C Sample Code self.configuredaccounts = @[ @ kkeymerchantid: @"inapptestmerchant", kkeymerchantexternalid: @"merchant.com.cybersource.tester", //--WARNING!---------------- // Transaction key should never be stored on the device or // embedded in code. The usage of the transaction key below is // shown only for demo purposes. kkeytransactionkey: @"Evy5pzmnlmmBNfdwbn6hvSWj32ufJt/ QO9GBipbDeLefkR0H8uzcHM/odWFRs/ ZPgjvGJNXuN7sibsFUXCjZmmLyKSNJ8zfJbXEkf4wKe57QGJuiBWZ0Lh8vewj7OiyrpJmv8Ow q9znynnjebla5iyqzrfkdffnubyogubvcngaghf6+oat16xmqcxm0v3sohuenhbtxq1c4aedp A2Q7eMIOXU2o/J3hRP18AQcBdA5fPIzvoxUJg1hxcwGPZcT6ycSMCR9Pzm/ kjoh69y3xzdylhb2xv1emliny6vnnrxzs0rzs2lykkploz+k2jj9z3e1fjmzt6krpucoht3yz Bg==", //--NOTE-------------------- // Encrypted blob is a Base64 of the JSON object that contains // the encrypted payment data. This blob is generated by the // PassKit API. kkeyencryptedblob: @"eyjkyxrhijoingkwzwwxsvhmegu1ykdjvzdwzfbzrvj1bhhwc1p1snrjwfvkdvy4rzbmv1r 4ZWVoWU5rYjJtRFh5RjhoWVFNclNOR1JiNzY2MU9hRGZWTjlMQXVuYnNMbG9tbTBuU0ZITCts Z1JQYjBGUFRWamN6eFVxa1A4akFEcEtwc2xtTUEwU0xRSFhcL1hYeUdTeSsxWDZBT0ltOUs0Y VBTWGt3MkNITkZaR0ErSktVdXdFbDBldlVWMnZUU0RONkZ2V1NmK0RwZUM0YlhpaUlLQ1IreE 9tWkhyc3ByTEhwNGJwcEdGYkduZ0tiTXZ0MjhIc2lNZVdIdXNLTDJ1cWNGVzdhcU5acSszZnQ 0QUxpbk1CYWJWS1ZnZjF4XC8ycitremIwcmhTQkFPWkJcLzlCNldQR3RhOWhUNmdlTERyTGMw NTNVWFZndXJOWkZ1WU1IOG1uM09MQlp2K1FmZ0dsVlRaODZYRmRMQlh4VUp2VHl3QVwvVCs1c 29KSUhJeWJNQnhiM3ZSTXR1MGhyZ2o2YUNxRWlkVWZOb0JnVEhlSDk4NStsR1BcL3lxQUk2dk pdrepcz1dxc2dvxc9nm0prm1q5qzc5vmd2uhzibjjmoezhylrts2pfvt0ilcj2zxjzaw9uijo irunfdjeilcjozwfkzxiionsiyxbwbgljyxrpb25eyxrhijoiotrlzta1otmznwu1oddlntax Y2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zY WN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZG YxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1 HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXdMQVlIS29aSXpqMEJBUUloQVBcL1wvXC9cLzhBQUFBQkFB QUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL01Gc0VJUFwvX C9cL1wvOEFBQUFCQUFBQUFBQUFBQUFBQUFBQVwvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC 9cLzhCQ0JheGpYWXFqcVQ1N1BydlZWMm1JYThaUjBHc014VHNQWTd6ancrSjlKZ1N3TVZBTVN ktmdprzv3u1rhbvo0nfjpzepyzujumzzrqkvfrwf4zli4duvzuwtmnhzpymxznljbog5jrgzz RXQ2ek9nOUtFNVJkaVl3cFpQNDBMaVwvaHBcL200N242MHA4RDU0V0s4NHpWMnN4WHM3THRrQ m9onzlsovfjaefqxc9cl1wvxc84qufbqufcl1wvxc9cl1wvxc9cl1wvxc9clys4nxzxdhb4zw VoUE81eXNMOFl5VlJBZ0VCQTBJQUJDWU1zOWNOSCtTd2pteWJ6TWhrMmVQXC9wYUhMVm1QY25 RaHhzanNpTDBRclwvREhrTmtjOHJXSjhhVGxvRzJGVXoyM3FmU0Z1R1BEcDV4M3dlRWtleHg0 PSIsInB1YmxpY0tleUhhc2giOiJ1T25KZmUyXC9GVjdDRTlqUERIYnZJb2lHUFBWZWYzWndsd zc5bw5rsfwveke9in0sinnpz25hdhvyzsi6ik1jsurrz1lks29aswh2y05buwndb0ljre16q0 NBeThDQVFFeEN6QUpCZ1VyRGdNQ0dnVUFNQXNHQ1NxR1NJYjNEUUVIQWFDQ0Fpc3dnZ0luTUl JQmxLQURBZ0VDQWhCY2wrUGYzK1U0cGsxM25WRDlud1FRTUFrR0JTc09Bd0lkQlFBd0p6RWxN Q01HQTFVRUF4NGNBR01BYUFCdEFHRUFhUUJBQUhZQWFRQnpBR0VBTGdCakFHOEFiVEFlRncwe E5EQXhNREV3TmpBd01EQmFGdzB5TkRBeE1ERXdOakF3TURCYU1DY3hKVEFqQmdOVkJBTWVIQU JqQUdnQWJRQmhBR2tBUUFCMkFHa0Fjd0JoQUM0QVl3QnZBRzB3Z1o4d0RRWUpLb1pJaHZjTkF RRUJCUUFEZ1kwQU1JR0pBb0dCQU5DOCtrZ3RnbXZXRjFPempnRE5yalRFQlJ1b1wvNU1LdmxN MTQ2cEFmN0d4NDFibEU5dzRmSVhKQUQ3RmZPN1FLaklYWU50MzlyTHl5N3hEd2JcLzVJa1pNN jbuwjjpstfwaju1vwm4zmq0znppcgszznrayvfhwe5mwxb0rzfkovy3svm4mk91cdlntw8xql BWclhUUEhOY3NNOTlFUFVuUHFkYmVHYzg3bTByQWdNQkFBR2pYREJhTUZnR0ExVWRBUVJSTUU CyberSource ios SDK for Apple Pay Developer Guide March 2015 32

Appendix C Sample Code rquviwldqcld0smq3wvo0mzfoq2c3wuztaetuqw5nu1v3sxdzrfzruuriahdbwxdcb0fhmefz UUJwQUVBQWRnQnBBSE1BWVFBdUFHTUFid0J0Z2hCY2wrUGYzK1U0cGsxM25WRDlud1FRTUFrR 0JTc09Bd0lkQlFBRGdZRUFiVUtZQ2t1SUtTOVFRMm1GY01ZUkVJbTJsK1hnOFwvSlh2K0dCVl FKa09Lb3NjWTRpTkRGQVwvYlFsb2dmOUxMVTg0VEh3TlJuc3ZWM1BydjdSVFk4MWdxMGR0Qzh 6WWNBYUFrQ0hJSTN5cU1uSjRBT3U2RU9XOWtKazIzMmdTRTdXbEN0SGJmTFNLZnVTZ1FYOEtY UVl1WkxrMlJyNjNOOEFwWHNYd0JMM2NKMHhnZUF3Z2QwQ0FRRXdPekFuTVNVd0l3WURWUVFES Gh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdEFoQmNsK1BmMytVNHBrMT NuVkQ5bndRUU1Ba0dCU3NPQXdJYUJRQXdEUVlKS29aSWh2Y05BUUVCQlFBRWdZQm83ZXpUUmh XR2dydTBhazB6WHJ5aE1EczBhcGd0Nk9mbGhkSUE5UzBub29uZVlieVF5QTkwalF2c1FYUXcr TTZhcXhQSThNbkxOSndqVk1GdGlsSmlFODg2em9qeEhGbWdyeEZaNGN1Z2E5MjREZWRUY1RZc WtrM3g3T002YTVyTWJqYkF4UGIyQnpDZ0N4K0gyaTk3THBPSjBXQlpBQjNUTUxmcWtsUkRuQT 09In0=", ];, //--NOTE-------------------- // Environment setting determines the API URL endpoints. kkeyenv: kenvtest self.accountpicker.delegate = self; self.accountpicker.datasource = self; self.selectedaccountdata = self.configuredaccounts[0]; - (IBAction)payButtonTouchDown:(id)sender [self.amounttextfield resignfirstresponder]; NSString* requesttype = [self.requesttypeselection titleforsegmentatindex:self.requesttypeselection.selectedsegmentindex]; [self updatestatusmessage:[nsstring stringwithformat:@"submitting %@ request...", requesttype]]; self.paybutton.enabled = NO; NSString *amounttext = self.amounttextfield.text; NSDecimalNumber *amountvalue = [NSDecimalNumber decimalnumberwithstring:amounttext]; BOOL isdecimal = amountvalue!= nil; if (isdecimal) // Pass in encrypted payment data from PassKit. [self performrequestwithencryptedpaymentdata:self.selectedaccountdata[kkeyencry ptedblob] withpaymentamount:amountvalue]; else self.paybutton.enabled = YES; self.statustext.text = @"Enter valid Amount"; CyberSource ios SDK for Apple Pay Developer Guide March 2015 33

Appendix C Sample Code - (IBAction)requestTypeSelectionValueChanged:(UISegmentedControl *)sender [self updaterequestselection]; -(void) updaterequestselection NSString* requesttype = [self.requesttypeselection titleforsegmentatindex:self.requesttypeselection.selectedsegmentindex]; [self updatestatusmessage:[nsstring stringwithformat:@"tap '%@' to %@ request.", self.paybutton.currenttitle, requesttype]]; - (void) updatestatusmessage: (NSString*) message self.statustext.text = message; self.paybutton.enabled = YES; - (void)performrequestwithencryptedpaymentdata: (NSString*) encryptedpaymentdata withpaymentamount: (NSDecimalNumber*) paymentamount VMposItem *item = [[VMposItem alloc] init]; item.name = NSLocalizedString(@"Item no 1", nil); item.price = paymentamount; VMposTransactionObject *transactionobject = [VMposTransactionObject createtransaction:vmpos_transaction_payment]; [transactionobject additem:item]; [transactionobject calculatetotals]; // Client application creates encrypted payment based on specification // from the Simple Order API. The following values are place holders. VMposEncryptedPayment* payment = [VMposEncryptedPayment new]; payment.encodeddata = encryptedpaymentdata; payment.encodedmetadata = kmetadataencodedvalue; payment.paymentsolution = kpaymentsolutiondefaultvalue; // Purchase details. VMposPurchaseDetails* purchasedetails = [VMposPurchaseDetails new]; purchasedetails.partialindicator = NO; // Sample billing information. VMposAddress* billto = [VMposAddress new]; billto.firstname = @"John"; billto.lastname = @"Doe"; billto.email = @"john.doe@yahoo.com"; billto.street1 = @"1234 Pine St."; billto.city = @"Redmond"; billto.state = @"WA"; billto.postalcode = @"98052"; billto.country = @"US"; CyberSource ios SDK for Apple Pay Developer Guide March 2015 34

Appendix C Sample Code // Save transaction information. transactionobject.encryptedpayment = payment; transactionobject.purchasedetails = purchasedetails; transactionobject.purchasedetails.commerceindicator = @"internet"; transactionobject.transactioncode = @"ref_code_12345678"; transactionobject.billto = billto; // Build fingerprint. //--WARNING!---------------- // Fingerprint generation requires the transaction key. This should // be done on the server. It is shown here only for demo purposes. NSString* merchantid = self.selectedaccountdata[kkeymerchantid]; NSString* fingerprint = [self buildfingerprintwithtransaction:transactionobject withmerchantid:merchantid]; NSLog(@"Fingerprint: %@", fingerprint); VMposGateway* gateway = [VMposGateway sharedinstance]; [gateway initsessionwithusername:merchantid withmerchantid:merchantid withfingerprint: fingerprint withdelegate:self]; if (self.selectedaccountdata[kkeyenv] == kenvlive) [VMposSettings sharedinstance].cybsenvironment = ENV_LIVE; else [VMposSettings sharedinstance].cybsenvironment = ENV_TEST; if (self.requesttypeselection.selectedsegmentindex == 0) [gateway performauthorizationwithtransaction:transactionobject withdelegate:self]; else [gateway performsalewithtransaction:transactionobject withdelegate:self]; - (void)viewdidload [super viewdidload]; [self configureaccounts]; [self updatestatusmessage:[nsstring stringwithformat:@"tap '%@' to submit a test request.", self.paybutton.currenttitle]]; self.amounttextfield.keyboardtype = UIKeyboardTypeDecimalPad; self.amounttextfield.text = @"1.09"; [self.requesttypeselection setselectedsegmentindex:0]; CyberSource ios SDK for Apple Pay Developer Guide March 2015 35

Appendix C Sample Code - (void)didreceivememorywarning [super didreceivememorywarning]; // Dispose of resources that can be recreated. // Returns the number of 'columns' to display. - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerview return 1; // Returns the # of rows in each component. - (NSInteger)pickerView:(UIPickerView *)pickerview numberofrowsincomponent:(nsinteger)component return self.configuredaccounts.count; - (NSString *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component NSDictionary* rowdata = self.configuredaccounts[row]; return [NSString stringwithformat:@"%@ (%@)", rowdata[kkeymerchantid], rowdata[kkeyenv]]; - (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component self.selectedaccountdata = self.configuredaccounts[row]; //! Callback for user session initialization. - (void) didinitusersession: (VMposUserSession*) paramusersession witherror:(vmposerror*)paramerror //! Provides feedback from finished authorization transaction request. /*! \param paramresponsedata gateway data retrieved from server (contains information about transaction status) \param paramerror an error if request failed */ - (void) authorizationfinishedwithgatewayresponse:(vmposgatewayresponse *)paramresponsedata witherror:(vmposerror *)paramerror self.authorized = YES; [self updatestatusmessagewithresponse: (VMposGatewayResponse *)paramresponsedata witherror: paramerror]; CyberSource ios SDK for Apple Pay Developer Guide March 2015 36

Appendix C Sample Code //! Provides feedback from finished sale request. /*! \param paramresponsedata gateway data retrieved from server (contains information about transaction status) \param paramerror an error if request failed */ - (void) salefinishedwithgatewayresponse:(vmposgatewayresponse *)paramresponsedata witherror:(vmposerror *)paramerror self.authorized = YES; [self updatestatusmessagewithresponse: (VMposGatewayResponse *)paramresponsedata witherror: paramerror]; - (void) updatestatusmessagewithresponse: (VMposGatewayResponse *)paramresponsedata witherror: (NSError*) paramerror NSMutableString* s = [NSMutableString new]; if (paramresponsedata) [s appendstring: @"\ntransaction Details:"]; [s appendformat: @"\n * Accepted: %@", paramresponsedata.isaccepted? @"Yes" : @"No"]; [s appendformat: @"\n * Auth Amount: %@", paramresponsedata.authorizedamount.stringvalue]; if (paramerror) [s appendformat:@"\nerror: %@", paramerror.localizeddescription]; [self updatestatusmessage:s]; /* ----------WARNING!---------------- Finger print generation requires the transaction key. This must be done on a secure server. It is shown here only for demo purposes. */ -(NSString*) buildfingerprintwithtransaction: (VMposTransactionObject*) transactionobject withmerchantid: (NSString*) merchantid NSDate* datenow = [NSDate date]; NSString* fingerprintdatestring = [MPDemoViewController formatfingerprintdate:datenow]; NSString* merchanttranskey = self.selectedaccountdata[kkeytransactionkey]; NSString* fgcomponents = [NSString stringwithformat:@"%@%@%@%@%@", [MPDemoViewController stringsha1:merchanttranskey], merchantid, transactionobject.transactioncode, [transactionobject.totalamount gatewaypricestring], fingerprintdatestring]; NSString* hashedfgcomponents = [MPDemoViewController stringhmacsha256:fgcomponents]; CyberSource ios SDK for Apple Pay Developer Guide March 2015 37

Appendix C Sample Code return [NSString stringwithformat:@"%@#%@", hashedfgcomponents, fingerprintdatestring]; +(NSString*) formatfingerprintdate: (NSDate*) date NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init]; NSTimeZone* tz = [NSTimeZone timezonewithname:@"utc"]; [dateformatter setdateformat:@"yyyy-mm-dd't'hh:mm:ss'z'"]; [dateformatter settimezone:tz]; return [dateformatter stringfromdate:date]; + (NSString *)stringsha1:(nsstring *)value const char *cstr = [value cstringusingencoding:nsutf8stringencoding]; NSData *data = [NSData datawithbytes:cstr length:value.length]; uint8_t digest[cc_sha1_digest_length]; // This is an ios5-specific method. // It takes in the data, how much data, and then output format, which in // this case is an int array. CC_SHA1(data.bytes, (uint)data.length, digest); return [self stringhexencode:digest withlength:cc_sha1_digest_length]; + (NSString *)stringsha256:(nsstring *)value const char *cstr = [value cstringusingencoding:nsutf8stringencoding]; NSData *data = [NSData datawithbytes:cstr length:value.length]; uint8_t digest[cc_sha256_digest_length]; // This is an ios5-specific method. // It takes in the data, how much data, and then output format, which in // this case is an int array. CC_SHA256(data.bytes, (uint)data.length, digest); return [self stringhexencode:digest withlength:cc_sha256_digest_ LENGTH]; + (NSString *)stringhmacsha256:(nsstring *)value CCHmacContext ctx; const char* utf8valuestring = [value UTF8String]; uint8_t hmacdata[cc_sha256_digest_length]; CCHmacInit(&ctx, kcchmacalgsha256, utf8valuestring, strlen(utf8valuestring)); CCHmacUpdate(&ctx, utf8valuestring, strlen(utf8valuestring)); CCHmacFinal(&ctx, hmacdata); CyberSource ios SDK for Apple Pay Developer Guide March 2015 38

Appendix C Sample Code return [self stringhexencode:hmacdata withlength:cc_sha256_digest_ LENGTH]; +(NSString*) stringhexencode: (uint8_t*) data withlength: (NSInteger) datalength NSMutableString* output = [NSMutableString stringwithcapacity:datalength * 2]; // Parse through the CC_SHA256 results (stored inside of digest[]). for(int i = 0; i < datalength; i++) [output appendformat:@"%02x", data[i]]; return output; + (NSString*)base64forData:(NSData*)theData const uint8_t* input = (const uint8_t*)[thedata bytes]; NSInteger length = [thedata length]; static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; NSMutableData* data = [NSMutableData datawithlength:((length + 2) / 3) * 4]; uint8_t* output = (uint8_t*)data.mutablebytes; NSInteger i; for (i=0; i < length; i += 3) NSInteger value = 0; NSInteger j; for (j = i; j < (i + 3); j++) value <<= 8; if (j < length) value = (0xFF & input[j]); NSInteger theindex = (i / 3) * 4; output[theindex + 0] = table[(value >> 18) & 0x3F]; output[theindex + 1] = table[(value >> 12) & 0x3F]; output[theindex + 2] = (i + 1) < length? table[(value >> 6) & 0x3F] : '='; output[theindex + 3] = (i + 2) < length? table[(value >> 0) & 0x3F] : '='; return [[NSString alloc] initwithdata:data encoding:nsasciistringencoding] ; @end CyberSource ios SDK for Apple Pay Developer Guide March 2015 39