In-App Payments SDK Quick Start

Step 5: Take payment with a server backend

cURL commands are useful for testing, but impractical for production. Use our sample server to process a production Charge request.

Java (Android)
Android
iOS
Save
  1. In com/example/supercookie/ConfigHelper.java, set the CHARGE_SERVER_HOST to the Heroku server host deployed in the previous step.
private static final String CHARGE_SERVER_HOST = "REPLACE_ME";
private static final String CHARGE_SERVER_URL = "https://" + CHARGE_SERVER_HOST + "/";
  1. Build and run the app in Android studio.
  2. Tap the Buy button and choose Pay with card and enter your card information.
  3. After submitting your card information, you will get a success message indicating that a nonce has been created. The sample also makes a call to your deployed server to complete the payment with the nonce.
  1. In InAppPaymentsSample/Constants/Constants.swift set the CHARGE_SERVER_HOST to the Heroku server host deployed in the previous step.
struct Square {
    ...
    static let CHARGE_SERVER_HOST: String = "REPLACE_ME"
    static let CHARGE_URL: String = "\(CHARGE_SERVER_HOST)/chargeForCookie"
}
  1. Build and run the app in Xcode.
  2. Tap the Buy button, choose Pay with card, and enter your card information.
  3. After submitting your card information, if a nonce is created, the sample app calls to your deployed sample server to charge the nonce. If the server completes the charge, the app displays a success message.

Once you see the success message you can view the transaction details in Square Dashboard.

Congratulations! You just completed a production-style credit card transaction with In-App Payments SDK.

Next Steps

Follow a link below to start building custom solutions with In-App Payments SDK.

Prev
< Deploy a server backend

Contact Developer Support, join our Slack channel, or ask for help on Stack Overflow