Skip to content

Commit

Permalink
Add remaining Partner Referral API endpoints. (fixes #594)
Browse files Browse the repository at this point in the history
  • Loading branch information
srmklive committed Nov 9, 2023
1 parent 3ae53c0 commit 79560c5
Show file tree
Hide file tree
Showing 3 changed files with 286 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/Traits/PayPalAPI/PartnerReferrals.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,66 @@ public function showReferralData(string $partner_referral_id)

return $this->doPayPalRequest();
}

/**
* List Seller Tracking Information.
*
* @param string $partner_id
* @param string $tracking_id
*
* @throws \Throwable
*
* @return array|\Psr\Http\Message\StreamInterface|string
*
* @see https://developer.paypal.com/docs/api/partner-referrals/v1/#merchant-integration_find
*/
public function listSellerTrackingInformation(string $partner_id, string $tracking_id)
{
$this->apiEndPoint = "v1/customer/partners/{$partner_id}/merchant-integrations?tracking_id={$tracking_id}";

$this->verb = 'get';

return $this->doPayPalRequest();
}

/**
* Show Seller Status.
*
* @param string $partner_id
* @param string $merchant_id
*
* @throws \Throwable
*
* @return array|\Psr\Http\Message\StreamInterface|string
*
* @see https://developer.paypal.com/docs/api/partner-referrals/v1/#merchant-integration_status
*/
public function showSellerStatus(string $partner_id, string $merchant_id)
{
$this->apiEndPoint = "v1/customer/partners/{$partner_id}/merchant-integrations/{$merchant_id}";

$this->verb = 'get';

return $this->doPayPalRequest();
}

/**
* List Merchant Credentials.
*
* @param string $partner_id
*
* @throws \Throwable
*
* @return array|\Psr\Http\Message\StreamInterface|string
*
* @see https://developer.paypal.com/docs/api/partner-referrals/v1/#merchant-integration_credentials
*/
public function listMerchantCredentials(string $partner_id)
{
$this->apiEndPoint = "v1/customer/partners/{$partner_id}/merchant-integrations/credentials";

$this->verb = 'get';

return $this->doPayPalRequest();
}
}
67 changes: 67 additions & 0 deletions tests/Feature/AdapterFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,73 @@ public function it_can_get_referral_details()
$this->assertArrayHasKey('referral_data', $response);
}

/** @test */
public function it_can_list_seller_tracking_information()
{
$this->client->setAccessToken([
'access_token' => self::$access_token,
'token_type' => 'Bearer',
]);

$this->client->setClient(
$this->mock_http_client(
$this->mockListSellerTrackingInformationResponse()
)
);

$partner_id = 'U6E69K99P3G88';
$tracking_id = 'merchantref1';

$response = $this->client->listSellerTrackingInformation($partner_id, $tracking_id);

$this->assertArrayHasKey('merchant_id', $response);
$this->assertArrayHasKey('tracking_id', $response);
}

/** @test */
public function it_can_show_seller_status()
{
$this->client->setAccessToken([
'access_token' => self::$access_token,
'token_type' => 'Bearer',
]);

$this->client->setClient(
$this->mock_http_client(
$this->mockShowSellerStatusResponse()
)
);

$partner_id = 'U6E69K99P3G88';
$merchant_id = '8LQLM2ML4ZTYU';

$response = $this->client->showSellerStatus($partner_id, $merchant_id);

$this->assertArrayHasKey('merchant_id', $response);
}

/** @test */
public function it_can_list_merchant_credentials()
{
$this->client->setAccessToken([
'access_token' => self::$access_token,
'token_type' => 'Bearer',
]);

$this->client->setClient(
$this->mock_http_client(
$this->mockListMerchantCredentialsResponse()
)
);

$partner_id = 'U6E69K99P3G88';

$response = $this->client->listMerchantCredentials($partner_id);

$this->assertArrayHasKey('client_id', $response);
$this->assertArrayHasKey('payer_id', $response);
}

/** @test */
public function it_can_list_web_experience_profiles()
{
Expand Down
157 changes: 157 additions & 0 deletions tests/Mocks/Responses/PartnerReferrals.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,161 @@ private function mockShowReferralDataResponse(): array
]
}', true);
}

private function mockListSellerTrackingInformationResponse(): array
{
return Utils::jsonDecode('{
"merchant_id": "8LQLM2ML4ZTYU",
"tracking_id": "merchantref1",
"links": [
{
"href": "v1/customer/partners/6LKMD2ML4NJYU",
"rel": "read",
"method": "GET",
"description": "Main partner resource."
}
]
}', true);
}

