35398340449619004
# Install using Composer
composer require amzn/amazon-pay-api-sdk-php
# Install using Composer
composer require amzn/amazon-pay-api-sdk-php
{
"webCheckoutDetails": {
"checkoutReviewReturnUrl": "https://a.com/merchant-review-page"
},
"storeId": "amzn1.application-oa2-client.8b5e45312b5248b69eeaStoreId",
"scopes": ["name", "email", "phoneNumber", "billingAddress"],
"deliverySpecifications": {
"specialRestrictions": ["RestrictPOBoxes"],
"addressRestrictions": {
"type": "Allowed",
"restrictions": {
"US": {
"statesOrRegions": ["WA"],
"zipCodes": ["95050", "93405"]
},
"GB": {
"zipCodes": ["72046", "72047"]
},
"IN": {
"statesOrRegions": ["AP"]
},
"JP": {}
}
}
}
}
'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem',
'region' => 'YOUR_REGION_CODE',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2',
);
$payload = array(
"webCheckoutDetails" => array(
"checkoutReviewReturnUrl" => "https://a.com/merchant-review-page"
),
"storeId" => "amzn1.application-oa2-client.8b5e45312b5248b69eeaStoreId",
"scopes" => array(
"name",
"email",
"phoneNumber",
"billingAddress"
),
"deliverySpecifications" => array(
"specialRestrictions" => array(
"RestrictPOBoxes"
),
"addressRestrictions" => array(
"type" => "Allowed",
"restrictions" => array(
"US" => (object) array(
"statesOrRegions" => array(
"WA"
),
"zipCodes" => array(
"95050",
"93405"
)
),
"GB" => (object) array(
"zipCodes" => array(
"72046",
"72047"
)
),
"IN" => (object) array(
"statesOrRegions" => array(
"AP"
)
),
"JP" => (object) array()
)
)
)
);
$headers = array('x-amz-pay-Idempotency-Key' => uniqid());
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->createCheckoutSession($payload, $headers);
if ($result['status'] === 201) {
// created
$response = json_decode($result['response'], true);
$checkoutSessionId = $response['checkoutSessionId'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n";
}
} catch (\Exception $e) {
// handle the exception
echo $e . "\n";
}
?>
'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem',
'region' => 'YOUR_REGION_CODE',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->getCheckoutSession('bd504926-f659-4ad7-a1a9-9a747aaf5275');
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$checkoutSessionState = $response['statusDetails']['state'];
$chargeId = $response['chargeId'];
$chargePermissionId = $response['chargePermissionId'];
// NOTE: Once Checkout Session moves to a "Completed" state, buyer and shipping
// details must be obtained from the getChargePermission() function call instead
$buyerName = $response['buyer']['name'];
$buyerAddress = $response['buyer']['shippingAddress'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n";
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$payload = array(
'webCheckoutDetails' => array(
'checkoutResultReturnUrl' => 'https://a.com/merchant-confirm-page'
),
'paymentDetails' => array(
'paymentIntent' => 'AuthorizeWithCapture',
'canHandlePendingAuthorization' => false,
'softDescriptor' => 'Descriptor',
'chargeAmount' => array(
'amount' => '1',
'currencyCode' => 'USD'
)
),
'merchantMetadata' => array(
'merchantReferenceId' => 'Merchant reference ID',
'merchantStoreName' => 'Merchant store name',
'noteToBuyer' => 'Note to buyer',
'customInformation' => 'Custom information'
)
);
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->updateCheckoutSession('bd504926-f659-4ad7-a1a9-9a747aaf5275', $payload);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$amazonPayRedirectUrl = $response['webCheckoutDetails']['amazonPayRedirectUrl'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$payload = array(
'chargeAmount' => array(
'amount' => '14.00',
'currencyCode' => 'USD'
)
);
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->completeCheckoutSession('bd504926-f659-4ad7-a1a9-9a747aaf5275', $payload);
if ($result['status'] === 202) {
// Charge Permission is in AuthorizationInitiated state
$response = json_decode($result['response'], true);
$checkoutSessionState = $response['statusDetails']['state'];
$chargeId = $response['chargeId'];
$chargePermissionId = $response['chargePermissionId'];
}
else if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$checkoutSessionState = $response['statusDetails']['state'];
$chargePermissionId = $response['chargePermissionId'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n";
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$payload = array(
'shippingAddress' => array(
'name' => 'Susi S',
'addressLine1' => '11 Ditka Ave',
'addressLine2'=> 'Suite 2500',
'city'=> 'Chicago',
'stateOrRegion'=> 'IL',
'postalCode'=> '60602',
'countryCode'=> 'US',
'phoneNumber'=> '800-000-0000'
),
'chargeAmount' => array(
'amount' => '14.00',
'currencyCode' => 'USD'
),
'paymentIntent' => 'AuthorizeWithCapture'
);
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->finalizeCheckoutSession('bd504926-f659-4ad7-a1a9-9a747aaf5275', $payload);
if ($result['status'] === 202) {
// Charge Permission is in AuthorizationInitiated state
$response = json_decode($result['response'], true);
$checkoutSessionState = $response['statusDetails']['state'];
$chargeId = $response['chargeId'];
$chargePermissionId = $response['chargePermissionId'];
}
else if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$checkoutSessionState = $response['statusDetails']['state'];
$chargePermissionId = $response['chargePermissionId'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n";
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
babysachen online kaufen gestrickte Babykleidung bio strickjacken fuer babys
top of page
bottom of page