Skip to content

Commit eaaeca3

Browse files
Updated: VaahPaypal usage file
1 parent f2e5911 commit eaaeca3

File tree

1 file changed

+53
-37
lines changed

1 file changed

+53
-37
lines changed

Libraries/VaahPayPal.md

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# VaahPaypal
1+
# VaahPayPal
22
> Small Laravel Helpers
33
44
### Installation
@@ -13,65 +13,81 @@ VaahPaypal provides to you a simple way to integrate Paypal in your Laravel appl
1313
```shell script
1414
composer require paypal/rest-api-sdk-php
1515
```
16+
### Add env variables:
1617

17-
[comment]: <> (Add Facade in `config/app.php`:)
18-
19-
[comment]: <> (```php)
20-
21-
[comment]: <> ('aliases' => [)
22-
23-
[comment]: <> (...)
24-
25-
[comment]: <> ('VaahStripe' => WebReinvent\VaahExtend\Facades\VaahStripe::class,)
26-
27-
[comment]: <> (...)
28-
29-
[comment]: <> (])
30-
31-
[comment]: <> (```)
32-
33-
Add env configuration:
18+
PayPal live and PayPal sandbox are two different environments for using the PayPal API. The live environment is the real PayPal network that processes actual payments, while the sandbox environment is a simulated test environment that allows developers to test their integration with the PayPal API without using real money.
3419
```env
20+
## For PayPal Sandbox
3521
PAYPAL_MODE=sandbox
3622
PAYPAL_SANDBOX_CLIENT_ID=xxxxxxxxxxxxxxx
3723
PAYPAL_SANDBOX_CLIENT_SECRET=xxxxxxxxxxxxx
24+
## For PayPal Live
25+
PAYPAL_MODE=live
26+
PAYPAL_LIVE_CLIENT_ID=xxxxxxxxxxxxxxx
27+
PAYPAL_LIVE_CLIENT_SECRET=xxxxxxxxxxxxx
3828
```
29+
To get your PayPal sandbox client secret and client ID, you first need to create a PayPal developer account at https://developer.paypal.com/. Once you have created your account, you can log in and create a sandbox account. This will allow you to test your integration with the PayPal API without using real money.
3930

40-
Reference url: https://developer.paypal.com/api/rest/
31+
To create a sandbox account, log in to your developer account and click on the "Dashboard" tab. From there, click on the "Sandbox" tab and then click on the "Accounts" link. This will take you to the sandbox accounts page where you can create a new sandbox account.
4132

42-
### Methods
33+
Once you have created a sandbox account, you can view its client ID and client secret by clicking on the account and then clicking on the "Profile" link. This will open the account's profile page, where you can find the client ID and client secret.
4334

35+
### Initialize VaahPaypal
36+
```php
37+
//Initialize the VaahPaypal
38+
$vaahPaypal = new VaahPayPal(
39+
$client_id, //required
40+
$client_secret, //required
41+
$return_url, //optional [default: /api/vaah/paypal/execute]
42+
$cancel_url, //optional [default: /api/vaah/paypal/cancel]
43+
$mode //optional [default: sandbox]
44+
);
45+
```
46+
The PayPal cancel and return URLs are the URLs that PayPal will redirect the user to after they have completed or canceled a payment. These URLs are specified by the developer in the PayPal API call, and they can be used to redirect the user back to the app or website after the payment is complete.
47+
48+
### Methods
4449
- Paypal Create Order
4550

4651
```php
47-
//Initialize the VaahPaypal
48-
$vaahPaypal = new VaahPayPal(
49-
$client_id,
50-
$client_secret,
51-
$return_url,
52-
$cancel_url,
53-
);
54-
//Create Order
5552
$vaahPaypal->pay([
5653
'name' => 'Name',
5754
'amount' => 100,
58-
'currency' => USD,
55+
'currency' => 'USD',
5956
'description' => 'Description',
6057
'quantity' => 1,
6158
]);
59+
60+
//success response
61+
[
62+
'status' => 'success';
63+
'approval_url' = 'approval url';
64+
'payment_id' = 'xxxxx';
65+
'token' = 'EC-xxxxxxxx';
66+
];
67+
68+
//error response
69+
[
70+
'status' => 'error';
71+
'errors' = 'errors';
72+
];
6273
```
6374

6475
- Execute Order
6576
```php
66-
//Initialize the VaahPaypal
67-
$vaahPaypal = new VaahPayPal(
68-
$client_id,
69-
$client_secret,
70-
$return_url,
71-
$cancel_url,
72-
);
73-
//Execute the order
77+
//Execute the order
7478
$payment_id = 'xxxx';
7579
$payer_id = 'xxxx';
7680
$vaahPaypal->executePayment($payment_id, $payer_id);
81+
82+
//success response
83+
[
84+
'status' => 'success';
85+
'data' => 'data'; //array
86+
];
87+
//error response
88+
[
89+
'status' => 'error';
90+
'errors' = 'errors';
91+
];
7792
```
93+
Reference url: https://developer.paypal.com/api/rest/

0 commit comments

Comments
 (0)