diff --git a/app/Http/Controllers/ClientPortal/ApplePayDomainController.php b/app/Http/Controllers/ClientPortal/ApplePayDomainController.php new file mode 100644 index 000000000000..8901102fec0c --- /dev/null +++ b/app/Http/Controllers/ClientPortal/ApplePayDomainController.php @@ -0,0 +1,105 @@ +stripe_keys) + ->where('is_deleted', false) + ->get(); + + foreach($cgs as $cg) + { + + if($cg->getConfigField('appleMerchantId')){ + return response($cg->getConfigField('appleMerchantId'),200); + + } + + } + + return response('', 400); + } + + /* Hosted */ + + $domain_name = $request->getHost(); + + if (strpos($domain_name, 'invoicing.co') !== false) + { + $subdomain = explode('.', $domain_name)[0]; + + $query = [ + 'subdomain' => $subdomain, + 'portal_mode' => 'subdomain', + ]; + + if($company = MultiDB::findAndSetDbByDomain($query)){ + return $this->resolveAppleMerchantId($company); + } + } + + $query = [ + 'portal_domain' => $request->getSchemeAndHttpHost(), + 'portal_mode' => 'domain', + ]; + + if($company = MultiDB::findAndSetDbByDomain($query)){ + return $this->resolveAppleMerchantId($company); + } + + return response('', 400); + + } + + private function resolveAppleMerchantId($company) + { + + $cgs = $company->company_gateways() + ->whereIn('gateway_key', $this->stripe_keys) + ->where('is_deleted', false) + ->get(); + + foreach($cgs as $cg) + { + + if($cg->getConfigField('appleMerchantId')){ + return response($cg->getConfigField('appleMerchantId'),200); + } + + } + + return response('', 400); + + } + +} diff --git a/app/Http/Controllers/ClientPortal/CreditController.php b/app/Http/Controllers/ClientPortal/CreditController.php index 2d5cafaa012d..a72b8b70bd47 100644 --- a/app/Http/Controllers/ClientPortal/CreditController.php +++ b/app/Http/Controllers/ClientPortal/CreditController.php @@ -1,4 +1,13 @@ run(); } + public function setDomain() + { + // \Stripe\ApplePayDomain::create([ + // 'domain_name' => 'example.com', + // ],[ + // 'stripe_account' => '{{CONNECTED_ACCOUNT_ID}}', + // ]); + } + public function disconnect() { if(!$this->stripe_connect) diff --git a/app/Utils/Traits/Uploadable.php b/app/Utils/Traits/Uploadable.php index 604bab5f5b1b..911e11053c96 100644 --- a/app/Utils/Traits/Uploadable.php +++ b/app/Utils/Traits/Uploadable.php @@ -42,4 +42,5 @@ trait Uploadable } } + } diff --git a/routes/api.php b/routes/api.php index ac07a0c107fd..796b50cc43bf 100644 --- a/routes/api.php +++ b/routes/api.php @@ -208,6 +208,7 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a Route::resource('subscriptions', 'SubscriptionController'); Route::post('subscriptions/bulk', 'SubscriptionController@bulk')->name('subscriptions.bulk'); Route::get('statics', 'StaticController'); + Route::post('apple_pay/upload_file','ApplyPayController@upload'); }); diff --git a/routes/web.php b/routes/web.php index b8180d7f1583..f29bf383ab55 100644 --- a/routes/web.php +++ b/routes/web.php @@ -44,3 +44,4 @@ Route::get('stripe/completed', 'StripeConnectController@completed')->name('strip Route::get('checkout/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', 'Gateways\Checkout3dsController@index')->name('checkout.3ds_redirect'); Route::get('mollie/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', 'Gateways\Mollie3dsController@index')->name('mollie.3ds_redirect'); Route::get('gocardless/ibp_redirect/{company_key}/{company_gateway_id}/{hash}', 'Gateways\GoCardlessController@ibpRedirect')->name('gocardless.ibp_redirect'); +Route::get('.well-known/apple-developer-merchantid-domain-association', 'ClientPortal\ApplePayDomainController@showAppleMerchantId'); diff --git a/tests/Feature/ApplePayDomainMerchantUrlTest.php b/tests/Feature/ApplePayDomainMerchantUrlTest.php new file mode 100644 index 000000000000..869652de1b5a --- /dev/null +++ b/tests/Feature/ApplePayDomainMerchantUrlTest.php @@ -0,0 +1,64 @@ +makeTestData(); + + $this->withoutMiddleware( + ThrottleRequests::class + ); + } + + public function testMerchantFieldGet() + { + $config = new \stdClass; + $config->publishableKey = "pk_test"; + $config->apiKey = "sk_test"; + $config->appleMerchantId = "merchant_id"; + + $cg = new CompanyGateway; + $cg->company_id = $this->company->id; + $cg->user_id = $this->user->id; + $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; + $cg->require_cvv = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; + $cg->update_details = true; + $cg->config = encrypt(json_encode($config)); + $cg->fees_and_limits = ''; + $cg->save(); + + $response = $this->withHeaders([])->get('.well-known/apple-developer-merchantid-domain-association'); + + $arr = $response->getContent(); + $response->assertStatus(200); + $this->assertEquals("merchant_id", $arr); + } +}