in-app-payments-react-native-plugin icon indicating copy to clipboard operation
in-app-payments-react-native-plugin copied to clipboard

App rejected by apple appstore

Open aargon007 opened this issue 1 year ago • 2 comments

WhatsApp Image 2024-09-04 at 4 11 31 PM I am using this plugin in my Expo React native project. all works in Native cli project development version. But when i deployed the app in apple testflight it got rejected with 5 issues. here is my code

import { SQIPCore, SQIPCardEntry } from 'react-native-square-in-app-payments';

SQIPCore.setSquareApplicationId('sandbox-sq0idb-88yVghwpOp1hSmaA5v1e2w');

const ConsultationBooking = () => {
 const handleBooking = async () => {
try {
                const cardEntryConfig = {
                    collectPostalCode: true
                };
                await SQIPCardEntry.startCardEntryFlow(
                    cardEntryConfig,
                    async (cardDetails) => {
                        // Handle payment success
                        await SQIPCardEntry.completeCardEntry(() => {
                            // console.log(JSON.stringify(cardDetails));
                            confirmBooking({
                                date: selected,
                                time: time,
                                foundItem: foundItem?._id,
                                nonce: cardDetails.nonce
                            }).unwrap().then((res) => {
                                // console.log(res);
                                Toast.show({
                                    type: 'success',
                                    text1: res?.message,
                                });
                            });
                        });
                    },
                    () => {
                        // Handle payment failure
                        console.log("cardEntryError");
                    }
                );
            } catch (ex) {
                console.log(ex);
            }
        }
...
}


App Details:
  - platform: iOS
  - OS and version: iOS15.5
  - dev environment: MacOS
  - In-App Payments Plugin version: 1.7.6
  - Expo : 51
  - RN: 0.74

aargon007 avatar Sep 04 '24 10:09 aargon007

Hey @aargon007, I am in a similar situation. Have you found any solution yet? Thanks

tirrth avatar Sep 13 '24 23:09 tirrth

Hey @aargon007, I am in a similar situation. Have you found any solution yet? Thanks

yeah!! do you solved this issues? maybe i can help you

aargon007 avatar Sep 18 '24 03:09 aargon007

Did anyone manage to solve this?

hmirza1 avatar Jan 19 '25 12:01 hmirza1

Hey @aargon007, I am in a similar situation. Have you found any solution yet? Thanks

yeah!! do you solved this issues? maybe i can help you

Looking for a resolution as well

Ocean572 avatar Aug 22 '25 16:08 Ocean572

@hmirza1 @Ocean572 you have to create a build script to solve the issue. Let me show you how i have done this.

  1. create reorderSquareIAPBuildPhase.rb in root folder
#!/usr/bin/env ruby

 require 'xcodeproj'
 require 'set'
 
 project_file, target_name = ARGV
 
 puts "Sorting sources in #{project_file} for target #{target_name}"
 
 project = Xcodeproj::Project.open(project_file)
 target = project.targets.select { |t| t.name == target_name }.first
 square_framework_run_script_index = target.build_phases.index { |b|
     name = b.name if b.respond_to? :name
     name == "Square Framework Run Script - InAppPaymentsSDK" #name of build phase you have given in plugin below
 }
 puts "Square Framework Run Script index: #{square_framework_run_script_index} Total build phases: #{target.build_phases.count - 1}"
 if square_framework_run_script_index.nil? == false
     puts "Moving Square Framework Run Script from #{square_framework_run_script_index} to the #{target.build_phases.count - 1} index"
     target.build_phases.move_from(square_framework_run_script_index, target.build_phases.count - 1) # move to the last indexs
 end
 project.save
  1. then create squareIOSBuildPhasePlugin.js in the root directory
const { withXcodeProject } = require('@expo/config-plugins');

const addBuildPhaseForSquareIOS = config => {
    return withXcodeProject(config, async conf => {
        const project = conf.modResults;

        project.addBuildPhase(
            [],
            'PBXShellScriptBuildPhase',
            'Square Framework Run Script - InAppPaymentsSDK', // build phase name
            project.getFirstTarget().uuid,
            {
                shellPath: '/bin/sh',
                shellScript:
                    'FRAMEWORKS="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}" && "${FRAMEWORKS}/SquareInAppPaymentsSDK.framework/setup"',
            }
        );

        return conf;
    });
};

