Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for currencies #20

Closed
rvdsteege opened this issue Sep 17, 2024 · 1 comment · Fixed by #21
Closed

Add support for currencies #20

rvdsteege opened this issue Sep 17, 2024 · 1 comment · Fixed by #21
Assignees
Labels
enhancement New feature or request

Comments

@rvdsteege
Copy link
Member

From customer, who wants to use the currency CHF to accept payments through Twint:

How can I define the currency?

Currently, only payments in EUR are supported — the default currency of the https://github.com/pronamic/wp-money library.

public static function get_submission_payment( WPCF7_Submission $submission ) {
$gateway = self::get_default_gateway();
if ( null === $gateway ) {
return null;
}
$submission_helper = new SubmissionHelper( $submission );
// Total.
$total = new Money();
$parser = new Parser();
$tags = $submission_helper->get_tags_with_basetype_or_name_or_option( 'pronamic_pay_amount' );
foreach ( $tags as $tag ) {
$values = $submission_helper->get_values_by_tag( $tag );
foreach ( $values as $value ) {
try {
$amount = $parser->parse( $value );
$total = $total->add( $amount );
} catch ( \Exception $e ) {
continue;
}
}
}
if ( $total->is_zero() ) {
return null;
}
// Payment.
$payment = new Payment();
$payment->set_total_amount( $total );

There are multiple ways to achieve multi-currency:

  • add a filter like pronamic_pay_contact_form_7_currency
  • add pronamic_pay_currency field option
  • add a general default currency plugin setting
  • ...

@remcotolsma, thoughts?

Internal Help Scout ticket: https://secure.helpscout.net/conversation/2708876062/27722

@rvdsteege rvdsteege added the enhancement New feature or request label Sep 17, 2024
@rvdsteege rvdsteege assigned rvdsteege and remcotolsma and unassigned rvdsteege Sep 17, 2024
@remcotolsma
Copy link
Member

I searched for "contact form 7 currency setting" and came across https://contactform7.com/2015/02/27/using-values-from-a-form-tag/ . In that regard you would think a pronamic_pay_currency field option would be a good choice. Admins could possibly let visitors choose their own currency or define a different currency in a hidden field?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
2 participants