Overview

Namespaces

  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
    • Tests
      • Batch
      • Cache
      • Common
        • Cache
        • Exception
      • Http
        • Curl
        • Exception
        • Message
          • Header
      • Inflection
      • Iterator
      • Log
      • Message
      • Mock
      • Parser
        • Cookie
        • Message
      • Parsers
        • UriTemplate
      • Plugin
        • Async
        • Backoff
        • Cache
        • Cookie
          • CookieJar
        • CurlAuth
        • ErrorResponse
        • History
        • Log
        • Md5
        • Mock
        • Oauth
        • Redirect
      • Service
        • Builder
        • Command
          • LocationVisitor
            • Request
            • Response
        • Description
        • Exception
        • Mock
          • Command
            • Sub
          • Model
        • Resource
      • Stream
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • Fatzebra
      • Message
  • PHP

Classes

  • AbstractRestRequest
  • CreateCardRequest
  • CreateCustomerRequest
  • CreatePlanRequest
  • CreateSubscriptionRequest
  • DeleteCustomerRequest
  • FetchAllPlansRequest
  • FetchCustomerRequest
  • FetchPlanRequest
  • FetchSubscriptionRequest
  • FetchTransactionRequest
  • PurchaseRequest
  • RefundRequest
  • RestResponse
  • Overview
  • Namespace
  • Class
  • Tree

Class CreateSubscriptionRequest

Fat Zebra REST Create Subscription Request

To create a new subscription the following details are required:

  • customer ID (getCustomerReference from a CreateCustomerRequest response)
  • plan ID (getTransactionReference from a CreatePlanRequest response)
  • frequency
  • start_date
  • reference

Example:

// Create a gateway for the Fat Zebra REST Gateway
  // (routes to GatewayFactory::create)
  $gateway = Omnipay::create('FatzebraGateway');

  // Initialise the gateway
  $gateway->initialize(array(
      'username' => 'TEST',
      'token'    => 'TEST',
      'testMode' => true, // Or false when you are ready for live transactions
  ));

  // Create a credit card object
  // This card can be used for testing.
  $card = new CreditCard(array(
              'firstName'    => 'Example',
              'lastName'     => 'Customer',
              'number'       => '4005550000000001',
              'expiryMonth'  => '01',
              'expiryYear'   => '2020',
              'cvv'          => '123',
              'billingAddress1'       => '1 Scrubby Creek Road',
              'billingCountry'        => 'AU',
              'billingCity'           => 'Scrubby Creek',
              'billingPostcode'       => '4999',
              'billingState'          => 'QLD',
              'email'                 => 'email@example.com',
  ));

  // Do a create customer transaction on the gateway
  $transaction = $gateway->createCustomer(array(
      'transactionReference'     => 'TestCustomer',
      'clientIp'                 => $_SERVER['REMOTE_ADDR'],
      'card'                     => $card,
  ));
  $response = $transaction->send();
  $customer_id = $response->getCustomerReference();

  // Do a create plan transaction on the gateway
  $transaction = $gateway->CreatePlan(array(
      'name'                     => 'Test Plan',
      'transactionReference'     => 'TestPlan',
      'description'              => 'A plan created for testing',
      'amount'                   => '10.00',
  ));
  $response = $transaction->send();
  $plan_id = $response->getTransactionReference();

  // Do a create subscription transaction on the gateway
  $transaction = $gateway->createSubscription(array(
      'customerReference'            => $customer_id,
      'planReference'                => $plan_id,
      'frequency'                => $gateway::FREQUENCY_WEEKLY,
      'startDate'                => new \DateTime('tomorrow'),
      'transactionReference'     => 'TestSubscription',
  ));
  $response = $transaction->send();
  if ($response->isSuccessful()) {
      echo "createSubscription transaction was successful!\n";
      $subscription_id = $response->getSubscriptionReference();
      echo "Subscription Reference = " . $subscription_id . "\n";
  }
Omnipay\Common\Message\AbstractRequest implements Omnipay\Common\Message\RequestInterface
Extended by Omnipay\Fatzebra\Message\AbstractRestRequest
Extended by Omnipay\Fatzebra\Message\CreateSubscriptionRequest
Namespace: Omnipay\Fatzebra\Message
See: Omnipay\Fatzebra\FatzebraGateway
Link: http://www.paystream.com.au/developer-guides/
Located at Message/CreateSubscriptionRequest.php
Methods summary
public mixed
# getData( )

Get the raw data array for this message. The format of this varies from gateway to gateway, but will usually be either an associative array, or a SimpleXMLElement.

Get the raw data array for this message. The format of this varies from gateway to gateway, but will usually be either an associative array, or a SimpleXMLElement.

Returns

mixed
protected string
# getEndpoint( )

Get transaction endpoint.

Get transaction endpoint.

Referenceizes are created using the /purchases resource.

Returns

string

Overrides

Omnipay\Fatzebra\Message\AbstractRestRequest::getEndpoint()
public string
# getCustomerReference( )

Get the customer token

Get the customer token

Returns

string
public Omnipay\Fatzebra\Message\CreateSubscriptionRequest
# setCustomerReference( $value )

Set the customer token

Set the customer token

Returns

Omnipay\Fatzebra\Message\CreateSubscriptionRequest
provides a fluent interface.
public string
# getPlanReference( )

Get the plan token

Get the plan token

Returns

string
public Omnipay\Fatzebra\Message\CreateSubscriptionRequest
# setPlanReference( $value )

Set the plan token

Set the plan token

Returns

Omnipay\Fatzebra\Message\CreateSubscriptionRequest
provides a fluent interface.
public string
# getFrequency( )

Get the frequency

Get the frequency

Returns

string
public Omnipay\Fatzebra\Message\CreateSubscriptionRequest
# setFrequency( $value )

Set the frequency

Set the frequency

Returns

Omnipay\Fatzebra\Message\CreateSubscriptionRequest
provides a fluent interface.
public DateTime
# getStartDate( )

Get the start date

Get the start date

Returns

DateTime
public Omnipay\Fatzebra\Message\CreateSubscriptionRequest
# setStartDate( $value )

Set the start date

Set the start date

Returns

Omnipay\Fatzebra\Message\CreateSubscriptionRequest
provides a fluent interface.
Methods inherited from Omnipay\Fatzebra\Message\AbstractRestRequest
getHttpMethod(), getUsername(), sendData(), setUsername()
Methods inherited from Omnipay\Common\Message\AbstractRequest
__construct(), formatCurrency(), getAmount(), getAmountInteger(), getCancelUrl(), getCard(), getCardReference(), getClientIp(), getCurrency(), getCurrencyDecimalPlaces(), getCurrencyNumeric(), getDescription(), getIssuer(), getItems(), getNotifyUrl(), getParameter(), getParameters(), getPaymentMethod(), getResponse(), getReturnUrl(), getTestMode(), getToken(), getTransactionId(), getTransactionReference(), initialize(), send(), setAmount(), setCancelUrl(), setCard(), setCardReference(), setClientIp(), setCurrency(), setDescription(), setIssuer(), setItems(), setNotifyUrl(), setParameter(), setPaymentMethod(), setReturnUrl(), setTestMode(), setToken(), setTransactionId(), setTransactionReference(), toFloat(), validate()
Constants inherited from Omnipay\Fatzebra\Message\AbstractRestRequest
API_VERSION
Properties inherited from Omnipay\Fatzebra\Message\AbstractRestRequest
$liveEndpoint, $testEndpoint
Properties inherited from Omnipay\Common\Message\AbstractRequest
$httpClient, $httpRequest, $negativeAmountAllowed, $parameters, $response, $zeroAmountAllowed
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen