Open Journal Systems
3.3.0
|
Protected Member Functions | |
getEndpoint () | |
getEndpoint () | |
![]() | |
createResponse ($data, $statusCode) | |
createResponse ($data, $statusCode) | |
getHttpMethod () | |
getHttpMethod () | |
![]() | |
getCurrencies () | |
getParameter ($key) | |
setParameter ($key, $value) | |
setParameter ($key, $value) | |
Additional Inherited Members | |
![]() | |
const | API_VERSION = 'v1' |
![]() | |
$liveEndpoint = 'https://api.paypal.com' | |
$payerId = null | |
$testEndpoint = 'https://api.sandbox.paypal.com' | |
![]() | |
$currencies | |
$httpClient | |
$httpRequest | |
$negativeAmountAllowed = false | |
$parameters | |
$response | |
$zeroAmountAllowed = true | |
PayPal REST Create Plan Request
PayPal offers merchants a /billing-plans resource for providing billing plans to users for recurring payments.
After the billing plan is created, the /billing-agreements resource provides billing agreements so that users can agree to be billed for the plans.
You can create an empty billing plan and add a trial period and/or regular billing. Alternatively, you can create a fully loaded plan that includes both a trial period and regular billing. Note: By default, a created billing plan is in a CREATED state. A user cannot subscribe to the billing plan unless it has been set to the ACTIVE state.
In order to create a new billing plan you must submit the following details:
// Create a gateway for the PayPal REST Gateway // (routes to GatewayFactory::create) $gateway = Omnipay::create('PayPal_Rest');
// Initialise the gateway $gateway->initialize(array( 'clientId' => 'MyPayPalClientId', 'secret' => 'MyPayPalSecret', 'testMode' => true, // Or false when you are ready for live transactions ));
// Do a create plan transaction on the gateway $transaction = $gateway->createPlan(array( 'name' => 'Test Plan', 'description' => 'A plan created for testing', 'type' => $gateway::BILLING_PLAN_TYPE_FIXED, 'paymentDefinitions' => [ [ 'name' => 'Monthly Payments for 12 months', 'type' => $gateway::PAYMENT_TRIAL, 'frequency' => $gateway::BILLING_PLAN_FREQUENCY_MONTH, 'frequency_interval' => 1, 'cycles' => 12, 'amount' => ['value' => 10.00, 'currency' => 'USD'], ], ], )); $response = $transaction->send(); if ($response->isSuccessful()) { echo "Create Plan transaction was successful!\n"; $plan_id = $response->getTransactionReference(); echo "Plan reference = " . $plan_id . "\n"; }
This is from the PayPal web site:
curl -v POST https://api.sandbox.paypal.com/v1/payments/billing-plans \ -H 'Content-Type:application/json' \ -H 'Authorization: Bearer <Access-Token>' \ -d '{ "name": "T-Shirt of the Month Club Plan", "description": "Template creation.", "type": "fixed", "payment_definitions": [ { "name": "Regular Payments", "type": "REGULAR", "frequency": "MONTH", "frequency_interval": "2", "amount": { "value": "100", "currency": "USD" }, "cycles": "12", "charge_models": [ { "type": "SHIPPING", "amount": { "value": "10", "currency": "USD" } }, { "type": "TAX", "amount": { "value": "12", "currency": "USD" } } ] } ], "merchant_preferences": { "setup_fee": { "value": "1", "currency": "USD" }, "return_url": "http://www.return.com", "cancel_url": "http://www.cancel.com", "auto_bill_amount": "YES", "initial_fail_amount_action": "CONTINUE", "max_fail_attempts": "0" } }'
This is from the PayPal web site:
{ "id": "P-94458432VR012762KRWBZEUA", "state": "CREATED", "name": "T-Shirt of the Month Club Plan", "description": "Template creation.", "type": "FIXED", "payment_definitions": [ { "id": "PD-50606817NF8063316RWBZEUA", "name": "Regular Payments", "type": "REGULAR", "frequency": "Month", "amount": { "currency": "USD", "value": "100" }, "charge_models": [ { "id": "CHM-55M5618301871492MRWBZEUA", "type": "SHIPPING", "amount": { "currency": "USD", "value": "10" } }, { "id": "CHM-92S85978TN737850VRWBZEUA", "type": "TAX", "amount": { "currency": "USD", "value": "12" } } ], "cycles": "12", "frequency_interval": "2" } ], "merchant_preferences": { "setup_fee": { "currency": "USD", "value": "1" }, "max_fail_attempts": "0", "return_url": "http://www.return.com", "cancel_url": "http://www.cancel.com", "auto_bill_amount": "YES", "initial_fail_amount_action": "CONTINUE" }, "create_time": "2014-07-31T17:41:55.920Z", "update_time": "2014-07-31T17:41:55.920Z", "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/billing-plans/P-94458432VR012762KRWBZEUA", "rel": "self", "method": "GET" } ] }
Omnipay PayPal REST Create Plan Request PayPal offers merchants a /billing-plans resource for providing billing plans to users for recurring payments. After the billing plan is created, the /billing-agreements resource provides billing agreements so that users can agree to be billed for the plans. You can create an empty billing plan and add a trial period and/or regular billing. Alternatively, you can create a fully loaded plan that includes both a trial period and regular billing. Note: By default, a created billing plan is in a CREATED state. A user cannot subscribe to the billing plan unless it has been set to the ACTIVE state. autotoc_md81 Request Data In order to create a new billing plan you must submit the following details: name (string). Required.description (string). Required.type (string). Allowed values: FIXED, INFINITE. Required.payment_definitions (array)merchant_preferences (object) autotoc_md82 Example // Create a gateway for the PayPal REST Gateway // (routes to GatewayFactory::create) $gateway = Omnipay::create('PayPal_Rest'); // Initialise the gateway $gateway->initialize(array( 'clientId' => 'MyPayPalClientId', 'secret' => 'MyPayPalSecret', 'testMode' => true, // Or false when you are ready for live transactions )); // Do a create plan transaction on the gateway $transaction = $gateway->createPlan(array( 'name' => 'Test Plan', 'description' => 'A plan created for testing', 'type' => $gateway::BILLING_PLAN_TYPE_FIXED, 'paymentDefinitions' => [ [ 'name' => 'Monthly Payments for 12 months', 'type' => $gateway::PAYMENT_TRIAL, 'frequency' => $gateway::BILLING_PLAN_FREQUENCY_MONTH, 'frequency_interval' => 1, 'cycles' => 12, 'amount' => ['value' => 10.00, 'currency' => 'USD'], ], ], )); $response = $transaction->send(); if ($response->isSuccessful()) { echo "Create Plan transaction was successful!\n"; $plan_id = $response->getTransactionReference(); echo "Plan reference = " . $plan_id . "\n"; }
autotoc_md83 Request Sample This is from the PayPal web site: curl -v POST https://api.sandbox.paypal.com/v1/payments/billing-plans \ -H 'Content-Type:application/json' \ -H 'Authorization: Bearer <Access-Token>' \ -d '{ "name": "T-Shirt of the Month Club Plan", "description": "Template creation.", "type": "fixed", "payment_definitions": [ { "name": "Regular Payments", "type": "REGULAR", "frequency": "MONTH", "frequency_interval": "2", "amount": { "value": "100", "currency": "USD" }, "cycles": "12", "charge_models": [ { "type": "SHIPPING", "amount": { "value": "10", "currency": "USD" } }, { "type": "TAX", "amount": { "value": "12", "currency": "USD" } } ] } ], "merchant_preferences": { "setup_fee": { "value": "1", "currency": "USD" }, "return_url": "http://www.return.com", "cancel_url": "http://www.cancel.com", "auto_bill_amount": "YES", "initial_fail_amount_action": "CONTINUE", "max_fail_attempts": "0" } }'
autotoc_md84 Response Sample This is from the PayPal web site: { "id": "P-94458432VR012762KRWBZEUA", "state": "CREATED", "name": "T-Shirt of the Month Club Plan", "description": "Template creation.", "type": "FIXED", "payment_definitions": [ { "id": "PD-50606817NF8063316RWBZEUA", "name": "Regular Payments", "type": "REGULAR", "frequency": "Month", "amount": { "currency": "USD", "value": "100" }, "charge_models": [ { "id": "CHM-55M5618301871492MRWBZEUA", "type": "SHIPPING", "amount": { "currency": "USD", "value": "10" } }, { "id": "CHM-92S85978TN737850VRWBZEUA", "type": "TAX", "amount": { "currency": "USD", "value": "12" } } ], "cycles": "12", "frequency_interval": "2" } ], "merchant_preferences": { "setup_fee": { "currency": "USD", "value": "1" }, "max_fail_attempts": "0", "return_url": "http://www.return.com", "cancel_url": "http://www.cancel.com", "auto_bill_amount": "YES", "initial_fail_amount_action": "CONTINUE" }, "create_time": "2014-07-31T17:41:55.920Z", "update_time": "2014-07-31T17:41:55.920Z", "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/billing-plans/P-94458432VR012762KRWBZEUA", "rel": "self", "method": "GET" } ] }
https://developer.paypal.com/docs/api/#create-a-plan Omnipay
Definition at line 195 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
Omnipay\PayPal\Message\RestCreatePlanRequest::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.
Implements Omnipay\Common\Message\MessageInterface.
Definition at line 298 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\getDescription(), Omnipay\PayPal\Message\RestCreatePlanRequest\getMerchantPreferences(), Omnipay\PayPal\Message\RestCreatePlanRequest\getName(), Omnipay\PayPal\Message\RestCreatePlanRequest\getPaymentDefinitions(), Omnipay\PayPal\Message\RestCreatePlanRequest\getType(), and Omnipay\Common\Message\AbstractRequest\validate().
Omnipay\PayPal\Message\RestCreatePlanRequest::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.
Implements Omnipay\Common\Message\MessageInterface.
Definition at line 298 of file vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\getDescription(), Omnipay\PayPal\Message\RestCreatePlanRequest\getMerchantPreferences(), Omnipay\PayPal\Message\RestCreatePlanRequest\getName(), Omnipay\PayPal\Message\RestCreatePlanRequest\getPaymentDefinitions(), Omnipay\PayPal\Message\RestCreatePlanRequest\getType(), and Omnipay\Common\Message\AbstractRequest\validate().
|
protected |
Get transaction endpoint.
Billing plans are created using the /billing-plans resource.
Reimplemented from Omnipay\PayPal\Message\AbstractRestRequest.
Definition at line 319 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
|
protected |
Get transaction endpoint.
Billing plans are created using the /billing-plans resource.
Reimplemented from Omnipay\PayPal\Message\AbstractRestRequest.
Definition at line 319 of file vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
Omnipay\PayPal\Message\RestCreatePlanRequest::getMerchantPreferences | ( | ) |
Get the plan merchant preferences
See the class documentation and the PayPal REST API documentation for a description of the array elements.
Definition at line 278 of file vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\getParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::getMerchantPreferences | ( | ) |
Get the plan merchant preferences
See the class documentation and the PayPal REST API documentation for a description of the array elements.
Definition at line 278 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\getParameter().
Referenced by Omnipay\PayPal\Message\RestCreatePlanRequest\getData().
Omnipay\PayPal\Message\RestCreatePlanRequest::getName | ( | ) |
Get the plan name
Definition at line 202 of file vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\getParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::getName | ( | ) |
Get the plan name
Definition at line 202 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\getParameter().
Referenced by Omnipay\PayPal\Message\RestCreatePlanRequest\getData().
Omnipay\PayPal\Message\RestCreatePlanRequest::getPaymentDefinitions | ( | ) |
Get the plan payment definitions
See the class documentation and the PayPal REST API documentation for a description of the array elements.
Definition at line 249 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\getParameter().
Referenced by Omnipay\PayPal\Message\RestCreatePlanRequest\getData().
Omnipay\PayPal\Message\RestCreatePlanRequest::getPaymentDefinitions | ( | ) |
Get the plan payment definitions
See the class documentation and the PayPal REST API documentation for a description of the array elements.
Definition at line 249 of file vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\getParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::getType | ( | ) |
Get the plan type
Definition at line 223 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\getParameter().
Referenced by Omnipay\PayPal\Message\RestCreatePlanRequest\getData().
Omnipay\PayPal\Message\RestCreatePlanRequest::getType | ( | ) |
Get the plan type
Definition at line 223 of file vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\getParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::setMerchantPreferences | ( | array | $value | ) |
Set the plan merchant preferences
See the class documentation and the PayPal REST API documentation for a description of the array elements.
array | $value |
Definition at line 293 of file vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\setParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::setMerchantPreferences | ( | array | $value | ) |
Set the plan merchant preferences
See the class documentation and the PayPal REST API documentation for a description of the array elements.
array | $value |
Definition at line 293 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\setParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::setName | ( | $value | ) |
Set the plan name
string | $value |
Definition at line 213 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\setParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::setName | ( | $value | ) |
Set the plan name
string | $value |
Definition at line 213 of file vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\setParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::setPaymentDefinitions | ( | array | $value | ) |
Set the plan payment definitions
See the class documentation and the PayPal REST API documentation for a description of the array elements.
array | $value |
Definition at line 264 of file vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\setParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::setPaymentDefinitions | ( | array | $value | ) |
Set the plan payment definitions
See the class documentation and the PayPal REST API documentation for a description of the array elements.
array | $value |
Definition at line 264 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\setParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::setType | ( | $value | ) |
Set the plan type
string | $value | either RestGateway::BILLING_PLAN_TYPE_FIXED or RestGateway::BILLING_PLAN_TYPE_INFINITE |
Definition at line 235 of file lib/vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\setParameter().
Omnipay\PayPal\Message\RestCreatePlanRequest::setType | ( | $value | ) |
Set the plan type
string | $value | either RestGateway::BILLING_PLAN_TYPE_FIXED or RestGateway::BILLING_PLAN_TYPE_INFINITE |
Definition at line 235 of file vendor/omnipay/paypal/src/Message/RestCreatePlanRequest.php.
References Omnipay\Common\Message\AbstractRequest\setParameter().