Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5207c2d
Updated: stripe payment
we-vikram-wri231 Jul 18, 2022
27f7a5c
Updated: stripe subscription readme
we-vikram-wri231 Jul 18, 2022
3a733b1
Updated: product and price read
we-vikram-wri231 Jul 18, 2022
0620762
Added: vaahpaypal class file
we-vikram-wri231 Nov 28, 2022
c5b23e7
Updated: Paypal methods
we-himanshu-r001-v1 Dec 2, 2022
51e6a7c
Fixed : Wrong vars
we-himanshu-r001-v1 Dec 2, 2022
818fe28
Updated: Code refactor
we-himanshu-r001-v1 Dec 2, 2022
435246d
Updated: VaahPaypal generic
we-himanshu-r001-v1 Dec 2, 2022
8efbd01
Updated : ApiContext var removed
we-himanshu-r001-v1 Dec 3, 2022
ba3cba5
Added: VaahPayPal.md
we-himanshu-r001-v1 Dec 3, 2022
f2e5911
Updated: VaahPayPal.md
we-himanshu-r001-v1 Dec 3, 2022
eaaeca3
Updated: VaahPaypal usage file
we-himanshu-r001-v1 Dec 5, 2022
83bda03
Updated: VaaPayPal Readme
we-himanshu-r001-v1 Dec 5, 2022
31cf4d4
Updated: VaahPayPal Readme
we-himanshu-r001-v1 Dec 5, 2022
4afc5cc
Updated: VaahPayPal Readme
we-himanshu-r001-v1 Dec 5, 2022
d5fa73e
Merge pull request #6 from webreinvent/1.x-feature/add-vaahpaypal
themodernpk Dec 5, 2022
b707d5f
Merge branch 'feature/update-readme' into develop
themodernpk Jan 10, 2023
0b6213c
Merge branch 'develop' into 1.x-develop
themodernpk Jan 10, 2023
d2be6e9
Merge branch '1.x-develop' into 1.x
themodernpk Jan 10, 2023
92535b1
fixed: imap issue
themodernpk Jul 4, 2023
46ae805
updated: library
themodernpk Jul 5, 2023
282a9bc
updated: version
themodernpk Jul 5, 2023
19e72c0
updated: version
themodernpk Jul 5, 2023
65657c1
added: mark as read and unread
themodernpk Jul 11, 2023
2decef7
fixed: issue
themodernpk Jul 11, 2023
8ce57b6
fixed: syncing method
themodernpk Jul 12, 2023
0a58f9a
added: VaahApollo
themodernpk Jul 26, 2023
6fb1e6a
Merge branch 'HEAD' into 1.x
themodernpk Jul 26, 2023
b72ca12
added: apollo method
themodernpk Aug 23, 2023
ec80319
Merge branch 'HEAD' into 1.x
themodernpk Aug 23, 2023
c89a795
Merge branch '1.x' into 1.x-develop
themodernpk Aug 24, 2023
a30ece0
Updated: getPeople method
we-vineet-k001 Sep 26, 2023
5d86b48
Merge pull request #9 from webreinvent/1.x-feature/update-vaa-apollo-…
we-vikram-wri231 Sep 26, 2023
a78cf15
Added: getMailAttachments function
we-vineet-k001 Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion Libraries/VaahAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,38 @@ public function __construct()
$this->ajax = new Client();
}
//------------------------------------------------
public function post($url, $params=null, $headers = null)
public function get($url, $query=null, $headers = null): array
{
$data = null;

if(!is_null($query))
{
$data['query'] = $query;
}
if(!is_null($headers))
{
$data['headers'] = $headers;
}
try{
$res = $this->ajax->request('GET', $url, $data);
$response = [
'status' => 'success',
'data' => [
'status_code' => $res->getStatusCode(),
'body' => $res->getBody(),
'content' => $res->getBody()->getContents(),
]
];
}catch(\Exception $e)
{
$response['status'] = 'failed';
$response['errors'] = [$e->getMessage()];

}
return $response;
}
//------------------------------------------------
public function post($url, $params=null, $headers = null): array
{
$data = null;

Expand Down
79 changes: 79 additions & 0 deletions Libraries/VaahApollo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
namespace WebReinvent\VaahExtend\Libraries;

use Cartalyst\Stripe\Laravel\Facades\Stripe;
use Illuminate\Http\Request;

class VaahApollo{

//----------------------------------------------------------
public $api_base_url;
public $api_key;

//-----------------------------------------------------
function __construct($api_key, $api_base_url="https://api.apollo.io/v1/")
{
$this->api_base_url = $api_base_url;
$this->api_key = $api_key;
}
//----------------------------------------------------------

public function getOrganizations($inputs )
{
$url = $this->api_base_url."organizations/enrich";
$ajax = new VaahAjax();
$headers = [];
$inputs['api_key'] = $this->api_key;

$res = $ajax->post($url, $inputs, $headers);

unset($inputs['api_key']);

$response['request'] = $inputs;
$response['response'] = $res;

return $response;
}
//----------------------------------------------------------
public function getPeople($inputs)
{

$url = $this->api_base_url."mixed_people/search";

$ajax = new VaahAjax();
$headers = [
'Content-Type' => 'application/json'
];

$inputs['api_key'] = $this->api_key;

if(isset($inputs['domains'])){
if(is_array($inputs['domains']) && count($inputs['domains']) > 0){
$inputs['q_organization_domains'] = implode("\n", $inputs['domains']);
}else if(is_string($inputs['domains'])){
$inputs['q_organization_domains'] = preg_replace('/^www\./', '', $inputs['domains']);
}
}


/*
* person_titles variable accept query string like
* person_titles[]=ceo&person_titles[]=cto
* which is not equal to php array, hence we have to convert it
*/

$apollo_inputs = http_build_query($inputs);
$apollo_inputs = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $apollo_inputs);

$res = $ajax->get($url, $apollo_inputs, $headers);

unset($inputs['api_key']);
$response['request'] = $inputs;
$response['response'] = $res;

return $response;
}
//----------------------------------------------------------


}
81 changes: 65 additions & 16 deletions Libraries/VaahImap.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function test(): array
return $response;
}
//----------------------------------------------------------
function connect($search_by='SINCE', $search_value=null)
function connect()
{

$response = $this->test();
Expand All @@ -71,10 +71,6 @@ function connect($search_by='SINCE', $search_value=null)
return $response;
}

