cancel
Showing results for 
Search instead for 
Did you mean: 

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

js
Member
14 REPLIES 14

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

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

qw
Contributor

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

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();

 

 

qw
Contributor

Just want to qualify the very helpful info from @qw : I followed their example but I found that it isn't the entire token object that I needed to hash, only the token.paymentData element. Encoding the whole token (which contains paymentMethod and transactionIdentifier in addition to paymentData) gave a 'could not decrypt' error. But passing in only the hashed paymentData element worked.

l3gsw3bst3r
Member

I added my bank card/account whenever Apple Pay first came out, didn't use it for awhile because no businesses around me accepted it. When I first saw the logo on some gas station register debit terminals, I tried it out and it worked exactly as advertised. It's one of those things you don't appreciate until you use it. Pulling out your wallet, then card, swiping, entering pin, keeping the card out until everything goes through...almost entirely gone and it's great. Sometimes you still have to enter your pin, sometimes you don't. I wish I never had to enter my pin.

Hello,

 

I have https://d.pr/i/o7FlUr types of data from ApplaPay Session, can you please let me know what you mean by "But passing in only the hashed paymentData element worked."

 

Thanks!

 

 

Facing same issue and looking for solution. Latest technology

ghfh
Member

According to my experience, some requirements are required

 

  • Your website must comply with the Apple Pay guidelines.

  • You must have an Apple Developer Account and complete the registration.

  • All pages that include Apple Pay must be served over HTTPS.


    @auhoque wrote:

    Hello,

     

    I have https://d.pr/i/o7FlUr types of data from ApplaPay Session, can you please let me know what you mean by "But passing in only the hashed paymentData element worked."

     

    Thanks!