__( 'Cryptoway payments', 'cryptoway-button' ), 'callback' => [ self::class, 'export' ], ]; return $exporters; } public static function erasers( $erasers ): array { $erasers = is_array( $erasers ) ? $erasers : []; $erasers['cryptoway-button'] = [ 'eraser_friendly_name' => __( 'Cryptoway payments', 'cryptoway-button' ), 'callback' => [ self::class, 'erase' ], ]; return $erasers; } /** * The payments made with an e-mail: what they were for, the amount, the status and what the * payer typed. */ public static function export( string $email, int $page = 1 ): array { $payments = Payment::find_by_email( $email, $page, self::PER_PAGE ); $items = []; foreach ( $payments as $payment ) { $data = [ [ 'name' => __( 'Payment', 'cryptoway-button' ), 'value' => '#' . $payment->id() ], [ 'name' => __( 'For', 'cryptoway-button' ), 'value' => $payment->title() ], [ 'name' => __( 'Amount', 'cryptoway-button' ), 'value' => Amounts::fiat( $payment->amount(), $payment->currency() ) ], [ 'name' => __( 'Status', 'cryptoway-button' ), 'value' => $payment->status_label_now() ], [ 'name' => __( 'Started', 'cryptoway-button' ), 'value' => Admin::format_time( $payment->created_at() ) ], ]; foreach ( $payment->payer() as $field => $value ) { $data[] = [ 'name' => match ( $field ) { 'name' => __( 'Name', 'cryptoway-button' ), 'email' => __( 'E-mail', 'cryptoway-button' ), default => __( 'Message', 'cryptoway-button' ), }, 'value' => $value, ]; } $items[] = [ 'group_id' => 'cryptoway-button-payments', 'group_label' => __( 'Cryptoway payments', 'cryptoway-button' ), 'item_id' => 'cryptoway-button-payment-' . $payment->id(), 'data' => $data, ]; } return [ 'data' => $items, 'done' => count( $payments ) < self::PER_PAGE ]; } /** * Remove what the payer typed (name, e-mail, message) from their payments. The payments stay: * they are the site's record of money received. */ public static function erase( string $email, int $page = 1 ): array { // Always the first page: erased payments no longer match the e-mail. $payments = Payment::find_by_email( $email, 1, self::PER_PAGE ); foreach ( $payments as $payment ) { $payment->delete_meta( Payment::META_PAYER ); $payment->delete_meta( Payment::META_PAYER_EMAIL ); $payment->add_history( __( 'The payer\'s details were erased on a personal data request.', 'cryptoway-button' ) ); } return [ 'items_removed' => count( $payments ) > 0, 'items_retained' => false, 'messages' => [], 'done' => count( $payments ) < self::PER_PAGE, ]; } /** A paragraph for Settings → Privacy → the policy guide. */ public static function policy_text(): void { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } wp_add_privacy_policy_content( 'Cryptoway Payment', wp_kses_post( wpautop( __( 'When you pay with a Cryptoway Payment button, this site keeps a record of the payment: what it was for, the amount, the coin, the transaction and its status. If the button asks for your name, e-mail or a message, they are kept with that record on this site and are not sent to Cryptoway. Your e-mail is used to send you the link to content you paid for. The payment itself is processed by Cryptoway (cryptoway.com) under its own terms and privacy policy.', 'cryptoway-button' ) ) ) ); } }