module.exports = addBuildPhaseForSquareIOS;
  1. now create eas-build-post-install.sh in root directory of the project. set the actual project name in the mentioned ProjectName (here is HerbFitz)
#!/usr/bin/env bash

# This is a file called "pre-install" in the root of the project
if [[ "$EAS_BUILD_PLATFORM" == "ios" ]]; then
    ./reorderSquareIAPBuildPhase.rb ios/HerbFitz.xcodeproj HerbFitz
fi
  1. add this script in package.json

"eas-build-post-install": "chmod +x ./eas-build-post-install.sh ./reorderSquareIAPBuildPhase.rb && ./eas-build-post-install.sh"

  1. now add the plugin in app.json

"plugins": [["./squareIOSBuildPhasePlugin.js"]]

aargon007 avatar Aug 22 '25 17:08 aargon007

Hi @aargon007 would this also work on expo projects

Marcel-Ng avatar Oct 26 '25 16:10 Marcel-Ng

Hi @aargon007 would this also work on expo projects

Yes. but you have to make a development build to run the app

aargon007 avatar Oct 26 '25 16:10 aargon007

Okay thanks @aargon007, so if I get you clearly I have to

  1. In my expo project in the root folder, create the reorderSquareIAPBuildPhase.rb or is that supposed to be in the ios root folder?

Same way run through to step 5 and then run npx expo run:ios before then running eas build -p ios

Please could you help clarify me on this. Thank you.

Marcel-Ng avatar Oct 26 '25 16:10 Marcel-Ng

Okay thanks @aargon007, so if I get you clearly I have to

  1. In my expo project in the root folder, create the reorderSquareIAPBuildPhase.rb or is that supposed to be in the ios root folder?

Same way run through to step 5 and then run npx expo run:ios before then running eas build -p ios

Please could you help clarify me on this. Thank you.

reorderSquareIAPBuildPhase.rb is a ruby file, will be in your root project folder. after all 5 step you can make dev or prod build

if it failed during build you can paste the log, i can help you

aargon007 avatar Oct 26 '25 16:10 aargon007

So I have completed from step 1 through 5. then ran npx expo prebuild --clean worked just fine. But when I ran eas build -p ios, I ran into this error.

Script 'eas-build-post-install' is present in package.json, running it...
yarn run v1.22.22
$ chmod +x ./eas-build-post-install.sh ./reorderSquareIAPBuildPhase.rb && ./eas-build-post-install.sh
./reorderSquareIAPBuildPhase.rb:12:in `<main>': undefined method `build_phases' for nil:NilClass (NoMethodError)
 square_framework_run_script_index = target.build_phases.index { |b|
                                           ^^^^^^^^^^^^^
Sorting sources in ios/PluritonguesApp.xcodeproj for target HerbFitz
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run eas-build-post-install exited with non-zero code: 1```

Marcel-Ng avatar Oct 26 '25 17:10 Marcel-Ng

So I have completed from step 1 through 5. then ran npx expo prebuild --clean worked just fine. But when I ran eas build -p ios, I ran into this error.

Script 'eas-build-post-install' is present in package.json, running it...
yarn run v1.22.22
$ chmod +x ./eas-build-post-install.sh ./reorderSquareIAPBuildPhase.rb && ./eas-build-post-install.sh
./reorderSquareIAPBuildPhase.rb:12:in `<main>': undefined method `build_phases' for nil:NilClass (NoMethodError)
 square_framework_run_script_index = target.build_phases.index { |b|
                                           ^^^^^^^^^^^^^
Sorting sources in ios/PluritonguesApp.xcodeproj for target HerbFitz
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run eas-build-post-install exited with non-zero code: 1```


HerbFitz was my app name. instead of it use your app name in eas-build-post-install.sh

aargon007 avatar Oct 26 '25 17:10 aargon007

Ahhh, thanks a lot. realized that mistake immediately after I sent the comment. Fixed it now, and it worked, and submitted to TestFlight.

Marcel-Ng avatar Oct 26 '25 19:10 Marcel-Ng