Call Update Charge Permission to update external merchant metadata or the recurringMetadata if subscription details change post-checkout. You can update merchantMetadata child parameters multiple times if the Charge Permission is in a Chargeable or NonChargeable state. You can update merchantMetadata child parameters if the Charge Permission is in a Closed state only if chargePermissionType is Onetime and if the child parameter value to be updated is either null or an empty string. Note that buyer communication will not reflect the updated value if the Charge Permission is in a Closed state.
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.
Metadata about how the recurring Charge Permission will be used. Amazon Pay only uses this information to calculate the Charge Permission expiration date and in buyer communication
Note that it is still your responsibility to call Create Charge to charge the buyer for each billing cycle
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.ChargePermission;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.UnitedStates,
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 void UpdateChargePermission()
{
// prepare the request
var chargePermissionId = "S01-5105180-3221187";
var request = new UpdateCheckoutSessionRequest()
{
RecurringMetadata =
{
Frequency = {
Unit = FrequencyUnit.Month,
Value = 1
},
Amount = {
Amount = 14,
CurrencyCode = Currency.USD
}
},
MerchantMetadata = {
MerchantReferenceId = "123-77-876",
MerchantStoreName = "AmazonTestStoreFront",
NoteToBuyer = "merchantNoteForBuyer",
CustomInformation = "This is custom information"
}
};
// send the request
ChargePermissionResponse result = client.UpdateChargePermission(chargePermissionId, request);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
}
// do something with the result, for instance:
State chargePermissionState = result.StatusDetails.State;
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
// for generating an idempotency key
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.NA)
.setPrivateKey("YOUR_PRIVATE_KEY")
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
AmazonPayResponse response = null;
String chargePermissionId = "S01-5105180-3221187";
JSONObject payload = new JSONObject();
JSONObject merchantMetadata = new JSONObject();
merchantMetadata.put("merchantReferenceId", "32-41-323141");
merchantMetadata.put("merchantStoreName", "AmazonTestStoreName");
merchantMetadata.put("noteToBuyer", "merchantNoteForBuyer");
merchantMetadata.put("customInformation", "This is custom information");
payload.put("merchantMetadata", merchantMetadata);
JSONObject recurringMetadata = new JSONObject();
JSONObject frequency = new JSONObject();
frequency.put("unit","Month");
frequency.put("value","1");
recurringMetadata.put("frequency", frequency);
JSONObject amount = new JSONObject();
amount.put("amount","14");
amount.put("currencyCode","USD");
recurringMetadata.put("amount", amount);
payload.put("recurringMetadata", recurringMetadata);
response = webstoreClient.updateChargePermission(chargePermissionId, payload);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.ChargePermission;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.UnitedStates,
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 void UpdateChargePermission()
{
// prepare the request
var chargePermissionId = "S01-5105180-3221187";
var request = new UpdateCheckoutSessionRequest()
{
RecurringMetadata =
{
Frequency = {
Unit = FrequencyUnit.Month,
Value = 1
},
Amount = {
Amount = 14,
CurrencyCode = Currency.USD
}
},
MerchantMetadata = {
MerchantReferenceId = "123-77-876",
MerchantStoreName = "AmazonTestStoreFront",
NoteToBuyer = "merchantNoteForBuyer",
CustomInformation = "This is custom information"
}
};
// send the request
ChargePermissionResponse result = client.UpdateChargePermission(chargePermissionId, request);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
}
// do something with the result, for instance:
State chargePermissionState = result.StatusDetails.State;
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Environment;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
// for generating an idempotency key
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.NA)
.setPrivateKey("YOUR_PRIVATE_KEY")
.setEnvironment(Environment.SANDBOX)
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
AmazonPayResponse response = null;
String chargePermissionId = "S01-5105180-3221187";
JSONObject payload = new JSONObject();
JSONObject merchantMetadata = new JSONObject();
merchantMetadata.put("merchantReferenceId", "32-41-323141");
merchantMetadata.put("merchantStoreName", "AmazonTestStoreName");
merchantMetadata.put("noteToBuyer", "merchantNoteForBuyer");
merchantMetadata.put("customInformation", "This is custom information");
payload.put("merchantMetadata", merchantMetadata);
JSONObject recurringMetadata = new JSONObject();
JSONObject frequency = new JSONObject();
frequency.put("unit","Month");
frequency.put("value","1");
recurringMetadata.put("frequency", frequency);
JSONObject amount = new JSONObject();
amount.put("amount","14");
amount.put("currencyCode","USD");
recurringMetadata.put("amount", amount);
payload.put("recurringMetadata", recurringMetadata);
response = webstoreClient.updateChargePermission(chargePermissionId, payload);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}