You are here

public static function SquareApi::createFromInstanceId in Commerce Square Connect 7

Create a class instance from a payment method instance.

Parameters

string $instance_id: The payment method instance ID.

Return value

self The Square API wrapper.

4 calls to SquareApi::createFromInstanceId()
commerce_square_capture_form_submit in includes/commerce_square.admin.inc
Submit handler: process the void request.
commerce_square_payment_method_submit_form_validate in ./commerce_square.module
Square payment checkout pane validate callback.
commerce_square_refund_form_submit in includes/commerce_square.admin.inc
Confirm form submit callback to refund an order.
commerce_square_void_form_submit in includes/commerce_square.admin.inc
Submit handler: process the void request.

File

includes/SquareApi.php, line 49
Square Connect SDK wrapper.

Class

SquareApi
A wrapper around the Square Connect SDK.

Code

public static function createFromInstanceId($instance_id) {
  $square_settings = variable_get('commerce_square_settings', commerce_square_default_settings()) + commerce_square_default_settings();
  $payment_method = commerce_payment_method_instance_load($instance_id);
  $mode = $payment_method['settings']['mode'];
  return new self($square_settings[$mode . '_access_token'], $mode);
}