payfort / payfort-php-sdk

30 stars 44 forks source link

Amazon Payment Services PHP SDK

Amazon Payment Services SDK offers seamless payments for PHP platform merchants. If you don't have an APS account click here to sign up for Amazon Payment Services account.

Getting Started

We know that payment processing is critical to your business. With this plugin we aim to increase your payment processing capabilities. Do you have a business-critical questions? View our quick reference documentation for key insights covering payment acceptance, integration, and reporting. For SDK Guide refer wiki

Payment Options

Integrations steps

Install PHP SDK Package

Install the PHP SDK Package of your solution with composer or download it from the GitHub repository and then run the composer update command in terminal to install all the dependencies.

Merchant configuration

As a merchant you need to send to the gateway some properties. These properties must be put into an array and set with the following method. If you want integration with Apple Pay all the properties that contains "Apple_" must be added, otherwise those properties are not required.

Properties sample ```php 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',
]; ```

All the merchant configuration properties

// load merchant configuration
$merchantParams = include 'merchant_config.php';

// set merchant configuration one time
APSMerchant::setMerchantParams($merchantParams);

Payment data configuration

As a merchant you need to send to the gateway the payment details. These details must be put into an array and set within the "setPaymentData" method below. The "merchant_reference" is the customer order number.

<?php

return  [
    'merchant_reference'=> 'O-00001-'.rand(1000, 99999),
    'amount'            => 3197.00,
    'currency'          => 'AED',
    'language'          => 'en',
    'customer_email'    => 'test@aps.com',

    'order_description' => 'Test product 1',
];

You can see below how the credit card redirect payment method issued. Payment data is set with the payment details, then set the authorization/purchase command, set your callback URL and render the information needed for your client page.

Sample ```
setPaymentData($paymentData) ->useAuthorizationCommand() ->setCallbackUrl(‘callback-url.php’) ->render([ ‘button_text’ => ‘Place order with Authorization’ ]); } catch (APSException $e) { echo ‘SETUP ERROR: ‘ . $e->getMessage(); } ?>
setPaymentData($paymentData) ->usePurchaseCommand() ->setCallbackUrl(‘callback-url.php’) ->render([ ‘button_text’ => ‘Place order with Purchase’ ]); } catch (APSException $e) { echo ‘SETUP ERROR: ‘ . $e->getMessage(); } ?> ```

Standard Checkout

The class for Standard Checkout payment option is called "CCStandard". This class can be used for Authorization or for Purchase command. For example, see the code below.

Sample ```
setPaymentData($paymentData) ->useAuthorizationCommand() ->setCallbackUrl('callback-url.php') ->render([ 'button_text' => 'Place order with Authorization' ]); } catch (APSException $e) { echo 'SETUP ERROR: ' . $e->getMessage(); } ?>
setPaymentData($paymentData) ->usePurchaseCommand() ->setCallbackUrl('callback-url.php') ->render([ 'button_text' => 'Place order with Purchase' ]); } catch (APSException $e) { echo 'SETUP ERROR: ' . $e->getMessage(); } ?>
```

Custom Checkout

The class for Custom Checkout payment option is called "CCCustom". This class can be used for Authorization or for Purchase command. For example, see the code below.

Sample ```
setPaymentData($paymentData) ->useAuthorizationCommand() ->setCallbackUrl('callback-url.php') ->render([ 'button_text' => 'Place order with Authorization' ]); } catch (APSException $e) { echo 'SETUP ERROR: ' . $e->getMessage(); } ?>
setPaymentData($paymentData) ->usePurchaseCommand() ->setCallbackUrl('callback-url.php') ->render([ 'button_text' => 'Place order with Purchase' ]); } catch (APSException $e) { echo 'SETUP ERROR: ' . $e->getMessage(); } ?>
```

Changelog

Plugin Version Release Notes
2.0.0 Integrated checkout experience options: Redirection, Merchant Page, Hosted Merchant Page, Apple Pay, Installments, Recurring, MOTO, Trusted
Partial/Full Refund, Single/Multiple Capture and Void events
Signature calculation and validation
Check Status as a function
Feedback notification handling

API Documentation

This SDK has been implemented by using following API library

Further Questions

Have any questions? Just get in touch

License

Released under the MIT License.