private function mockShowSellerStatusResponse(): array
{
return Utils::jsonDecode('{
"merchant_id": "8LQLM2ML4ZTYU",
"products": [
{
"name": "PAYFLOW_PRO",
"vetting_status": "APPROVED",
"status": "ACTIVE"
},
{
"name": "EXPRESS_CHECKOUT",
"status": "ACTIVE"
},
{
"name": "PPCP_STANDARD",
"vetting_status": "SUBSCRIBED",
"capabilities": [
"CUSTOM_CARD_PROCESSING",
"CARD_PROCESSING_VIRTUAL_TERMINAL",
"FRAUD_TOOL_ACCESS",
"AMEX_OPTBLUE",
"DEBIT_CARD_SWITCH",
"COMMERCIAL_ENTITY"
]
},
{
"name": "PPCP_CUSTOM",
"vetting_status": "IN_REVIEW",
"capabilities": []
}
],
"capabilities": [
{
"name": "CUSTOM_CARD_PROCESSING",
"status": "ACTIVE",
"limits": [
{
"type": "GENERAL"
}
]
},
{
"name": "CARD_PROCESSING_VIRTUAL_TERMINAL",
"status": "ACTIVE"
},
{
"name": "FRAUD_TOOL_ACCESS",
"status": "ACTIVE"
},
{
"name": "AMEX_OPTBLUE",
"status": "ACTIVE"
},
{
"name": "DEBIT_CARD_SWITCH",
"status": "ACTIVE"
},
{
"name": "COMMERCIAL_ENTITY",
"status": "ACTIVE"
}
],
"payments_receivable": true,
"primary_email": "[email protected]",
"primary_email_confirmed": true,
"granted_permissions": [
"AIR_TRAVEL",
"INVOICING",
"RECURRING_PAYMENT_REPORT"
],
"api_credential": {
"signature": {
"api_user_name": "example_api1.gmail.com",
"api_password": "7QPZJL5PX2TT94RX",
"signature": "Ak0kqXY-wqI.w.dfyQrwACtkK4HcMNxGdvADyrIE8QLgZWyIDNJSDlQ1e"
}
},
"oauth_integrations": [
{
"integration_type": "OAUTH_THIRD_PARTY",
"oauth_third_party": [
{
"partner_client_id": "AafBGhBphJ66SHPtbCMTsH1q2HQC2lnf0ER0KWAVSsOqsAtVfnye5Vc8hAOC",
"merchant_client_id": "AafBGhBphJ66SHPtbCMTsH1q2HQC2lnf0ER0KWAVSsOqsAtVfnye5Vc8hAOC",
"scopes": [
"https://uri.paypal.com/services/payments/realtimepayment",
"https://uri.paypal.com/services/payments/payment/authcapture",
"https://uri.paypal.com/services/payments/refund"
]
},
{
"partner_client_id": "AafBGhBphJ66SHPtbCMTsH1q2HQC2lnf0ER0KWAVSsOqsAtVfnye5Vc8hAOC",
"merchant_client_id": "AafBGhBphJ66SHPtbCMTsH1q2HQC2lnf0ER0KWAVSsOqsAtVfnye5Vc8hAOC",
"scopes": [
"https://uri.paypal.com/services/payments/realtimepayment",
"https://uri.paypal.com/services/payments/payment/authcapture"
]
}
]
}
],
"limitations": [
{
"name": "MRCHT - Pending User Agreement",
"restrictions": [
"ACH IN",
"Withdraw Money",
"Remove Bank",
"Refunds to Buyer",
"Close Account",
"Send Money",
"Remove Card"
]
},
{
"name": "Seller-linked merchant",
"restrictions": [
"ACH IN",
"Send Money",
"Refunds to Buyer",
"Receive/Request Money",
"Remove Bank",
"Remove Card",
"Withdraw Money",
"Close Account"
]
}
]
}', true);
}

private function mockListMerchantCredentialsResponse(): array
{
return Utils::jsonDecode('{
"client_id": "Ab27r3fkrQezHdcPrn2b2SYzPEldXx2dWgv76btVfI-eYF8KRAd2WxXAZyb0ETygSNeHBthzlxjlQ_qw",
"client_secret": "EAcTvpnDHZf4icl_2MPnt2gRpOxHVtaQJChWU3PrRbYR4uyvUXV6h4DWQjm7XOfdnk_OrEEWdxY2eUG3",
"payer_id": "QVG98CUNMS2PY"
}', true);
}
}

0 comments on commit 79560c5

Please sign in to comment.