[Step 6 of 9] The buyer is redirected to checkoutResultReturnUrl after Amazon Pay has processed the transaction. The Amazon Pay checkout session ID will be included as a query parameter.
In this step, you will use the checkout session ID to confirm that the buyer has successfully returned to your site and finalize the paymentIntent. At the end of this step, you will be able to present the buyer with the checkout result.
Note: If your publicKeyId does not have an environment prefix (does not begin with 'SANDBOX' or 'LIVE') follow these instructions instead.
Note: If your publicKeyId has an environment prefix (for example: SANDBOX-AFVX7ULWSGBZ5535PCUQOY7B) follow these instructions instead.
Use Complete Checkout Session to confirm that the buyer has successfully returned to your site. The chargeAmount in the request must match the Checkout Session object paymentDetails.chargeAmount to verify order amount. You must also specify totalOrderAmount if one was provided for the Checkout Session object.
Note: Amazon Pay will not finalize the paymentIntent until you confirm checkout with Complete Checkout Session. Any Checkout Session that is not confirmed within 24 hours will be cancelled. If payment authorization was requested it will also be cancelled.
Successful response:
Complete Checkout Session will return a success response if the transaction was processed successfully. Implement the guidance that corresponds to the Checkout Session paymentIntent:
paymentIntent
Description
AuthorizeWithCapture
Payment has been authorized and captured.
1. Store the ChargeId - You must store the ChargeId to process refunds.
2. Store the ChargePermissionId - If you specified totalOrderAmount and there is uncaptured payment, see manage deferred payments for more information. You can also use the ChargePermissionId to retrieve buyer and transaction info using Get Charge Permission for 30 days, you must store the data to persist the information beyond 30 days.
Authorize
Payment has been authorized.
1. Store the ChargeId - You must store the ChargeID for deferred payment capture. See deferred transactions for more info.
2. Store the ChargePermissionId - If you specified totalOrderAmount and there is uncaptured payment, see manage deferred payments for more information. You can also use the ChargePermissionId to retrieve buyer and transaction info using Get Charge Permission for 30 days, you must store the data to persist the information beyond 30 days.
Confirm
Payment has not been authorized or captured.
1. Store the ChargePermissionId - You must store the ChargePermissionId for deferred payment authorization. See deferred transactions for more info. You can also use the ChargePermissionId to retrieve buyer and transaction info after checkout. You will only be able to retrieve the data using Get Charge Permission for 30 days, you must store the data to persist the information beyond 30 days.
Error response:
Complete Checkout Session will return an error response for failed transactions. The buyer either canceled checkout or was unable to provide a valid payment instrument. You should:
Redirect the buyer to the start of checkout
Display a message such as: "Your payment was not successful. Please try another payment method.“
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.CheckoutSession;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public CheckoutSessionResponse CompleteCheckoutSession(string checkoutSessionId)
{
// prepare the request
var request = new CompleteCheckoutSessionRequest(14.00M, Currency.USD);
// send the request
var result = client.CompleteCheckoutSession(checkoutSessionId, request);
// check if API call was successful
if (!result.Success)
{
// do something, e.g. throw an error
}
return result;
}
}
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.CheckoutSession;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
environment: Environment.Sandbox,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public CheckoutSessionResponse CompleteCheckoutSession(string checkoutSessionId)
{
// prepare the request
var request = new CompleteCheckoutSessionRequest(14.00M, Currency.USD);
// send the request
var result = client.CompleteCheckoutSession(checkoutSessionId, request);
// check if API call was successful
if (!result.Success)
{
// do something, e.g. throw an error
}
return result;
}
}
Note: This section is only applicable if you ship packages using a supported carrier.
Send shipment tracking information to Amazon Pay using the Delivery Tracker API. Amazon Pay will notify your buyers on their Alexa device when their package is shipped and when their package is delivered. See setting up delivery notifications for more info.