2016-10-20 23:10 阅读 116


I am working with the PayPal-PHP-SDK as suggested in the Developer Docs. I am running this code currently:

I simply want to change the Brand Name and add a Logo, but I don't know how to achieve this.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dpjjr42626 dpjjr42626 2016-10-21 09:49

    Since PayPal updated their Design the Design changes you can make in the profile Settings wont work anymore.

    To change the Design, you need to create a WebProfile first:

        // Create the WebProfile
        $presentation = new Presentation();
            ->setBrandName("YeowZa! Paypal")
        $inputFields = new InputFields();
        $webProfile = new WebProfile();
        $webProfile->setName("YeowZa! T-Shirt Shop" . uniqid())
        try {
            $createdProfile = $webProfile->create($paypal);
            $createdProfileID = json_decode($createdProfile);
            $profileid = $createdProfileID->id;
        } catch(PayPal\Exception\PayPalConnectionException $pce) {
            echo '<pre>',print_r(json_decode($pce->getData())),"</pre>";

    The ID of the created Profile is been stored in $profileid.This ID needs to be set via. setExperienceProfileId($profileid) if you create the payment.

            // Create the Payment       
        $product = $_POST['product'];
        $price = 4;
        $shipping  = 2;
        $total = $price + $shipping;
        $payer = new Payer(); 
        $item1 = new Item();
        $item1->setName('Ground Coffee 40 oz') ->setCurrency('EUR') ->setQuantity(1) ->setSku("123123")->setPrice(6.5); // Similar to `item_number` in Classic API 
        $item2 = new Item();
        $item2->setName('Granola bars') ->setCurrency('EUR') ->setQuantity(1) ->setSku("321321")->setPrice(1.5); // Similar to `item_number` in Classic API  
        $itemList = new ItemList(); 
        $itemList->setItems(array($item1, $item2));
        $details = new Details(); 
        $details->setShipping(1.2) ->setTax(1.3) ->setSubtotal(8);
        $amount = new Amount();
        $amount->setCurrency("EUR") ->setTotal(10.5) ->setDetails($details);
        $transaction = new Transaction();
        $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid());
        $baseUrl = "http://localhost/abiunity/test.php"; 
        $redirectUrls = new RedirectUrls(); 
        $payment = new Payment(); 
        $payment->setExperienceProfileId($profileid)->setIntent("sale") ->setPayer($payer) ->setRedirectUrls($redirectUrls) ->setTransactions(array($transaction));
        //$request = clone $payment;
        try {
            $approvalUrl = $payment->getApprovalLink();
        } catch(PayPal\Exception\PayPalConnectionException $pce) {
            echo '<pre>',print_r(json_decode($pce->getData())),"</pre>";

    I hope this helps someone and saves a little bit of time :)

    点赞 评论 复制链接分享