diff --git a/src/DqBilling.php b/src/DqBilling.php index 32a90c121e459fb9809bd19fe882ca86a578f24b..7b85ff49df838f74893d4d82b0437e90e51fae02 100644 --- a/src/DqBilling.php +++ b/src/DqBilling.php @@ -19,21 +19,13 @@ class DqBilling extends \Staskjs\SimpleApi\SimpleJsonApi { } public function pay(array $customerData, array $paymentData) { - $customer = [ - 'id' => $customerData['id'] - ]; - - $payment = [ - 'card_identifier' => $paymentData['card_identifier'], - 'merchantSessionKey' => $paymentData['merchant_session_key'], - 'description' => $paymentData['payment_type'], - 'type' => $paymentData['payment_type'], - 'amount' => $paymentData['amount'], - 'currency' => $paymentData['currency'], - 'save_card' => $paymentData['save_data'], - 'applicationAlias' => $paymentData['application_alias'] - ]; - + $customer = array_only($customerData, ['id']); + + $payment = array_only($paymentData, [ + 'card_identifier', 'merchantSessionKey', 'description', + 'type', 'amount', 'currency', 'save_card', 'applicationAlias', + ]); + return $this->request('POST', 'pay', [ 'customer' => $customer, 'payment' => $payment, @@ -43,4 +35,20 @@ class DqBilling extends \Staskjs\SimpleApi\SimpleJsonApi { public function getPaymentSession() { return $this->request('GET', 'payment_session'); } + + public function getClientProfiles($urn) { + return $this->request('GET', 'customers', ['urn' => $urn]); + } + + public function getProfilePaymentCards($customerId) { + return $this->request('GET', "customers/{$customerId}/cards"); + } + + public function saveProfile(array $profile) { + $profileData = array_only($profile, [ + 'urn', 'first_name', 'last_name', 'address_1', 'address_2', + 'country', 'city', 'postal_code', 'state', 'id' + ]); + return $this->request('POST', 'customers', $profileData); + } }