laravel-paypal
laravel-paypal copied to clipboard
Issue on simple creating a basic plan
Hi Can anyone please help me why I can't simply create a basic plan?
I followed the docs from https://srmklive.github.io/laravel-paypal/docs.html#item-5-2
$provider = \PayPal::setProvider();
$provider->getAccessToken();
$data = json_decode('{
"product_id": "PROD-XXCD1234QWER65782",
"name": "Video Streaming Service Plan",
"description": "Video Streaming Service basic plan",
"status": "ACTIVE",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "TRIAL",
"sequence": 1,
"total_cycles": 2,
"pricing_scheme": {
"fixed_price": {
"value": "3",
"currency_code": "USD"
}
}
},
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "TRIAL",
"sequence": 2,
"total_cycles": 3,
"pricing_scheme": {
"fixed_price": {
"value": "6",
"currency_code": "USD"
}
}
},
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 3,
"total_cycles": 12,
"pricing_scheme": {
"fixed_price": {
"value": "10",
"currency_code": "USD"
}
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "10",
"currency_code": "USD"
},
"setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 3
},
"taxes": {
"percentage": "10",
"inclusive": false
}
}', true);
$plan = $provider->createPlan($data);
Error: Too few arguments to function Srmklive\PayPal\Services\PayPal::createPlan(), 1 passed
public function createPlan(array $data, string $request_id)
{
$this->apiEndPoint = 'v1/billing/plans';
$this->options['headers']['PayPal-Request-Id'] = $request_id;
$this->options['json'] = $data;
$this->verb = 'post';
return $this->doPayPalRequest();
}
I am not sure where to get the $request_id on PayPal-Request-Id?
And if I a put another args on it:
$plan = $provider->createPlan($data, 'PLAN-18062019-001);
Then I get another error:
array:1 [▼
"error" => array:5 [▼
"name" => "RESOURCE_NOT_FOUND"
"message" => "The specified resource does not exist."
"debug_id" => "1054d60e72928"
"details" => array:1 [▼
0 => array:2 [▼
"issue" => "INVALID_RESOURCE_ID"
"description" => "Invalid product id"
]
]
"links" => array:1 [▼
0 => array:3 [▼
"href" => "https://developer.paypal.com/docs/api/v1/billing/subscriptions#RESOURCE_NOT_FOUND"
"rel" => "information_link"
"method" => "GET"
]
]
]
]
I appreciate anyone who can help and guide me.
Thank you!