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
- Omnipay\Fatzebra\Message\AbstractRestRequest
- Omnipay\Fatzebra\Message\CreateSubscriptionRequest
Namespace: Omnipay\Fatzebra\Message
See:
Link: http://www.paystream.com.au/developer-guides/
Located at Message/CreateSubscriptionRequest.php
See:
Omnipay\Fatzebra\FatzebraGateway
Link: http://www.paystream.com.au/developer-guides/
Located at Message/CreateSubscriptionRequest.php
public
mixed
|
|
protected
string
|
|
public
string
|
|
public
|
|
public
string
|
|
public
|
|
public
string
|
|
public
|
|
public
|
|
public
|
getHttpMethod(),
getUsername(),
sendData(),
setUsername()
|
API_VERSION
|
$liveEndpoint,
$testEndpoint
|
$httpClient,
$httpRequest,
$negativeAmountAllowed,
$parameters,
$response,
$zeroAmountAllowed
|