#StackBounty: #ios #applepay #applepayjs Apple Pay – onvalidatemerchant Payment Not Completed error

Bounty: 50

I am implementing apple pay onto our website. I do not have a macOS device and am using windows visual studios / mvcnet. I have done all the merchantID and certification stuff and configured it on the windows machine. I am using Apple Pay JS and on the step where the payment sheet is opened with session.begin(). I use an ajax call to retrieve a merchantSession, which I believe it does successfully because the object consumed by session.completeMerchantValidation(merchantSession) contains an epochnumber, expiration time and the site name. However, immediately after completeMerchantValidation, the oncancel event is fired, and I get a red alert saying “Payment not completed”.

I need help with how to proceed from here, I read somewhere online that the domain on where I am testing needs to be a registered merchant domain. For example, when I test the functionality of the button, I need to be on www.mySite.com, where I have mySite.com registered as a domain. Can someone confirm if this is true.. because I am accessing the site from my iOS devices through local IP address. If that is not true, any help proceeding from where I am would be helpful.

function StartPaySession() {
    var lineItems = [
        {
            label: 'Shipping',
            amount: '0.00',
        }
    ];

    var shippingMethods = [
        {
            label: 'Free Shipping',
            amount: '0.00',
            identifier: 'free',
            detail: 'Delivers in five business days',
        },
        {
            label: 'Express Shipping',
            amount: '5.00',
            identifier: 'express',
            detail: 'Delivers in two business days',
        }
    ];

    var total = {
        label: 'Apple Pay Example',
        amount: '8.99',
    };

    var paymentData = {
        countryCode: 'US',
        currencyCode: 'USD',
        shippingMethods: shippingMethods,
        lineItems: lineItems,
        total: total,
        supportedNetworks: ['amex', 'discover', 'masterCard', 'visa'],
        merchantCapabilities: ['supports3DS'],
        requiredShippingContactFields: ['postalAddress', 'email'],
    };


    var paySession = new ApplePaySession(2, paymentData);

    paySession.onvalidatemerchant = function (event) {
        var validationData = { ValidationUrl: event.validationURL };
        $.ajax({
            url: '/orders/cart/startapplepaysession',
            method: "POST",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(validationData)
        }).then(function (merchantSession) {
            paySession.completeMerchantValidation(merchantSession);
            alert("end = " + window.location.host);
        }, function (error) {
            alert("merchant validation unsuccessful: " + JSON.stringify(error));
            paySession.abort();
        });
    };

    paySession.onpaymentmethodselected = function (event) {
        alert("1");
        paySession.completePaymentMethodSelection(total, lineItems);
    };

    paySession.onshippingcontactselected = function (event) {
        alert("2");
        paySession.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS, shippingMethods, total, lineItems);
    };

    paySession.onshippingmethodselected = function (event) {
        alert("3");
        paySession.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS, total, lineItems);
    }

    paySession.onpaymentauthorized = function (event) {
        var token = event.payment.token;
        alert("payment authorization | token = " + token);
        paySession.completePayment(ApplePaySession.STATUS_SUCCESS);
    }

    paySession.oncancel = function (event) {
        alert("payment cancel error " + event);
    }

    paySession.begin();
};


Get this bounty!!!

#StackBounty: #ios #node.js #express #stripe-payments #payment Apple Pay – "Payment Not Completed" – Using Stripe

Bounty: 50

I am using stripes “Payment Request Button” to implement Apple Pay for my website. On the stripe side of things all is well. The token is passed through correcty as I verified within Stripe logs.
https://stripe.com/docs/stripe-js/elements/payment-request-button

However, I get an error message: “Payment Not Completed” from Apple Pay every time I try to complete a test payment.

This has me stuck and I’m not sure how to debug or fix. Any ideas?

I get an undefined token

This is the error:

enter image description here

My set up:

FRONT END:

https://js.stripe.com/v3/
var stripe = Stripe('pk_test_xxxxx'); var paymentRequest = stripe.paymentRequest({ country: 'US', currency: 'usd', total: { label: 'JobQuiz', amount: 999, }, requestPayerName: true, requestPayerEmail: false, }); var elements = stripe.elements(); var prButton = elements.create('paymentRequestButton', { paymentRequest: paymentRequest, }); // Check the availability of the Payment Request API first. paymentRequest.canMakePayment().then(function(result) { if (result) { prButton.mount('#payment-request-button'); } else { document.getElementById('payment-request-button').style.display = 'none'; } }); paymentRequest.on('token', function(ev) { // Send the token to your server to charge it! fetch('/apple-pay', { method: 'POST', body: JSON.stringify({token: ev.token.id}), headers: {'content-type': 'application/json'}, }) .then(function(response) { if (response.ok) { // Report to the browser that the payment was successful, prompting // it to close the browser payment interface. ev.complete('success'); } else { // Report to the browser that the payment failed, prompting it to // re-show the payment interface, or show an error message and close // the payment interface. ev.complete('fail'); } }); });

