Paypal Sandbox integration does not work!

Asked

Viewed 561 times

2

Hello, good morning will someone help me with a problem I’m having in Paypal’s Rest Api SDK integration.

I put the code below, it seems to run perfectly, but when I go in "Transactions" in the paypal sandbox no transaction appears. Can anyone tell me what it is?

CODE

use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Api\Payer;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Details;
use PayPal\Api\Amount;
use PayPal\Api\Transaction;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Payment;

require dirname( dirname( __FILE__ ) ) . "/autoload.php";

$api = new ApiContext(
    new OAuthTokenCredential(
        '{CLIENT_ID}',     // ClientID
        '{CLIENT_SECRECT}'      // ClientSecret
    )
);

$api->setConfig(
    array(
        'mode'                      => 'sandbox',
        'http.ConnectionTimeOut'    => 30,
        'log.LogEnable'             => false,
        'log.FileName'              => '',
        'log.LogLevel'              => 'FINE',
        'validation.level'          => 'log'
    )
);

/**
 * Payer

$payer = new Payer();
$payer->setPaymentMethod('paypal');

$item = new Item();
$item->setName('Item 1');
$item->setCurrency('USD');
$item->setPrice('2');
$item->setQuantity(1);

$itemList = new ItemList();
$itemList->setItems(array($item));

$details = new Details();
$details->setSubtotal('2');

$amount = new Amount();
$amount->setCurrency('USD');
$amount->setTotal('2');
$amount->setDetails($details);

$transaction = new Transaction();
$transaction->setAmount( $amount );
$transaction->setItemList($itemList);

$urls = new RedirectUrls();
$urls->setReturnUrl('{URL}');
$urls->setCancelUrl('{URL}');

$payment = new Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$payment->setRedirectUrls($urls);

try {
    $payment->create( $api );
} catch (Exception $e) {
    die($e);
}

header("location:" . $payment->getApprovalLink() );

I can finalize the "purchase" normally with the buyer user that the sandbox create, but no appearing transactions.

  • Hello, within your integration you are doing Doexpresscheckoutpayment correctly ? Because if it is not the payment is processed normally, but internally it is not completed. I recommend that you check your Doexpresscheckoutpayment, and try again!

  • Everything you need to know about Express Checkout integration in Brazil, you can find it on the Paypal website, for example https://www.paypal-brasil.com.br/developers/tutorial/guia-integracao-rapida-usando-express-checkout/ here is a good documentation explaining how the flow works and how your Doexpresscheckoutpayment should be. Let me know if it’s all right ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.