PHP Class PayWithAmazon\Client

Inheritance: implements paywithamazon\ClientInterface, implements Psr\Log\LoggerAwareInterface
Datei anzeigen Open project: amzn/login-and-pay-with-amazon-sdk-php

Public Properties

Property Type Description
$success Boolean variable to check if the API call was a success

Public Methods

Method Description
__construct ( $config = null ) * Takes user configuration array from the user as input Takes JSON file path with configuration information as input Validates the user configuration array against existing config array
__get ( $name ) * Getter Gets the value for the key if the key exists in config
authorize ( $requestParameters = [] ) * Authorize API call - Reserves a specified amount against the payment method(s) stored in the order reference.
authorizeOnBillingAgreement ( $requestParameters = [] ) * AuthorizeOnBillingAgreement API call - Reserves a specified amount against the payment method(s) stored in the Billing Agreement.
cancelOrderReference ( $requestParameters = [] ) * CancelOrderReferenceDetails API call - Cancels a previously confirmed order reference.
capture ( $requestParameters = [] ) * Capture API call - Captures funds from an authorized payment instrument.
charge ( $requestParameters = [] ) * charge convenience method Performs the API calls 1. SetOrderReferenceDetails / SetBillingAgreementDetails 2. ConfirmOrderReference / ConfirmBillingAgreement 3. Authorize (with Capture) / AuthorizeOnBillingAgreeemnt (with Capture)
closeAuthorization ( $requestParameters = [] ) * CloseAuthorization API call - Closes an authorization.
closeBillingAgreement ( $requestParameters = [] ) * CloseBillingAgreement API Call - Returns details about the Billing Agreement object and its current state.
closeOrderReference ( $requestParameters = [] ) * CloseOrderReferenceDetails API call - Confirms that an order reference has been fulfilled (fully or partially) and that you do not expect to create any new authorizations on this order reference.
confirmBillingAgreement ( $requestParameters = [] ) * ConfirmBillingAgreement API Call - Confirms that the Billing Agreement is free of constraints and all required information has been set on the Billing Agreement.
confirmOrderReference ( $requestParameters = [] ) * ConfirmOrderReferenceDetails API call - Confirms that the order reference is free of constraints and all required information has been set on the order reference.
createOrderReferenceForId ( $requestParameters = [] ) * CreateOrderReferenceForId API Call - Creates an order reference for the given object
getAuthorizationDetails ( $requestParameters = [] ) * GetAuthorizationDetails API call - Returns the status of a particular authorization and the total amount captured on the authorization.
getBillingAgreementDetails ( $requestParameters = [] ) * GetBillingAgreementDetails API Call - Returns details about the Billing Agreement object and its current state.
getCaptureDetails ( $requestParameters = [] ) * GetCaptureDetails API call - Returns the status of a particular capture and the total amount refunded on the capture.
getOrderReferenceDetails ( $requestParameters = [] ) * GetOrderReferenceDetails API call - Returns details about the Order Reference object and its current state.
getParameters ( ) * Getter for parameters string Gets the value for the parameters string for unit testing
getProviderCreditDetails ( $requestParameters = [] ) * GetProviderCreditDetails API Call - Get the details of the Provider Credit.
getProviderCreditReversalDetails ( $requestParameters = [] ) * GetProviderCreditReversalDetails API Call - Get details of the Provider Credit Reversal.
getRefundDetails ( $requestParameters = [] ) * GetRefundDetails API call - Returns the status of a particular refund.
getServiceStatus ( $requestParameters = [] ) * GetServiceStatus API Call - Returns the operational status of the Off-Amazon Payments API section
getSignature ( $stringToSign, $secretKey ) * Computes RFC 2104-compliant HMAC signature
getUserInfo ( $accessToken ) * GetUserInfo convenience function - Returns user's profile information from Amazon using the access token returned by the Button widget.
refund ( $requestParameters = [] ) * Refund API call - Refunds a previously captured amount.
reverseProviderCredit ( $requestParameters = [] ) * ReverseProviderCredit API Call - Reverse the Provider Credit.
setBillingAgreementDetails ( $requestParameters = [] ) * SetBillingAgreementDetails API call - Sets Billing Agreement details such as a description of the agreement and other information about the seller.
setClientId ( $value ) * Setter for config['client_id'] Sets the value for config['client_id'] variable
setLogger ( Psr\Log\LoggerInterface $logger = null )
setMwsServiceUrl ( $url ) * Setter for $mwsServiceUrl Set the URL to which the post request has to be made for unit testing
setOrderReferenceDetails ( $requestParameters = [] ) * SetOrderReferenceDetails API call - Sets order reference details such as the order total and a description for the order.
setProxy ( $proxy ) * Setter for Proxy input $proxy [array]
setSandbox ( $value ) * Setter for sandbox Sets the Boolean value for config['sandbox'] variable
validateBillingAgreement ( $requestParameters = [] ) * ValidateBillignAgreement API Call - Validates the status of the Billing Agreement object and the payment method associated with it.