Server side code in app.js

app.post('/apple-pay', function(req, res, next) {


// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")("sk_test_xxxxxx");

// Token is created using Checkout or Elements!
// Get the payment token ID submitted by the form:
const token = req.body.token; // Using Express

const charge = stripe.charges.create({
  amount: 999,
  currency: 'usd',
  description: 'Example charge',
  source: token,
}, function(err, charge){ 
if (err){

} else { 

}
});
});


Get this bounty!!!

#StackBounty: #ios #react-native #expo ReactNative: Image src not display properly

Bounty: 50

I’m using ReactNative + Expo
As what i know ios now required the transport is using HTTPS, when using HTTP it doesn’t render the image.

HTTPS: tested is working render properly
HTTP: test is not working

from google, it required this code into the project.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
</dict>
</plist>

My question is I do not have /ios project this is pure reactnative, how to make it work in expo? if not able where should i put this info.plist?

I have try put under /src/ios/{projectname}/Info.plist is not working.


Get this bounty!!!

#StackBounty: #ios #swift #amazon-web-services #aws-appsync #aws-appsync-ios How to set AWS Appsync request timeout limit || AWSAppSync…

Bounty: 50

I’m using AWS Appsync for the current App I’m developing and facing a serious issue that is Whenever I fire queries in Appsync client, when there is slow internet connection the request never end with a callback. I checked over internet there is limited source of information on this topic and also found this issue that is still open.

This is the code I used to get the response

func getAllApi(completion:@escaping DataCallback){
    guard isInternetAvailabele() else {
        completion(nil)
        return
    }
    // AppSyncManager.Client() is AWSAppSyncClient Object
    AppSyncManager.Client().fetch(query: GetlAllPostQuery(input: allInputs), cachePolicy:.fetchIgnoringCacheData) {
        (result, error) in
        var haveError:Bool = error != nil
        if let _ = result?.data?.getAllPostings?.responseCode {haveError = false} else {haveError = true}
        if haveError  {
            print(error?.localizedDescription ?? "")
            completion(nil)
            return
        }

        if result != nil{
            completion(result)
        }else{
            completion(nil)
        }
    }
}

The code works fine with internet connection and I have already checked at the top if there is no internet but when there is slow internet connection or the wifi is connected to a hotspot that I created with my mobile with internet data disabled the request doesn’t return any callback it should give failed alert like we get in other apis when the request time out.
Is there any support for request for request time out or did I miss something?

Note : I recieved these logs in Terminal

Task <06E9BBF4-5731-471B-9B7D-19E5E504E57F>.<45> HTTP load failed (error code: -1001 [1:60])
Task <D91CA952-DBB5-4DBD-9A90-98E2069DBE2D>.<46> HTTP load failed (error code: -1001 [1:60])
Task <06E9BBF4-5731-471B-9B7D-19E5E504E57F>.<45> finished with error - code: -1001
Task <D91CA952-DBB5-4DBD-9A90-98E2069DBE2D>.<46> finished with error - code: -1001


Get this bounty!!!

#StackBounty: #ios #objective-c Can't add unified CNContact to CNGroup in iOS

Bounty: 100

Here’s what I’m doing:

