如何修改Square Connect API及iOS POS收据中的Custom Amount文本?
Hey there! I’ve worked with Square’s Point of Sale API for iOS before, so let’s get that receipt text changed for you.
The "Custom Amount" text you’re seeing is the default label for custom amount transactions. To replace it with your own text, you just need to use a specific property when building your SCCAPIRequest object:
Step-by-Step Fix
When initializing your transaction request, add the customAmountDescription parameter and set it to your desired text. This will directly replace the default "Custom Amount" on the receipt.
Here’s a Swift example to show you how it works:
import SquarePointOfSaleSDK // Build your custom amount request let posRequest = SCCAPIRequest( locationID: "YOUR_LOCATION_ID", // Replace with your actual location ID callbackURL: URL(string: "your-app-scheme://square-pos-callback")!, // Your app's callback scheme amount: 1500, // Amount in cents (e.g., $15.00) currencyCode: "USD", transactionNotes: "Your existing transaction note here", // Your existing note works as before customerID: nil, supportedTenderTypes: .all, customAmountDescription: "Your Custom Label", // This replaces "Custom Amount" skipReceipt: false ) // Send the request to Square POS SCCAPIConnection.perform(posRequest) { result in // Handle the result here }
And if you’re using Objective-C, here’s the equivalent:
#import <SquarePointOfSaleSDK/SquarePointOfSaleSDK.h> SCCAPIRequest *request = [[SCCAPIRequest alloc] initWithLocationID:@"YOUR_LOCATION_ID" callbackURL:[NSURL URLWithString:@"your-app-scheme://square-pos-callback"] amount:@1500 currencyCode:@"USD" transactionNotes:@"Your existing transaction note here" customerID:nil supportedTenderTypes:SCCAPIRequestTenderTypeAll customAmountDescription:@"Your Custom Label" skipReceipt:NO]; [SCCAPIConnection performRequest:request completionHandler:^(SCCAPIResponse * _Nullable response, NSError * _Nullable error) { // Handle response/error }];
Key Notes
- Make sure you’re using the latest version of the Square Point of Sale SDK for iOS to ensure this property is available.
- The
customAmountDescriptiontargets specifically that label on the receipt—your existingtransactionNoteswill still appear in the receipt’s notes section as it did before.
That should do it! After adding this parameter, your receipt will show your custom text instead of "Custom Amount".
内容的提问来源于stack exchange,提问作者venkat

