Sunnysideup\Afterpay\Factory\SilverstripeMerchantApi
An API which handles the main steps needed for a website to function with afterpay.
Synopsis
class SilverstripeMerchantApi
{
- // constants
- const CONNECTION_URL_TEST = 'https://api-sandbox.afterpay.com/v1/';
- const CONNECTION_URL_LIVE = 'https://api.afterpay.com/v1/';
- // members
- protected $authorization;
- protected $client;
- protected array $configurationInfo = ;
- protected OrderToken $orderToken;
- protected Payment $paymentInfo;
- protected static SilverstripeMerchantApi $singleton_cache;
- private static integer $merchant_id = 0;
- private static string $secret_key = '';
- private static integer $number_of_payments = 4;
- private static string $merchant_name = '';
- private static string $expectations_folder = 'vendor/sunnysideup/expectations';
- private integer $minPrice = 0;
- private integer $maxPrice = 0;
- private bool $isTest = false;
- private bool $isServerAvailable = false;
- // methods
- public void __construct()
- public static void inst()
- public SilverstripeMerchantApi setIsServerAvailable()
- public void setMinAndMaxPrice()
- public bool getIsServerAvailable()
- public bool canProcessPayment()
- public void getNumberOfPayments()
- public DBCurrency getAmountPerPaymentForCurrentOrder()
- public float getAmountPerPayment()
- public ApiException|OrderToken createOrder()
- public ApiException|Payments createPayment()
- protected void ping_end_point()
- protected void setupAuthorization()
- protected void setupGuzzleClient()
- protected void getUserAgentString()
- protected null|Configuration retrieveConfig()
- protected void retrieveMinAndMaxFromConfig()
- protected void getConnectionURL()
- protected void findExpectationFile()
- protected void localExpecationFileToClass()
Hierarchy
Uses
- SilverStripe\Core\Config\Configurable
- SilverStripe\Core\Extensible
- SilverStripe\Core\Injector\Injectable
Constants
Name | Value |
---|---|
CONNECTION_URL_TEST | 'https://api-sandbox.afterpay.com/v1/' |
CONNECTION_URL_LIVE | 'https://api.afterpay.com/v1/' |
Members
private
- $expectations_folder
—
string
see: afterpay/expectations as an example. - $isServerAvailable — Sunnysideup\Afterpay\Factory\bool
- $isTest — Sunnysideup\Afterpay\Factory\bool
- $maxPrice — float
- $merchant_id
- $merchant_name
- $minPrice — float
- $number_of_payments
- $secret_key
protected
- $client
- $configurationInfo
—
array
Configuration information. - $orderToken
—
CultureKings\Afterpay\Model\Merchant\OrderToken
Order Token. - $paymentInfo
—
CultureKings\Afterpay\Model\Merchant\Payment
Payment information. - $singleton_cache
—
Sunnysideup\Afterpay\Factory\SilverstripeMerchantApi
this.
Methods
protected
- findExpectationFile()
- getConnectionURL()
- getUserAgentString()
- localExpecationFileToClass()
- ping_end_point() — Initialize the authorization field with the set merchant id and secret key.
- retrieveConfig() — Initialize the API with the configuration data from afterpay Currently only the PAY_BY_INSTALLMENT configuration is collected**maybe.
- retrieveMinAndMaxFromConfig()
- setupAuthorization() — Initialize the authorization field with the set merchant id and secret key.
- setupGuzzleClient()
public
- __construct()
- canProcessPayment() — Can the payment be processed (in range of the max and min price).
- createOrder() — Pass an OrderDetails object to this function and collect the OrderToken from afterpay if succesful. This order helps afterpay assess the preapproval https://github.com/culturekings/afterpay/blob/master/docs/merchant/api.md#create-order https://docs.afterpay.com/nz-online-api-v1.html#orders.
- createPayment() — Capture the payment after the order has been placed.
- getAmountPerPayment() — Get the payment installations for afterpay (return 0 if price is out of range).
- getAmountPerPaymentForCurrentOrder()
- getIsServerAvailable() — Getter for is server available.
- getNumberOfPayments()
- inst() — Singleton instance pattern.
- setIsServerAvailable() — Setter for is server available If no server exists then collect fake responses from a cache.
- setMinAndMaxPrice() — set the minimum and maximum price to use Afterpay This can overrule settings from Afterpay server and therefore make it faster ...