mobly/paypal-stc

PayPal STC SDK Integration

1.0.0 2019-09-18 13:05 UTC

This package is not auto-updated.

Last update: 2024-12-22 07:01:33 UTC


README

Mobly PayPal-STC-SDK

Simple SDK to make an standardize paypal stc integration

How to use

Make a Payment Transaction:

require __DIR__ . '/vendor/autoload.php';

use Mobly\PaypalStc\Sdk\Client;
use Mobly\PaypalStc\Sdk\Command\Risk;
use Mobly\PaypalStc\Sdk\Entities\Receiver;
use Mobly\PaypalStc\Sdk\Entities\Transaction;
use Mobly\PaypalStc\Sdk\Interfaces\PaymentInterface;

$paypalPlusMerchantId = "my-merchant-id";
$trackingId = 'my-tracking';
$token = 'my-token';
$url = 'http://www.paypal.com';

$risk = new Risk($paypalPlusMerchantId, $trackingId);
$receiver = new Receiver();
$order = new Transaction();

$sender = new \Mobly\PaypalStc\Sdk\Entities\Sender();
$sender->setSenderFirstName('João')
    ->setSenderLastName('João')
    ->setSenderPhone(11123451234);
    //other fields ...


$receiver->setBusinessName('Mobly');
$receiver->setReceiverEmail('paypal@paypal.com');
$receiver->setReceiverAccountId('paypal@paypal.com');
$receiver->setReceiverAddressState('SP');
$receiver->setReceiverAddressCity('São Paulo');
$receiver->setReceiverAddressCountryCode(PaymentInterface::PAYMENT_CURRENCY);
// other fields ...

$transaction = new Transaction();
$transaction->setSender($sender)
    ->setReceiver($receiver);

$client = new Client($token, $url);
$risk  = new Risk($paypalPlusMerchantId, $trackingId);

try {
    $risk->registerRisk($client, $transaction);
    $risk->retrieveRisk($client);
} catch (\GuzzleHttp\Exception\GuzzleException $e) {
    die($e->getMessage());
} catch (Exception $e) {
    die($e->getMessage());
}