Reply
js
Member
Posts: 1
Registered: ‎07-15-2019

Apple Pay on the Web integration

We are trying to help our merchant customers integrating Apple Pay on the Web and using Authorize.Net as their payment gateway. With regards to the "Create an Apple Pay Transaction" API example snippet below, we have the following 2 questions:

 

1. For Apple Pay on the web, should the "dataDescriptor" field be set to "COMMON.APPLE.INAPP.PAYMENT" or some other value?

2. For Apple Pay on the web, should we set the "dataValue" field to the Apple Pay token retrieved from consumer's Apple Pay wallet?

 

{ "createTransactionRequest": { "merchantAuthentication": { "name": "5KP3u95bQpv", "transactionKey": "346HZ32z3fP4hTG2" }, "refId": "123456", "transactionRequest": { "transactionType": "authCaptureTransaction", "amount": "50", "payment": { "opaqueData": { "dataDescriptor": "COMMON.APPLE.INAPP.PAYMENT", "dataValue": "1234567890ABCDEF1111AAAA2222BBBB3333CCCC4444DDDD5555EEEE6666FFFF7777888899990000" } },

 

Thanks,

JS

qw
Contributor
Posts: 20
Registered: ‎08-27-2019

Re: Apple Pay on the Web integration

Did you ever figure this out?  I'm at the same step and I cannot get the final call to auth.net to work, and I feel like its because whatever I'm putting into the opaqueDataType is incorrect...

 

My question that's as yet unanswered:
https://community.developer.authorize.net/t5/Integration-and-Testing/Apple-Pay-Error-153-in-Sandbox-...

 

 

qw
Contributor
Posts: 20
Registered: ‎08-27-2019

Re: Apple Pay on the Web integration

I figured out what they were looking for, please see my linked post above for the answer.

Member
Posts: 7
Registered: ‎08-27-2019

Re: Apple Pay on the Web integration

Hi, @qw the above link is not working. Can you help me to solve this?

qw
Contributor
Posts: 20
Registered: ‎08-27-2019

Re: Apple Pay on the Web integration

[ Edited ]

They deleted my linked post because I guess they didn't like the sample code and explanation I provided.

 

The short answer is that:

 

1) Yes, you have to use: dataDescriptor = "COMMON.APPLE.INAPP.PAYMENT"

 

2) You need to take the entire Apple Pay JSON token, base64 encode it, and assign that to the dataValue property.

 

Hope this helps!

 

For me, in C#, it looked like this:

 

    //base-64 encode the json
    var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(tokenjson);
    var token64 = System.Convert.ToBase64String(plainTextBytes);

    ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;

    // define the merchant information (authentication / transaction id)
    ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
    {
        name = ApiLoginID,
        ItemElementName = ItemChoiceType.transactionKey,
        Item = ApiTransactionKey,
    };

    //set up data based on transaction
    var opaqueData = new opaqueDataType { dataDescriptor = "COMMON.APPLE.INAPP.PAYMENT", dataValue = token64 };

    //standard api call to retrieve response
    var paymentType = new paymentType { Item = opaqueData };

    var transactionRequest = new transactionRequestType
    {
        transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // authorize and capture transaction
        amount = Amount,
        payment = paymentType
    };

    var request = new createTransactionRequest { transactionRequest = transactionRequest };
// instantiate the controller that will call the service
var controller = new createTransactionController(request);
controller.Execute();

// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();