if($search_by=='SINCE' && !$search_value){
$search_value = date('d F Y');
}

$this->imap = new \PhpImap\Mailbox(
$this->mailbox,
$this->username,
Expand All @@ -88,6 +84,18 @@ function connect($search_by='SINCE', $search_value=null)
$this->imap->setAttachmentsIgnore(true);
}

return $this->imap;
}
//----------------------------------------------------------
function searchMailBox($search_by='UNSEEN', $search_value=null){

$this->connect();

if($search_by === 'SINCE' && is_null($search_value))
{
$search_value = date('d F Y');
}

try {
if($search_by == 'SINCE')
{
Expand All @@ -97,6 +105,21 @@ function connect($search_by='SINCE', $search_value=null)
} else{
$this->mail_uids = $this->searchMailBox('UNSEEN', SE_UID);
}

if(count($this->mail_uids) < 1) {
$response = [
'status' => "success",
'data' => [],
'messages' => ['Mailbox is empty'],
];
return $response;
}

return [
'status' => "success",
'data' => $this->mail_uids
];

} catch(\PhpImap\ConnectionException $ex)
{
$response = [
Expand All @@ -107,21 +130,30 @@ function connect($search_by='SINCE', $search_value=null)
}


if(count($this->mail_uids) < 1) {
$response = [
'status' => "success",
'data' => [],
'messages' => ['Mailbox is empty'],
];
return $response;

}
//----------------------------------------------------------
function getMailUids($search_by='UNSEEN', $search_value=null)
{

$connect = $this->searchMailBox($search_by, $search_value);

if(isset($connect['status']) && $connect['status'] == 'failed')
{
return $connect;
}

$response = [
'status' => "success",
'data' => $this->mail_uids,
];
return $response;
}
//----------------------------------------------------------
function getMails($search_by='SINCE', $search_value=null)
{

$connect = $this->connect($search_by, $search_value);
$connect = $this->searchMailBox($search_by, $search_value);

if(isset($connect['status']) && $connect['status'] == 'failed')
{
Expand Down Expand Up @@ -155,6 +187,9 @@ function getMails($search_by='SINCE', $search_value=null)
//----------------------------------------------------------
function getMail($uid)
{

$this->connect();

$mail = $this->imap->getMail($uid);

$data['mail_uid'] = $uid;
Expand All @@ -167,15 +202,15 @@ function getMail($uid)

$data['date_time'] = $mail->date;

$data['subject'] = $mail->subject;
$data['subject'] = mb_convert_encoding($mail->subject, "UTF-8", "auto");

if(!isset($data['subject']) || $data['subject'] == "")
{
$data['subject'] = "(no subject)";
}

$data['message_html'] = $mail->textHtml;
$data['message_plain'] = $mail->textPlain;
$data['message_html'] = mb_convert_encoding($mail->textHtml, "UTF-8", "auto");
$data['message_plain'] = mb_convert_encoding($mail->textPlain, "UTF-8", "auto");

$data['has_attachments'] = null;

Expand Down Expand Up @@ -311,7 +346,21 @@ function getBcc($mail)
}
//----------------------------------------------------------

function markAsRead($uid){
$this->connect();
return $this->imap->markMailAsRead($uid);
}

//----------------------------------------------------------
function markMailAsUnread($uid){
$this->connect();
return $this->imap->markMailAsUnread($uid);
}
//----------------------------------------------------------
function getMailAttachments($mail_uid){
$this->connect();
$mail = $this->imap->getMail($mail_uid);
return $mail->getAttachments();
}
//----------------------------------------------------------
}
125 changes: 125 additions & 0 deletions Libraries/VaahPayPal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# VaahPayPal
> Small Laravel Helpers

### Installation

VaahPaypal provides to you a simple way to integrate Paypal in your Laravel application.

### Dependencies
- [PayPal-PHP-SDK](https://github.com/paypal/PayPal-PHP-SDK)

### Installation

```shell script
composer require paypal/rest-api-sdk-php
```
### Add env variables:

`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.
```env
## For PayPal Sandbox
PAYPAL_MODE=sandbox
PAYPAL_SANDBOX_CLIENT_ID=xxxxxxxxxxxxxxx
PAYPAL_SANDBOX_CLIENT_SECRET=xxxxxxxxxxxxx
## For PayPal Live
PAYPAL_MODE=live
PAYPAL_LIVE_CLIENT_ID=xxxxxxxxxxxxxxx
PAYPAL_LIVE_CLIENT_SECRET=xxxxxxxxxxxxx
```
To obtain your PayPal sandbox client ID and client secret, you will need to complete the following steps:

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

### Initialize VaahPaypal
```php
//Initialize the VaahPaypal
$vaahPaypal = new VaahPayPal(
$client_id,
$client_secret,
$return_url,
$cancel_url,
$mode
);
```
| Name | Description | Required | Default |
|--|--|--|--|
| client_id | PayPal Live/Sandbox client id| Yes
| client_secret| PayPal Live/Sandbox client_secret| Yes
| return_ url| redirect the user to after they have completed a payment.| No | /api/vaah/paypal/execute
| cancel_url | redirect the user to after they have canceled a payment. | No| /api/vaah/paypal/cancel|
| mode | environments for managing payments | No | sandbox

### Methods
- Paypal Create Order

|Name| Required | Type |
|--|--|--|
| name | yes | String |
| quantity| yes | String
| amount| yes | String
| description| yes | String
| currency | yes | String |
|shipping | No | Integer
|tax| No | Integer
```php
$vaahPaypal->pay([
'name' => 'Name',
'amount' => 100,
'currency' => 'USD',
'description' => 'Description',
'quantity' => 1,
]);
```

**Success response**
```php
[
'status' => 'success';
'approval_url' = 'approval url';
'payment_id' = 'xxxxx';
'token' = 'EC-xxxxxxxx';
];
```
**Error Response**
```php
[
'status' => 'failed';
'errors' = 'errors';
];
```
- Execute Order

|Name| Required
|--|--|
| payment_id | yes |
| payer_id | yes |
```php
$payment_id = 'xxxx';
$payer_id = 'xxxx';
$vaahPaypal->executePayment($payment_id, $payer_id);
```

**Success response**
```php
[
'status' => 'success';
'data' => 'data'; //array
];
```
**Error response**
```php
[
'status' => 'failed';
'errors' = 'errors';
];
```
Reference url: https://developer.paypal.com/api/rest/
Loading