Private Methods

Method Description
calculateSignatureAndParametersToString ( $parameters = [] ) * Create an Array of required parameters, sort them Calculate signature and invoke the POST to the MWS Service URL
calculateSignatureAndPost ( $parameters ) * calculateSignatureAndPost - convert the Parameters array to string and curl POST the parameters to MWS
calculateStringToSignV2 ( array $parameters ) * Calculate String to Sign for SignatureVersion 2
checkConfigKeys ( $config ) * Checks if the keys of the input configuration matches the keys in the config array if they match the values are taken else throws exception strict case match is not performed
checkIfBool ( $string ) * checkIfBool - checks if the input is a boolean
checkIfFileExists ( $config ) * checkIfFileExists - check if the JSON file exists in the path provided
constructUserAgentHeader ( ) * Create the User Agent Header sent with the POST request
createServiceUrl ( ) * Create MWS service URL and the Endpoint path
getErrorMessageForJsonError ( $jsonError ) * Convert a json error code to a descriptive error message
getFormattedTimestamp ( ) * Formats date as ISO 8601 timestamp
getParametersAsString ( array $parameters ) * Convert paremeters to Url encoded query string
getRegionUrls ( ) * Get the Region specific properties from the Regions class.
invokePost ( $parameters ) * invokePost takes the parameters and invokes the httpPost function to POST the parameters Exponential retries on error 500 and 503 The response from the POST is an XML which is converted to Array
logMessage ( $message ) * Helper function to log data within the Client
makeChargeCalls ( $chargeType, $setParameters, $confirmParameters, $authorizeParameters ) * makeChargeCalls - makes API calls based off the charge type (OrderReference or BillingAgreement)
pauseOnRetry ( $retries, $status ) * Exponential sleep on failed request
profileEndpointUrl ( ) * Based on the config['region'] and config['sandbox'] values get the user profile URL
quoteApplicationName ( $s ) * Collapse multiple whitespace characters into a single ' ' and backslash escape '\', and '/' characters from a string.
quoteApplicationVersion ( $s ) * Collapse multiple whitespace characters into a single ' ' and backslash escape '\', and '(' characters from a string.
sanitizeRequestData ( $input )
sanitizeResponseData ( $input )
setDefaultValues ( $parameters, $fieldMappings, $requestParameters ) * If merchant_id is not set via the requestParameters array then it's taken from the config array
setParametersAndPost ( $parameters, $fieldMappings, $requestParameters ) * setParametersAndPost - sets the parameters array with non empty values from the requestParameters array sent to API calls.
setProviderCreditDetails ( $parameters, $providerCreditInfo ) * setProviderCreditDetails - sets the provider credit details sent via the Capture or Authorize API calls
setProviderCreditReversalDetails ( $parameters, $providerCreditInfo ) * setProviderCreditReversalDetails - sets the reverse provider credit details sent via the Refund API call.
sign ( $data, $algorithm ) * Computes RFC 2104-compliant HMAC signature
signParameters ( array $parameters ) * Computes RFC 2104-compliant HMAC signature for request parameters Implements AWS Signature, as per following spec:
trimArray ( $array ) * Trim the input Array key values
urlEncode ( $value )

Method Details

__construct() public method

* Takes user configuration array from the user as input Takes JSON file path with configuration information as input Validates the user configuration array against existing config array
public __construct ( $config = null )

__get() public method

* Getter Gets the value for the key if the key exists in config
public __get ( $name )

authorize() public method

* Authorize API call - Reserves a specified amount against the payment method(s) stored in the order reference.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Authorize.html
public authorize ( $requestParameters = [] )

authorizeOnBillingAgreement() public method

* AuthorizeOnBillingAgreement API call - Reserves a specified amount against the payment method(s) stored in the Billing Agreement.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_AuthorizeOnBillingAgreement.html
public authorizeOnBillingAgreement ( $requestParameters = [] )

cancelOrderReference() public method

* CancelOrderReferenceDetails API call - Cancels a previously confirmed order reference.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CancelOrderReference.html
public cancelOrderReference ( $requestParameters = [] )

capture() public method

* Capture API call - Captures funds from an authorized payment instrument.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Capture.html
public capture ( $requestParameters = [] )

charge() public method

* charge convenience method Performs the API calls 1. SetOrderReferenceDetails / SetBillingAgreementDetails 2. ConfirmOrderReference / ConfirmBillingAgreement 3. Authorize (with Capture) / AuthorizeOnBillingAgreeemnt (with Capture)
public charge ( $requestParameters = [] )

closeAuthorization() public method

* CloseAuthorization API call - Closes an authorization.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseOrderReference.html
public closeAuthorization ( $requestParameters = [] )

closeBillingAgreement() public method

* CloseBillingAgreement API Call - Returns details about the Billing Agreement object and its current state.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseBillingAgreement.html
public closeBillingAgreement ( $requestParameters = [] )

closeOrderReference() public method

* CloseOrderReferenceDetails API call - Confirms that an order reference has been fulfilled (fully or partially) and that you do not expect to create any new authorizations on this order reference.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseOrderReference.html
public closeOrderReference ( $requestParameters = [] )

confirmBillingAgreement() public method

* ConfirmBillingAgreement API Call - Confirms that the Billing Agreement is free of constraints and all required information has been set on the Billing Agreement.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmBillingAgreement.html
public confirmBillingAgreement ( $requestParameters = [] )

confirmOrderReference() public method

* ConfirmOrderReferenceDetails API call - Confirms that the order reference is free of constraints and all required information has been set on the order reference.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmOrderReference.html
public confirmOrderReference ( $requestParameters = [] )

createOrderReferenceForId() public method

* CreateOrderReferenceForId API Call - Creates an order reference for the given object
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CreateOrderReferenceForId.html
public createOrderReferenceForId ( $requestParameters = [] )

getAuthorizationDetails() public method

* GetAuthorizationDetails API call - Returns the status of a particular authorization and the total amount captured on the authorization.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetAuthorizationDetails.html
public getAuthorizationDetails ( $requestParameters = [] )

getBillingAgreementDetails() public method

* GetBillingAgreementDetails API Call - Returns details about the Billing Agreement object and its current state.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetBillingAgreementDetails.html
public getBillingAgreementDetails ( $requestParameters = [] )

getCaptureDetails() public method

* GetCaptureDetails API call - Returns the status of a particular capture and the total amount refunded on the capture.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetCaptureDetails.html
public getCaptureDetails ( $requestParameters = [] )

getOrderReferenceDetails() public method

* GetOrderReferenceDetails API call - Returns details about the Order Reference object and its current state.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetOrderReferenceDetails.html
public getOrderReferenceDetails ( $requestParameters = [] )

getParameters() public method

* Getter for parameters string Gets the value for the parameters string for unit testing
public getParameters ( )

getProviderCreditDetails() public method

* GetProviderCreditDetails API Call - Get the details of the Provider Credit.
public getProviderCreditDetails ( $requestParameters = [] )

getProviderCreditReversalDetails() public method

* GetProviderCreditReversalDetails API Call - Get details of the Provider Credit Reversal.
public getProviderCreditReversalDetails ( $requestParameters = [] )

getRefundDetails() public method

* GetRefundDetails API call - Returns the status of a particular refund.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetRefundDetails.html
public getRefundDetails ( $requestParameters = [] )

getServiceStatus() public method

* GetServiceStatus API Call - Returns the operational status of the Off-Amazon Payments API section
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetServiceStatus.html The GetServiceStatus operation returns the operational status of the Off-Amazon Payments API section of Amazon Marketplace Web Service (Amazon MWS). Status values are GREEN, GREEN_I, YELLOW, and RED.
public getServiceStatus ( $requestParameters = [] )

getSignature() public static method

* Computes RFC 2104-compliant HMAC signature
public static getSignature ( $stringToSign, $secretKey )

getUserInfo() public method

* GetUserInfo convenience function - Returns user's profile information from Amazon using the access token returned by the Button widget.
See also: http://login.amazon.com/website Step 4
public getUserInfo ( $accessToken )
$accessToken [String]

refund() public method

* Refund API call - Refunds a previously captured amount.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Refund.html
public refund ( $requestParameters = [] )

reverseProviderCredit() public method

* ReverseProviderCredit API Call - Reverse the Provider Credit.
public reverseProviderCredit ( $requestParameters = [] )

setBillingAgreementDetails() public method

* SetBillingAgreementDetails API call - Sets Billing Agreement details such as a description of the agreement and other information about the seller.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetBillingAgreementDetails.html
public setBillingAgreementDetails ( $requestParameters = [] )

setClientId() public method

* Setter for config['client_id'] Sets the value for config['client_id'] variable
public setClientId ( $value )

setLogger() public method

public setLogger ( Psr\Log\LoggerInterface $logger = null )
$logger Psr\Log\LoggerInterface

setMwsServiceUrl() public method

* Setter for $mwsServiceUrl Set the URL to which the post request has to be made for unit testing
public setMwsServiceUrl ( $url )

setOrderReferenceDetails() public method

* SetOrderReferenceDetails API call - Sets order reference details such as the order total and a description for the order.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetOrderReferenceDetails.html
public setOrderReferenceDetails ( $requestParameters = [] )

setProxy() public method

* Setter for Proxy input $proxy [array]
public setProxy ( $proxy )

setSandbox() public method

* Setter for sandbox Sets the Boolean value for config['sandbox'] variable
public setSandbox ( $value )

validateBillingAgreement() public method

* ValidateBillignAgreement API Call - Validates the status of the Billing Agreement object and the payment method associated with it.
See also: http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ValidateBillingAgreement.html
public validateBillingAgreement ( $requestParameters = [] )

Property Details

$success public_oe property

Boolean variable to check if the API call was a success
public $success