Skip to content

Instantly share code, notes, and snippets.

@masterfermin02
Created April 7, 2025 02:24
Show Gist options
  • Save masterfermin02/2bee29bbb6f991c9bc96aec6262b8506 to your computer and use it in GitHub Desktop.
Save masterfermin02/2bee29bbb6f991c9bc96aec6262b8506 to your computer and use it in GitHub Desktop.
Paypal service
<?php
namespace App\Extension\Paypal\Traits;
use Carbon\Carbon;
trait Filters
{
/**
* @var array
*/
protected $invoice_search_filters = [];
/**
* @var array
*/
protected $invoices_date_types = [
'invoice_date',
'due_date',
'payment_date',
'creation_date',
];
/**
* @var array
*/
protected $invoices_status_types = [
'DRAFT',
'SENT',
'SCHEDULED',
'PAID',
'MARKED_AS_PAID',
'CANCELLED',
'REFUNDED',
'PARTIALLY_PAID',
'PARTIALLY_REFUNDED',
'MARKED_AS_REFUNDED',
'UNPAID',
'PAYMENT_PENDING',
];
/**
* @param string $email
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function addInvoiceFilterByRecipientEmail(string $email): self
{
$this->invoice_search_filters['recipient_email'] = $email;
return $this;
}
/**
* @param string $name
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function addInvoiceFilterByRecipientFirstName(string $name): self
{
$this->invoice_search_filters['recipient_first_name'] = $name;
return $this;
}
/**
* @param string $name
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function addInvoiceFilterByRecipientLastName(string $name): self
{
$this->invoice_search_filters['recipient_last_name'] = $name;
return $this;
}
/**
* @param string $name
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function addInvoiceFilterByRecipientBusinessName(string $name): self
{
$this->invoice_search_filters['recipient_business_name'] = $name;
return $this;
}
/**
* @param string $invoice_number
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function addInvoiceFilterByInvoiceNumber(string $invoice_number): self
{
$this->invoice_search_filters['invoice_number'] = $invoice_number;
return $this;
}
/**
* @param array $status
*
* @throws \Exception
*
* @return \Srmklive\PayPal\Services\PayPal
*
* @see https://developer.paypal.com/docs/api/invoicing/v2/#definition-invoice_status
*/
public function addInvoiceFilterByInvoiceStatus(array $status): self
{
$invalid_status = false;
foreach ($status as $item) {
if (!in_array($item, $this->invoices_status_types)) {
$invalid_status = true;
}
}
if ($invalid_status === true) {
throw new \Exception('status should be always one of these: '.implode(',', $this->invoices_date_types));
}
$this->invoice_search_filters['status'] = $status;
return $this;
}
/**
* @param string $reference
* @param bool $memo
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function addInvoiceFilterByReferenceorMemo(string $reference, bool $memo = false): self
{
$field = ($memo === false) ? 'reference' : 'memo';
$this->invoice_search_filters[$field] = $reference;
return $this;
}
/**
* @param string $currency_code
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function addInvoiceFilterByCurrencyCode(string $currency_code = ''): self
{
$currency = !isset($currency_code) ? $this->getCurrency() : $currency_code;
$this->invoice_search_filters['currency_code'] = $currency;
return $this;
}
/**
* @param float $start_amount
* @param float $end_amount
* @param string $amount_currency
*
* @throws \Exception
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function addInvoiceFilterByAmountRange(float $start_amount, float $end_amount, string $amount_currency = ''): self
{
if ($start_amount > $end_amount) {
throw new \Exception('Starting amount should always be less than end amount!');
}
$currency = !isset($amount_currency) ? $this->getCurrency() : $amount_currency;
$this->invoice_search_filters['total_amount_range'] = [
'lower_amount' => [
'currency_code' => $currency,
'value' => $start_amount,
],
'upper_amount' => [
'currency_code' => $currency,
'value' => $end_amount,
],
];
return $this;
}
/**
* @param string $start_date
* @param string $end_date
* @param string $date_type
*
* @throws \Exception
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function addInvoiceFilterByDateRange(string $start_date, string $end_date, string $date_type): self
{
$start_date_obj = Carbon::parse($start_date);
$end_date_obj = Carbon::parse($end_date);
if ($start_date_obj->gt($end_date_obj)) {
throw new \Exception('Starting date should always be less than the end date!');
}
if (!in_array($date_type, $this->invoices_date_types)) {
throw new \Exception('date type should be always one of these: '.implode(',', $this->invoices_date_types));
}
$this->invoice_search_filters["{$date_type}_range"] = [
'start' => $start_date,
'end' => $end_date,
];
return $this;
}
/**
* @param bool $archived
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function addInvoiceFilterByArchivedStatus(?bool $archived = null): self
{
$this->invoice_search_filters['archived'] = $archived;
return $this;
}
/**
* @param array $fields
*
* @return \Srmklive\PayPal\Services\PayPal
*
* @see https://developer.paypal.com/docs/api/invoicing/v2/#definition-field
*/
public function addInvoiceFilterByFields(array $fields): self
{
$this->invoice_search_filters['status'] = $fields;
return $this;
}
}
<?php
namespace App\Extension\Paypal\Traits;
trait InvoicesSearch
{
use Filters;
/**
* Search and return existing invoices.
*
* @throws \Throwable
*
* @return array|\Psr\Http\Message\StreamInterface|string
*
* @see https://developer.paypal.com/docs/api/invoicing/v2/#invoices_list
*/
public function searchInvoices()
{
if (collect($this->invoice_search_filters)->count() < 1) {
$this->invoice_search_filters = [
'currency_code' => $this->getCurrency(),
];
}
$this->apiEndPoint = "v2/invoicing/search-invoices?page={$this->current_page}&page_size={$this->page_size}&total_required={$this->show_totals}";
$this->options['json'] = $this->invoice_search_filters;
$this->verb = 'post';
return $this->doPayPalRequest();
}
}
namespace App\Extension\Paypal\Services;
use App\Extension\Paypal\Traits\PayPalAPI;
use App\Extension\Paypal\Traits\PayPalExperienceContext;
use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Exception\ClientException as HttpClientException;
use GuzzleHttp\Utils;
use Psr\Http\Message\StreamInterface;
use RuntimeException;
use Srmklive\PayPal\Services\Str;
use Srmklive\PayPal\Traits\PayPalVerifyIPN;
class Paypal
{
use PayPalAPI;
use PayPalExperienceContext;
use PayPalVerifyIPN;
/**
* Http Client class object.
*
* @var HttpClient
*/
private $client;
/**
* Http Client configuration.
*
* @var array
*/
private $httpClientConfig;
/**
* PayPal API Endpoint.
*
* @var string
*/
private $apiUrl;
/**
* PayPal API Endpoint.
*
* @var string
*/
private $apiEndPoint;
/**
* IPN notification url for PayPal.
*
* @var string
*/
private $notifyUrl;
/**
* Http Client request body parameter name.
*
* @var string
*/
private $httpBodyParam;
/**
* Default payment action for PayPal.
*
* @var string
*/
private $paymentAction;
/**
* Default locale for PayPal.
*
* @var string
*/
private $locale;
/**
* Validate SSL details when creating HTTP client.
*
* @var bool
*/
private $validateSSL;
/**
* Request type.
*
* @var string
*/
protected $verb = 'post';
/**
* PayPal API mode to be used.
*
* @var string
*/
public $mode;
/**
* PayPal access token.
*
* @var string
*/
protected $access_token;
/**
* PayPal API configuration.
*
* @var array
*/
private array $config;
/**
* Default currency for PayPal.
*
* @var string
*/
protected $currency;
/**
* Additional options for PayPal API request.
*
* @var array
*/
protected $options;
/**
* Set limit to total records per API call.
*
* @var int
*/
protected $page_size = 20;
/**
* Set the current page for list resources API calls.
*
* @var bool
*/
protected $current_page = 1;
/**
* Toggle whether totals for list resources are returned after every API call.
*
* @var string
*/
protected string $show_totals;
/**
* PayPal constructor.
*
* @param array $config
*
* @throws Exception
*/
public function __construct(array $config = [])
{
// Setting PayPal API Credentials
$this->setConfig($config);
$this->httpBodyParam = 'form_params';
$this->options = [];
$this->setRequestHeader('Accept', 'application/json');
}
/**
* Set ExpressCheckout API endpoints & options.
*
* @param array $credentials
*/
protected function setOptions(array $credentials): void
{
// Setting API Endpoints
$this->config['api_url'] = 'https://api-m.paypal.com';
$this->config['gateway_url'] = 'https://www.paypal.com';
$this->config['ipn_url'] = 'https://ipnpb.paypal.com/cgi-bin/webscr';
if ($this->mode === 'sandbox') {
$this->config['api_url'] = 'https://api-m.sandbox.paypal.com';
$this->config['gateway_url'] = 'https://www.sandbox.paypal.com';
$this->config['ipn_url'] = 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr';
}
// Adding params outside sandbox / live array
$this->config['payment_action'] = $credentials['payment_action'];
$this->config['notify_url'] = $credentials['notify_url'];
$this->config['locale'] = $credentials['locale'];
}
/**
* Login through PayPal API to get access token.
*
* @throws \Throwable
*
* @return array|\Psr\Http\Message\StreamInterface|string
*
* @see https://developer.paypal.com/docs/api/get-an-access-token-curl/
* @see https://developer.paypal.com/docs/api/get-an-access-token-postman/
*/
public function getAccessToken()
{
$this->apiEndPoint = 'v1/oauth2/token';
$this->options['auth'] = [$this->config['client_id'], $this->config['client_secret']];
$this->options[$this->httpBodyParam] = [
'grant_type' => 'client_credentials',
];
$response = $this->doPayPalRequest();
unset($this->options['auth']);
unset($this->options[$this->httpBodyParam]);
if (isset($response['access_token'])) {
$this->setAccessToken($response);
}
return $response;
}
/**
* Set PayPal Rest API access token.
*
* @param array $response
*
* @return void
*/
public function setAccessToken(array $response)
{
$this->access_token = $response['access_token'] ?? '';
$this->setPayPalAppId($response);
$tokenType = $response['token_type'] ?? 'Bearer';
$this->setRequestHeader('Authorization', "{$tokenType} {$this->access_token}");
}
/**
* Set PayPal App ID.
*
* @param array $response
*
* @return void
*/
private function setPayPalAppId(array $response)
{
$app_id = empty($response['app_id']) ? $this->config['app_id'] : $response['app_id'];
$this->config['app_id'] = $app_id;
}
/**
* Set records per page for list resources API calls.
*
* @param int $size
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function setPageSize(int $size): self
{
$this->page_size = $size;
return $this;
}
/**
* Set the current page for list resources API calls.
*
* @param int $size
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function setCurrentPage(int $page): self
{
$this->current_page = $page;
return $this;
}
/**
* Toggle whether totals for list resources are returned after every API call.
*
* @param bool $totals
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function showTotals(bool $totals): self
{
$this->show_totals = $totals ? 'true' : 'false';
return $this;
}
/**
* Set curl constants if not defined.
*
* @return void
*/
protected function setCurlConstants()
{
$constants = [
'CURLOPT_SSLVERSION' => 32,
'CURL_SSLVERSION_TLSv1_2' => 6,
'CURLOPT_SSL_VERIFYPEER' => 64,
'CURLOPT_SSLCERT' => 10025,
];
foreach ($constants as $key => $item) {
$this->defineCurlConstant($key, $item);
}
}
/**
* Declare a curl constant.
*
* @param string $key
* @param string $value
*
* @return bool
*/
protected function defineCurlConstant(string $key, string $value)
{
return defined($key) ? true : define($key, $value);
}
/**
* Function to initialize/override Http Client.
*
* @param \GuzzleHttp\Client|null $client
*
* @return void
*/
public function setClient(?HttpClient $client = null)
{
if ($client instanceof HttpClient) {
$this->client = $client;
return;
}
$this->client = new HttpClient([
'curl' => $this->httpClientConfig,
]);
}
/**
* Function to set Http Client configuration.
*
* @return void
*/
protected function setHttpClientConfiguration()
{
$this->setCurlConstants();
$this->httpClientConfig = [
CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2,
CURLOPT_SSL_VERIFYPEER => $this->validateSSL,
];
// Initialize Http Client
$this->setClient();
// Set default values.
$this->setDefaultValues();
// Set PayPal IPN Notification URL
$this->notifyUrl = $this->config['notify_url'];
}
/**
* Set default values for configuration.
*
* @return void
*/
private function setDefaultValues()
{
$paymentAction = empty($this->paymentAction) ? 'Sale' : $this->paymentAction;
$this->paymentAction = $paymentAction;
$locale = empty($this->locale) ? 'en_US' : $this->locale;
$this->locale = $locale;
$validateSSL = empty($this->validateSSL) ? true : $this->validateSSL;
$this->validateSSL = $validateSSL;
$this->showTotals(true);
}
/**
* Perform PayPal API request & return response.
*
* @throws \Throwable
*
* @return StreamInterface
*/
private function makeHttpRequest(): StreamInterface
{
try {
return $this->client->{$this->verb}(
$this->apiUrl,
$this->options
)->getBody();
} catch (HttpClientException $e) {
throw new RuntimeException($e->getResponse()->getBody());
}
}
/**
* Function To Perform PayPal API Request.
*
* @param bool $decode
*
* @throws \Throwable
*
* @return array|StreamInterface|string
*/
private function doPayPalRequest(bool $decode = true)
{
try {
$this->apiUrl = collect([$this->config['api_url'], $this->apiEndPoint])->implode('/');
// Perform PayPal HTTP API request.
$response = $this->makeHttpRequest();
return ($decode === false) ? $response->getContents() : Utils::jsonDecode($response, true);
} catch (RuntimeException $t) {
$error = ($decode === false) || (Str::isJson($t->getMessage()) === false) ? $t->getMessage() : Utils::jsonDecode($t->getMessage(), true);
return ['error' => $error];
}
}
/**
* Set PayPal API Credentials.
*
* @param array $credentials
*
* @throws \RuntimeException|\Exception
*/
public function setApiCredentials(array $credentials): void
{
if (empty($credentials)) {
$this->throwConfigurationException();
}
// Setting Default PayPal Mode If not set
$this->setApiEnvironment($credentials);
// Set API configuration for the PayPal provider
$this->setApiProviderConfiguration($credentials);
// Set default currency.
$this->setCurrency($credentials['currency']);
// Set Http Client configuration.
$this->setHttpClientConfiguration();
}
/**
* Function to set currency.
*
* @param string $currency
*
* @throws \RuntimeException
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function setCurrency(string $currency = 'USD'): self
{
$allowedCurrencies = ['AUD', 'BRL', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'INR', 'JPY', 'MYR', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'TWD', 'THB', 'USD', 'RUB', 'CNY'];
// Check if provided currency is valid.
if (!in_array($currency, $allowedCurrencies, true)) {
throw new RuntimeException('Currency is not supported by PayPal.');
}
$this->currency = $currency;
return $this;
}
/**
* Return the set currency.
*/
public function getCurrency(): string
{
return $this->currency;
}
/**
* Function to add request header.
*
* @param string $key
* @param string $value
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function setRequestHeader(string $key, string $value): self
{
$this->options['headers'][$key] = $value;
return $this;
}
/**
* Function to add multiple request headers.
*
* @param array $headers
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function setRequestHeaders(array $headers): self
{
foreach ($headers as $key=>$value) {
$this->setRequestHeader($key, $value);
}
return $this;
}
/**
* Return request options header.
*
* @param string $key
*
* @throws \RuntimeException
*
* @return string
*/
public function getRequestHeader(string $key): string
{
if (isset($this->options['headers'][$key])) {
return $this->options['headers'][$key];
}
throw new RuntimeException('Options header is not set.');
}
/**
* Function To Set PayPal API Configuration.
*
* @param array $config
*
* @throws \Exception
*/
private function setConfig(array $config): void
{
$api_config = empty($config) && function_exists('config') && !empty(config('paypal')) ?
config('paypal') : $config;
// Set Api Credentials
$this->setApiCredentials($api_config);
}
/**
* Set API environment to be used by PayPal.
*
* @param array $credentials
*/
private function setApiEnvironment(array $credentials): void
{
$this->mode = 'live';
if (!empty($credentials['mode'])) {
$this->setValidApiEnvironment($credentials['mode']);
} else {
$this->throwConfigurationException();
}
}
/**
* Validate & set the environment to be used by PayPal.
*
* @param string $mode
*/
private function setValidApiEnvironment(string $mode): void
{
$this->mode = !in_array($mode, ['sandbox', 'live']) ? 'live' : $mode;
}
/**
* Set configuration details for the provider.
*
* @param array $credentials
*
* @throws \Exception
*/
private function setApiProviderConfiguration(array $credentials): void
{
// Setting PayPal API Credentials
if (empty($credentials[$this->mode])) {
$this->throwConfigurationException();
}
$config_params = ['client_id', 'client_secret'];
foreach ($config_params as $item) {
if (empty($credentials[$this->mode][$item])) {
throw new RuntimeException("{$item} missing from the provided configuration. Please add your application {$item}.");
}
}
collect($credentials[$this->mode])->map(function ($value, $key) {
$this->config[$key] = $value;
});
$this->paymentAction = $credentials['payment_action'];
$this->locale = $credentials['locale'];
$this->setRequestHeader('Accept-Language', $this->locale);
$this->validateSSL = $credentials['validate_ssl'];
$this->setOptions($credentials);
}
/**
* @throws RuntimeException
*/
private function throwConfigurationException()
{
throw new RuntimeException('Invalid configuration provided. Please provide valid configuration for PayPal API. You can also refer to the documentation at https://srmklive.github.io/laravel-paypal/docs.html to setup correct configuration.');
}
/**
* @throws RuntimeException
*/
private function throwInvalidEvidenceFileException()
{
throw new RuntimeException('Invalid evidence file type provided.
1. The party can upload up to 50 MB of files per request.
2. Individual files must be smaller than 10 MB.
3. The supported file formats are JPG, JPEG, GIF, PNG, and PDF.
');
}
/**
* List tracking information based on Transaction ID or tracking number.
*
* @param string $transaction_id
* @param string $tracking_number
*
* @throws \Throwable
*
* @return array|\Psr\Http\Message\StreamInterface|string
*
* @see https://developer.paypal.com/docs/api/tracking/v1/#trackers-batch_get
*/
public function listTrackingDetails(string $transaction_id, ?string $tracking_number = null)
{
$this->apiEndPoint = "v1/shipping/trackers?transaction_id={$transaction_id}".!empty($tracking_number) ? "&tracking_number={$tracking_number}" : '';
$this->verb = 'get';
return $this->doPayPalRequest();
}
/**
* Adds tracking information, with or without tracking numbers, for multiple PayPal transactions.
*
* @param array $data
*
* @throws \Throwable
*
* @return array|\Psr\Http\Message\StreamInterface|string
*
* @see https://developer.paypal.com/docs/api/tracking/v1/#trackers-batch_post
*/
public function addBatchTracking(array $data)
{
$this->apiEndPoint = 'v1/shipping/trackers-batch';
$this->options['json'] = $data;
$this->verb = 'post';
return $this->doPayPalRequest();
}
/**
* Adds tracking information for a PayPal transaction.
*
* @param array $data
*
* @throws \Throwable
*
* @return array|\Psr\Http\Message\StreamInterface|string
*
* @see https://developer.paypal.com/docs/api/tracking/v1/#trackers_post
*/
public function addTracking(array $data)
{
$this->apiEndPoint = 'v1/shipping/trackers';
$this->options['json'] = $data;
$this->verb = 'post';
return $this->doPayPalRequest();
}
/**
* Update tracking information.
*
* @param string $tracking_id
* @param array $data
*
* @throws \Throwable
*
* @return array|\Psr\Http\Message\StreamInterface|string
*
* @see https://developer.paypal.com/docs/api/tracking/v1/#trackers_put
*/
public function updateTrackingDetails(string $tracking_id, array $data)
{
$this->apiEndPoint = "v1/shipping/trackers/{$tracking_id}";
$this->options['json'] = $data;
$this->verb = 'put';
return $this->doPayPalRequest(false);
}
/**
* Show tracking information.
*
* @param string $tracking_id
*
* @throws \Throwable
*
* @return array|\Psr\Http\Message\StreamInterface|string
*
* @see https://developer.paypal.com/docs/api/tracking/v1/#trackers_get
*/
public function showTrackingDetails(string $tracking_id)
{
$this->apiEndPoint = "v1/shipping/trackers/{$tracking_id}";
$this->verb = 'get';
return $this->doPayPalRequest();
}
}
<?php
namespace App\Extension\Paypal\Traits;
use Srmklive\PayPal\Traits\PayPalAPI as PayPalAPITrait;
trait PayPalAPI
{
use PayPalAPITrait\CatalogProducts;
use PayPalAPITrait\Disputes;
use PayPalAPITrait\DisputesActions;
use PayPalAPITrait\Identity;
use PayPalAPITrait\Invoices;
use InvoicesSearch;
use PayPalAPITrait\InvoicesTemplates;
use PayPalAPITrait\Orders;
use PayPalAPITrait\PartnerReferrals;
use PayPalAPITrait\PaymentExperienceWebProfiles;
use PayPalAPITrait\PaymentMethodsTokens;
use PayPalAPITrait\PaymentAuthorizations;
use PayPalAPITrait\PaymentCaptures;
use PayPalAPITrait\PaymentRefunds;
use PayPalAPITrait\Payouts;
use PayPalAPITrait\ReferencedPayouts;
use PayPalAPITrait\BillingPlans;
use PayPalAPITrait\Subscriptions;
use PayPalAPITrait\Reporting;
use PayPalAPITrait\WebHooks;
use PayPalAPITrait\WebHooksVerification;
use PayPalAPITrait\WebHooksEvents;
}
<?php
namespace App\Extension\Paypal\Traits;
trait PayPalExperienceContext
{
/**
* @var array
*/
protected $experience_context = [];
/**
* Set Brand Name when setting experience context for payment.
*
* @param string $brand
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function setBrandName(string $brand): self
{
$this->experience_context = array_merge($this->experience_context, [
'brand_name' => $brand,
]);
return $this;
}
/**
* Set return & cancel urls.
*
* @param string $return_url
* @param string $cancel_url
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function setReturnAndCancelUrl(string $return_url, string $cancel_url): self
{
$this->experience_context = array_merge($this->experience_context, [
'return_url' => $return_url,
'cancel_url' => $cancel_url,
]);
return $this;
}
/**
* Set stored payment source.
*
* @param string $initiator
* @param string $type
* @param string $usage
* @param bool $previous_reference
* @param string|null $previous_transaction_id
* @param string|null $previous_transaction_date
* @param string|null $previous_transaction_reference_number
* @param string|null $previous_transaction_network
*
* @return \Srmklive\PayPal\Services\PayPal
*/
public function setStoredPaymentSource(
string $initiator,
string $type,
string $usage,
bool $previous_reference = false,
?string $previous_transaction_id = null,
?string $previous_transaction_date = null,
?string $previous_transaction_reference_number = null,
?string $previous_transaction_network = null
): self {
$this->experience_context = array_merge($this->experience_context, [
'stored_payment_source' => [
'payment_initiator' => $initiator,
'payment_type' => $type,
'usage' => $usage,
],
]);
if ($previous_reference === true) {
$this->experience_context['stored_payment_source']['previous_network_transaction_reference'] = [
'id' => $previous_transaction_id,
'date' => $previous_transaction_date,
'acquirer_reference_number' => $previous_transaction_reference_number,
'network' => $previous_transaction_network,
];
}
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment