diff --git a/src/Traits/PayPalAPI/PartnerReferrals.php b/src/Traits/PayPalAPI/PartnerReferrals.php index 13aa2458..9d1cc17c 100644 --- a/src/Traits/PayPalAPI/PartnerReferrals.php +++ b/src/Traits/PayPalAPI/PartnerReferrals.php @@ -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(); + } } diff --git a/tests/Feature/AdapterFeatureTest.php b/tests/Feature/AdapterFeatureTest.php index 50b95981..a22750c6 100644 --- a/tests/Feature/AdapterFeatureTest.php +++ b/tests/Feature/AdapterFeatureTest.php @@ -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() { diff --git a/tests/Mocks/Responses/PartnerReferrals.php b/tests/Mocks/Responses/PartnerReferrals.php index b499e65c..0c620e32 100644 --- a/tests/Mocks/Responses/PartnerReferrals.php +++ b/tests/Mocks/Responses/PartnerReferrals.php @@ -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": "seller@example.com", + "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); + } }