Skip to content

Commit 83bda03

Browse files
Updated: VaaPayPal Readme
1 parent eaaeca3 commit 83bda03

File tree

1 file changed

+53
-20
lines changed

1 file changed

+53
-20
lines changed

Libraries/VaahPayPal.md

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ composer require paypal/rest-api-sdk-php
1515
```
1616
### Add env variables:
1717

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.
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.
1919
```env
2020
## For PayPal Sandbox
2121
PAYPAL_MODE=sandbox
@@ -26,28 +26,51 @@ PAYPAL_MODE=live
2626
PAYPAL_LIVE_CLIENT_ID=xxxxxxxxxxxxxxx
2727
PAYPAL_LIVE_CLIENT_SECRET=xxxxxxxxxxxxx
2828
```
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.
29+
To obtain your PayPal sandbox client ID and client secret, you will need to complete the following steps:
3030

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.
32-
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.
31+
1. Visit the [PayPal Developer](https://developer.paypal.com/home) website and sign in to your account.
32+
2. Click on the `Sandbox > Accounts` option in the top menu.
33+
3. In the `Business` section, click on the `Create` button to create a
34+
new sandbox business account.
35+
4. Enter the required information to create your account and click
36+
`Create Account`.
37+
5. Once your account has been created, click on the `Profile` link next
38+
to the account.
39+
6. On the next page, you will see your `sandbox client ID` and
40+
`client secret`. Make sure to save these values, as you will need them to
41+
authenticate your app with PayPal in the sandbox environment.
3442

3543
### Initialize VaahPaypal
3644
```php
3745
//Initialize the VaahPaypal
3846
$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]
47+
$client_id,
48+
$client_secret,
49+
$return_url,
50+
$cancel_url,
51+
$mode
4452
);
4553
```
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.
54+
| Name | Description | Required | Default |
55+
|--|--|--|--|
56+
| client_id | PayPal Live/Sandbox client id| Yes
57+
| client_secret| PayPal Live/Sandbox client_secret| Yes
58+
| return_ url| redirect the user to after they have completed a payment.| No | /api/vaah/paypal/execute
59+
| cancel_url | redirect the user to after they have canceled a payment. | No| /api/vaah/paypal/cancel|
60+
| mode | environments for managing payments | No | sandbox
4761

4862
### Methods
4963
- Paypal Create Order
5064

65+
|Name| Required | Type |
66+
|--|--|--|
67+
| name | yes | String |
68+
| quantity| yes | String
69+
| amount| yes | String
70+
| description| yes | String
71+
| currency | yes | String |
72+
|shipping | No | Integer
73+
|tax| No | Integer
5174
```php
5275
$vaahPaypal->pay([
5376
'name' => 'Name',
@@ -56,35 +79,45 @@ $vaahPaypal->pay([
5679
'description' => 'Description',
5780
'quantity' => 1,
5881
]);
82+
```
5983

60-
//success response
84+
**Success response**
85+
```php
6186
[
6287
'status' => 'success';
6388
'approval_url' = 'approval url';
6489
'payment_id' = 'xxxxx';
6590
'token' = 'EC-xxxxxxxx';
6691
];
67-
68-
//error response
69-
[
92+
```
93+
**Error Response**
94+
```php
95+
[
7096
'status' => 'error';
7197
'errors' = 'errors';
7298
];
73-
```
99+
```
100+
- Execute Order
74101

75-
- Execute Order
102+
|Name| Required
103+
|--|--|
104+
| payment_id | yes |
105+
| payer_id | yes |
76106
```php
77-
//Execute the order
78107
$payment_id = 'xxxx';
79108
$payer_id = 'xxxx';
80109
$vaahPaypal->executePayment($payment_id, $payer_id);
110+
```
81111

82-
//success response
112+
**Success response**
113+
```php
83114
[
84115
'status' => 'success';
85116
'data' => 'data'; //array
86117
];
87-
//error response
118+
```
119+
**Error response**
120+
```php
88121
[
89122
'status' => 'error';
90123
'errors' = 'errors';

0 commit comments

Comments
 (0)