PHP code example of amazonpaymentservices / aps-php-sdk

1. Go to this page and download the library: Download amazonpaymentservices/aps-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

amazonpaymentservices / aps-php-sdk example snippets


php


return [
    'merchant_identifier'       => '**********',
   
 'access_code'               => '**********',
    
'SHARequestPhrase'          => '**********',
   
 'SHAResponsePhrase'         => '**********',
    
'SHAType'                   => '**********',
   
 'sandbox_mode'              => true,

   
 'Apple_AccessCode'          => '**********',
   
 'Apple_SHARequestPhrase'    => '**********',
   
 'Apple_SHAResponsePhrase'   => '**********',
    
'Apple_SHAType'             => '**********',
    
'Apple_DisplayName'         => 'Test Apple store',
   
 'Apple_DomainName'          => 'https://store.local.com',
    
'Apple_SupportedNetworks'   => ["visa", "masterCard", "amex", "mada"],
    
'Apple_SupportedCountries'  => [],
   
 'Apple_CertificatePath'     => '**path**to**certificate**',
   
 'Apple_CertificateKeyPath'  => '**path**to**certificate**key**',
   
 'Apple_CertificateKeyPass'  => 'apple*certificate*password',

   
 // folder must be created before
    
'log_path'                  => __DIR__ . '/tmp/aps.log',
   
'3ds_modal'                 => true,
    
'debug_mode'                => false,
    
'locale'                    => 'en',
];


// load merchant configuration
$merchantParams = ant::setMerchantParams($merchantParams);



return  [
    'merchant_reference'=> 'O-00001-'.rand(1000, 99999),
    'amount'            => 3197.00,
    'currency'          => 'AED',
    'language'          => 'en',
    'customer_email'    => '[email protected]',

    'order_description' => 'Test product 1',
];
<div>
    
    try {
        echo (new CCRedirect())
            ->setPaymentData($paymentData)
            ->useAuthorizationCommand()
            ->setCallbackUrl(‘callback-url.php’)
            ->render([
                    ‘button_text’   => ‘Place order with Authorization’
            ]);
    } catch (APSException $e) {
        echo ‘SETUP ERROR: ‘ . $e->getMessage();
    }
    
   
<div>
    
    try {
        echo (new CCStandard())
            ->setPaymentData($paymentData)
            ->useAuthorizationCommand()
            ->setCallbackUrl('callback-url.php')
            ->render([
                    'button_text'   => 'Place order with Authorization'
            ]);
    } catch (APSException $e) {
        echo 'SETUP ERROR: ' . $e->getMessage();
    }
    

<div>
    
    try {
        echo (new CCCustom())
            ->setPaymentData($paymentData)
            ->useAuthorizationCommand()
            ->setCallbackUrl('callback-url.php')
            ->render([
                    'button_text'   => 'Place order with Authorization'
            ]);
    } catch (APSException $e) {
        echo 'SETUP ERROR: ' . $e->getMessage();
    }