mollie: pass orderid in description field (#60808)
The field "description" can also be filled with a more human description using the subject parameter of request().
This commit is contained in:
parent
6f9ebcd866
commit
0608e27dfe
|
@ -75,6 +75,8 @@ class Payment(PaymentCommon):
|
|||
|
||||
def request(self, amount, **kwargs):
|
||||
amount = self.clean_amount(amount, cents=False)
|
||||
orderid = kwargs.pop('orderid', None)
|
||||
subject = kwargs.pop('subject', None)
|
||||
|
||||
metadata = {
|
||||
k: v for k, v in kwargs.items() if k in ('email', 'first_name', 'last_name') and v is not None
|
||||
|
@ -89,6 +91,12 @@ class Payment(PaymentCommon):
|
|||
'metadata': metadata,
|
||||
'description': self.description_text,
|
||||
}
|
||||
if orderid is not None:
|
||||
body['description'] = orderid
|
||||
metadata['orderid'] = orderid
|
||||
if subject is not None:
|
||||
body['description'] = subject
|
||||
body['subject'] = subject
|
||||
|
||||
resp = self.call_endpoint('POST', 'payments', data=body)
|
||||
|
||||
|
|
|
@ -181,6 +181,44 @@ def test_mollie_request(mollie):
|
|||
assert body['redirectUrl'] == RETURN_URL
|
||||
|
||||
|
||||
@with_httmock(add_payment)
|
||||
def test_mollie_request_orderid(mollie):
|
||||
email = 'test@test.com'
|
||||
payment_id, kind, url = mollie.request(2.5, email=email, orderid='1234')
|
||||
|
||||
assert payment_id == PAYMENT_ID
|
||||
assert kind == eopayment.URL
|
||||
assert 'mollie.com/payscreen/' in url
|
||||
|
||||
body = json.loads(add_payment.call['requests'][0].body.decode())
|
||||
assert body['amount']['value'] == '2.5'
|
||||
assert body['amount']['currency'] == 'EUR'
|
||||
assert body['metadata']['email'] == email
|
||||
assert body['metadata']['orderid'] == '1234'
|
||||
assert body['webhookUrl'] == WEBHOOK_URL
|
||||
assert body['redirectUrl'] == RETURN_URL
|
||||
assert body['description'] == '1234'
|
||||
|
||||
|
||||
@with_httmock(add_payment)
|
||||
def test_mollie_request_orderid_subject(mollie):
|
||||
email = 'test@test.com'
|
||||
payment_id, kind, url = mollie.request(2.5, email=email, orderid='1234', subject='Ticket cantine #1234')
|
||||
|
||||
assert payment_id == PAYMENT_ID
|
||||
assert kind == eopayment.URL
|
||||
assert 'mollie.com/payscreen/' in url
|
||||
|
||||
body = json.loads(add_payment.call['requests'][0].body.decode())
|
||||
assert body['amount']['value'] == '2.5'
|
||||
assert body['amount']['currency'] == 'EUR'
|
||||
assert body['metadata']['email'] == email
|
||||
assert body['metadata']['orderid'] == '1234'
|
||||
assert body['webhookUrl'] == WEBHOOK_URL
|
||||
assert body['redirectUrl'] == RETURN_URL
|
||||
assert body['description'] == 'Ticket cantine #1234'
|
||||
|
||||
|
||||
@with_httmock(successful_payment)
|
||||
def test_mollie_response(mollie):
|
||||
payment_response = mollie.response(QUERY_STRING)
|
||||
|
|
Loading…
Reference in New Issue