- (void)doCreateGroup {
    [[self contentView] endEditing:true];

    NSString * newString = [[[[self contentView] groupNameField] text] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    NSString * firstError = nil;
    if ([newString length] == 0) {
        firstError = @"Missing group name";
    }

    NSError * groupsError = nil;
    NSArray * groups = [self.contactStore groupsMatchingPredicate:nil error:&groupsError];

    for (CNGroup * group in groups) {
        if ([group.name isEqualToString:newString]) {
            firstError = @"Group already exists";
        }
    }

    if (firstError) {
        [self presentViewController:[WLGCommonUtilities doProcessErrorWithOkay:@"Error" errorMessage:firstError] animated:YES completion:nil];
        return;
    }

    CNMutableGroup * newGroup = [CNMutableGroup new];
    [newGroup setName:newString];

    CNSaveRequest *saveRequest = [CNSaveRequest new];
    [saveRequest addGroup:newGroup toContainerWithIdentifier:nil];

    NSError * error = nil;
    [self.contactStore executeSaveRequest:saveRequest error:&error];
    if (error) {
        [self presentViewController:[WLGCommonUtilities doProcessErrorWithOkay:@"Error" errorMessage:[error localizedDescription]] animated:YES completion:nil];
    } else {
        CNSaveRequest *saveRequest2 = [CNSaveRequest new];
        NSArray * groupsAgain = [self.contactStore groupsMatchingPredicate:nil error:&groupsError];
        CNGroup * gotGroup;
        for (CNGroup * group in groupsAgain) {
            if ([group.name isEqualToString:newString]) {
                gotGroup = group;
            }
        }
        for (CNContact * contact in self.selectedContactsArray) {
            [saveRequest2 addMember:contact toGroup:gotGroup];
        }

        NSError * error1 = nil;
        [self.contactStore executeSaveRequest:saveRequest2 error:&error1];
        if (error) {
            [self presentViewController:[WLGCommonUtilities doProcessErrorWithOkay:@"Error" errorMessage:[error1 localizedDescription]] animated:YES completion:nil];
        } else {
            [[self navigationController] dismissViewControllerAnimated:true completion:nil];
        }
    }
}

this works to create a CNGroup and then add contacts to said CNGroup. Works for all contacts EXCEPT for unified contacts. I’ve tried everything possible to make this work and it just doesn’t. It likely has something to do with the unified CNContact’s identifier since that identifier is only stored in temp memory so it can’t be added to a CNGroup since it doesn’t really haver a REAL CNContact identifier. Contacts framework is a mess! Any help would be appreciated. I’ve also filed a tech support request with Apple.

EDIT:
One way to get around this is to use Address Framework that is now deprecated. I can add as many unified contacts to Address groups by doing this.

ABRecordRef group = ABGroupCreate();
ABAddressBookAddRecord(addressBook, group, nil);

ABRecordSetValue(group, kABGroupNameProperty,@"My Groups", nil);
for (int i=0;i < nPeople;i++) {
    ABRecordRef ref = CFArrayGetValueAtIndex(allPeople,i);
    ABGroupAddMember(group, ref, nil);
    ABAddressBookSave(addressBook, nil);
}

this does save everything in the contact book to a group, all visible contacts that is. so it does store the Unified contact into the group. if you unlink the contacts while they are in a group, both contacts stay within the group. so the old framework works to solve this. just seems ridiculous that it can’t be solved with new Contacts framework. Again, I may be missing something with the new Contacts framework, so if this is possible with the current Contacts framework in iOS please let me know.


Get this bounty!!!

#StackBounty: #ios #objective-c #swift #xcode #bridging-header Xcode 10 Failed to emit precompiled header for bridging header

Bounty: 50

Hi I’m getting a very annoying error on Xcode 10 that is

1 error generated.
<unknown>:0: error: failed to emit precompiled header '/Users/me/Library/Developer/Xcode/DerivedData/APP-hlczpckeselwrtaqjcbxdpoiogkj/Build/Intermediates.noindex/PrecompiledHeaders/APP-Bridging-Header-swift_35K3KO8G70VCD-clang_3DGF15CYP79L0.pch' for bridging header '/Users/me/Desktop/Swift/Folder/APP/APP/UNLKV2-Bridging-Header.h'

I’m not sure how to solve this I have tried everything. It was very sudden today before there was no problem but the second I added the Firebase info.plist to the project I got this error. I have tried to delete the file, made sure the name of the header file was entered correctly in the “Objective-C Bridging Header” and I have it entered as
$(PROJECT_DIR)/$(PROJECT_NAME)/$(PROJECT_NAME)-Bridging-Header.h
I have cleaned and built the project multiple times and reinstalled all the pods.

Besides this, I also get an error that

JPSVolumeButtonHandler/JPSVolumeButtonHandler.h’ file not found

I would really appreciate it if someone could help me solve this, I’ve been looking around all day at every single post and forum and nothing has worked for me. If you need any more information about this issue, please let me know.


Get this bounty!!!

#StackBounty: #android #linux #ios #pdf-viewer Free PDF viewer for different operating systems that supports animations

Bounty: 50

I need to be able to view a pdf file that contains animations, and I need to be able to do this on all the common operating systems (Windows, Mac, Linux, Android, iPhone). What free programs can display such files correctly?

~edit~ Since no one seems to know the answer, could I get some help testing what works? I just need people to try to open this test file on their respective operating systems, using their available pdf-readers, and just report back if it works or not. It should take you all of 10 seconds to view the file and confirm this. Please state your operating system, the program you used, and whether or not the file displayed correctly.

These are some specific combinations of OS and program I would like to test, in addition to whatever program is most readily accessible to you:

  • Mac: whatever the default or pre-installed pdf-reader is
  • Mac: Adobe Acrobat Reader for Mac OS
  • Mac: Foxit Mobile PDF reader
  • iPhone: whatever the default or pre-installed pdf-reader is
  • iPhone: Adobe Acrobat Reader for iOS
  • iPhone: Foxit Mobile PDF reader
  • Android: Foxit Mobile PDF reader
  • Linux: any version of Adobe Acrobat Reader that can run on this OS, even if Adobe no longer supports it

These are my results so far:

  • What works: Adobe Acrobat Reader on Windows.
  • What doesn’t work: Foxit Mobile PDF for Windows, Adobe Acrobat Reader for Android, the built-in pdf-viewers for browsers (firefox, chrome, edge).

Thanks in advance for any help you can offer.


Get this bounty!!!

#StackBounty: #ios #objective-c #swift #amazon-web-services #aws-appsync-ios Process for uploading image to s3 with appsync || iOS Apps…

Bounty: 50

I’m working on a new project that requires uploading attachments in the form of images. I’m using DynamoDB and AppSync API’s to insert and retrieve data from database. As we are new to the AppSync and all the amazon services and database we are using for the app i’m little bit confused about the authentication process. Right now we are using API key for authentication and I have tried these steps to upload image to s3.

1 Configue the AWSServiceManager with static configuration like :-

let staticCredit =  AWSStaticCredentialsProvider(accessKey: kAppSyncAccessKey, secretKey: kAppSyncSecretKey)
let AppSyncRegion: AWSRegionType = .USEast2
let config = AWSServiceConfiguration(region: AppSyncRegion, credentialsProvider: staticCredit)
AWSServiceManager.default().defaultServiceConfiguration = config

2 Uploding picture with this method : –

func updatePictureToServer(url:URL, completion:@escaping (Bool)->Void){
    let transferManager = AWSS3TransferManager.default()
    let uploadingFileURL = url
    let uploadRequest = AWSS3TransferManagerUploadRequest()
    let userBucket = String(format: "BUCKET")
    uploadRequest?.bucket = userBucket
    let fileName = String(format: "%@%@", AppSettings.getUserId(),".jpg")
    uploadRequest?.key = fileName
    uploadRequest?.body = uploadingFileURL
    transferManager.upload(uploadRequest!).continueWith(executor: AWSExecutor.mainThread(), block: { (task:AWSTask<AnyObject>) -> Any? in
        if let error = task.error as NSError? {
            if error.domain == AWSS3TransferManagerErrorDomain, let code = AWSS3TransferManagerErrorType(rawValue: error.code) {
                switch code {
                case .cancelled, .paused:
                    break
                default:
                    print("Error uploading: (String(describing: uploadRequest!.key)) Error: (error)")
                }
            } else {
                print("Error uploading: (String(describing: uploadRequest!.key)) Error: (error)")
            }
            completion(false)
            return nil
        }

        _ = task.result
        completion(true)
        print("Upload complete for: (String(describing: uploadRequest!.key))")
        return nil
    })
}

3 And finally i’m able to see the uploaded image on the S3 bucket

enter image description here

But i’m concerned about how to save the url of the image and how to retrieve the image because when i have to make the buket PUBLIC to retrieve the image and i don’t think that’s a good approach, plus is it necessary to have a Cognito user pool because we aren’t using Cognito user pool yet in our app and not have much knowledge about that too and documents are not helping in practical situations because we are implementing ti for the first time so we need some little help.

So two question : –

  1. Proper procedure to use for uploading and retrieving images for S3 and AppSync.
  2. Is it necessary to use Cognito user pool for image uploading and retrieving.

Thanks

Note: Any suggestion or improvement or anything related to the AppSync, S3 or DynamoDB will be truly appreciated and language is not a barrier just looking for directions so swift or objective-c no problem.


Get this bounty!!!