Skip to content

Commit

Permalink
Merge pull request #323 from EasyPost/priority
Browse files Browse the repository at this point in the history
fix: rename primaryOrSecondary to priority
  • Loading branch information
Justintime50 committed Nov 29, 2023
2 parents e6e4176 + a0a3514 commit d573f88
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Removed `withCarbonOffset` parameter from `create`, `buy`, and `regenerateRates` functions of the Shipment service as EasyPost now offers Carbon Neutral shipments by default for free
- Fixes a bug where the original filtering criteria of `all` calls wasn't passed along to `getNextPage` calls. Now, these are persisted via a `_params` key on response objects locally
- Removes the undocumented `createAndBuy` function from the `Batch` service. The proper usage is to create a batch first and buy it separately
- Renames `primaryOrSecondary` to `priority` to match the API name for the parameter

## v6.9.1 (2023-11-20)

Expand Down
6 changes: 3 additions & 3 deletions lib/EasyPost/Service/BetaReferralCustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ class BetaReferralCustomerService extends BaseService
*
* @param string $stripeCustomerId
* @param string $paymentMethodReference
* @param string $primaryOrSecondary
* @param string $priority
* @return mixed
*/
public function addPaymentMethod($stripeCustomerId, $paymentMethodReference, $primaryOrSecondary = 'primary')
public function addPaymentMethod($stripeCustomerId, $paymentMethodReference, $priority = 'primary')
{
$params = [
'payment_method' => [
'stripe_customer_id' => $stripeCustomerId,
'payment_method_reference' => $paymentMethodReference,
'priority' => $primaryOrSecondary
'priority' => $priority
]
];

Expand Down
18 changes: 9 additions & 9 deletions lib/EasyPost/Service/BillingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public function retrievePaymentMethods($params = null)
* Fund your EasyPost wallet by charging your primary or secondary payment method.
*
* @param string $amount
* @param string $primaryOrSecondary
* @param string $priority
* @return void
*/
public function fundWallet($amount, $primaryOrSecondary = 'primary')
public function fundWallet($amount, $priority = 'primary')
{
[$paymentMethodEndpoint, $paymentMethodId] = self::getPaymentInfo(strtolower($primaryOrSecondary));
[$paymentMethodEndpoint, $paymentMethodId] = self::getPaymentInfo(strtolower($priority));

$url = $paymentMethodEndpoint . "/$paymentMethodId/charges";
$wrappedParams = ['amount' => $amount];
Expand All @@ -53,12 +53,12 @@ public function fundWallet($amount, $primaryOrSecondary = 'primary')
/**
* Delete a payment method.
*
* @param string $primaryOrSecondary
* @param string $priority
* @return void
*/
public function deletePaymentMethod($primaryOrSecondary)
public function deletePaymentMethod($priority)
{
[$paymentMethodEndpoint, $paymentMethodId] = self::getPaymentInfo(strtolower($primaryOrSecondary));
[$paymentMethodEndpoint, $paymentMethodId] = self::getPaymentInfo(strtolower($priority));
$url = $paymentMethodEndpoint . "/$paymentMethodId";

Requestor::request($this->client, 'delete', $url);
Expand All @@ -67,18 +67,18 @@ public function deletePaymentMethod($primaryOrSecondary)
/**
* Get payment info (type of the payment method and ID of the payment method)
*
* @param string $primaryOrSecondary
* @param string $priority
* @return array
* @throws PaymentException
*/
private function getPaymentInfo($primaryOrSecondary = 'primary')
private function getPaymentInfo($priority = 'primary')
{
$paymentMethods = self::retrievePaymentMethods();
$paymentMethodMap = [
'primary' => 'primary_payment_method',
'secondary' => 'secondary_payment_method'
];
$paymentMethodToUse = $paymentMethodMap[$primaryOrSecondary] ?? null;
$paymentMethodToUse = $paymentMethodMap[$priority] ?? null;

if ($paymentMethodToUse != null && $paymentMethods->$paymentMethodToUse->id != null) {
$paymentMethodId = $paymentMethods->$paymentMethodToUse->id;
Expand Down
6 changes: 3 additions & 3 deletions lib/EasyPost/Service/ReferralCustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function updateEmail($email, $userId)
* @param int $expirationMonth
* @param int $expirationYear
* @param string $cvc
* @param string $primaryOrSecondary
* @param string $priority
* @return mixed
* @throws ExternalApiException
*/
Expand All @@ -96,7 +96,7 @@ public function addCreditCard(
$expirationMonth,
$expirationYear,
$cvc,
$primaryOrSecondary = 'primary'
$priority = 'primary'
) {
$easypostStripeApiKey = self::retrieveEasypostStripeApiKey();

Expand All @@ -114,7 +114,7 @@ public function addCreditCard(

$stripeToken = $stripeToken['id'] ?? '';

$response = self::createEasypostCreditCard($referralApiKey, $stripeToken, $primaryOrSecondary);
$response = self::createEasypostCreditCard($referralApiKey, $stripeToken, $priority);

return InternalUtil::convertToEasyPostObject($this->client, $response);
}
Expand Down

0 comments on commit d573f88

Please sign in to comment.