Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to create and delete PayPal WebProfile object (PHP)

Tags:

php

paypal

I'm using PayPal REST API WebProfile class to customize how a PayPal site should be opened to a customer. There are some things that are not clear for me. Based on PayPal recommendations, I create a WebProfile object, get unique experience_profile_id and use it when creating a Payment object (which opens PayPal site for payment). Snippets (a lot of code including try blocks, etc. removed for brevity):

$my_web_profile = new WebProfile();
$create_profile_response = $my_web_profile->create($my_paypal);
$my_web_profile_id = $create_profile_response->getId();
$my_payment = new Payment();
$my_payment->setExperienceProfileId($my_web_profile_id);
$my_payment->create($my_paypal);

All of this works fine.

My questions:

WebProfile class gives a way to update a created web-profile object and delete it. When should I use update and delete methods? What is the appropriate time to create WebProfile object? Can it be created when a website starts and just reused for every payment customers try to make? Or should it be created for each payment ( when a customer presses "Buy" button ) and deleted after each payment?

like image 630
Diana Avatar asked Nov 09 '22 23:11

Diana


1 Answers

The PayPal API Reference states:

As a merchant, you can use the Payment Experience API to create web experience profiles to customize payment flow experiences. You can create multiple product-agnostic web experience profiles. These profiles are decoupled from the core Payments API and your general merchant profile settings and preferences, which enables you to use them across products and integration types.

When you create a payment, you can reference a web experience profile that provides your customers with a seamless experience from your merchant cart to the payment flow.

This means you just have to create a profile once for your app. The profile can be used to place multiple payments. You don't need to necessarily delete it.

like image 191
Simon H Avatar answered Nov 15 '22 05:11

Simon H