简体   繁体   中英

Using Objects in PAYPAL PHP REST API SDK

I am new to Rest Api's . I am trying to create a payment using paypal express checkout via php sdk rest api.I have downloaded and installed their official sdk.

Now I can create a normal payment and everything is working fine.Now I want to set landing page type to billing.In documentation page I have been told to set landing_page_type to billing. How can I do that in my php script.

Link : https://developer.paypal.com/docs/api/#flowconfig-object

My php script looks something like

$transaction = new Transaction();
$transaction->setAmount($amount)
    ->setItemList($itemList)
    ->setDescription("Payment description")
    ->setInvoiceNumber(uniqid());



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

    $payment->create($apiContext);

So As for I understood ,I must create new object named flow config and add landing page to it.I tried something like

    $billing = new FlowConfig();
$billing->setLandingPageType("billing");

What to do next ? How to integrage this $billing in my $payment

To set landing page type, you should create a Payment Experience and specify the landing page in the request:

https://developer.paypal.com/docs/integration/direct/rest-experience-overview/ https://developer.paypal.com/docs/api/#payment-experience

PHP SDK sample: https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payment-experience/CreateWebProfile.php

There is a payment experience profile ID in the response. Then add the ExperienceProfileId to the request of Create a Payment like below:

$payment->setIntent("sale")
    ->setPayer($payer)
    ->setRedirectUrls($redirectUrls)
    ->setTransactions(array($transaction));
    ->setExperienceProfileId(**********)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM